Skip to content

Commit db31fc0

Browse files
Updated docs
1 parent 98a19ec commit db31fc0

File tree

6 files changed

+86
-55
lines changed

6 files changed

+86
-55
lines changed

.streamlit/secrets.toml.example

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ ASTRA_SCB_PATH = ""
66
ASTRA_CLIENT_ID = ""
77
ASTRA_CLIENT_SECRET = ""
88

9-
# LangSmith credentials
9+
# Optionally: LangSmith credentials for tracing
1010
LANGCHAIN_ENDPOINT = ""
1111
LANGCHAIN_API_KEY = ""
1212
LANGCHAIN_PROJECT = ""
1313

1414
[passwords]
1515
# Follow the rule: username = "password"
1616
# Where username defines the Astra Vector Table and the rails.csv experience
17-
postnl = "astradb"
18-
datastax = "astradb"
17+
postnl = "password_xyz"
18+
datastax = "password_abc"
1919

2020
[languages]
2121
# Follow the rule: username = "localization_code"
22-
# Localization_code defines the language from localization.csv
22+
# Where localization_code defines the language from localization.csv
2323
postnl = "nl_NL"
2424
datastax = "en_US"

README.md

+26-11
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,45 @@
1-
# 🦜🔗 Enterprise Chat Agent
2-
This Chat Agent is build specifically for use in Enterprise environments as it incorporates the following functions:
1+
# Configurable Enterprise Chat Agent
2+
This Chat Agent is build specifically as a reusable and configurable sample app to share with enterprises or prospects.
3+
34
1. It uses [LangChain](https://www.langchain.com/) as the framework to easily set up LLM Q&A chains
45
2. It uses [Streamlit](https://streamlit.io/) as the framework to easily create Web Applications
56
3. It uses [Astra DB](https://astra.datastax.com/) as the Vector Store to enable Rerieval Augmented Generation in order to provide meaningfull contextual interactions
6-
4. It uses Short Term Memory to keep track of what was said and generated
7+
4. It uses [Astra DB](https://astra.datastax.com/) as Short Term Memory to keep track of what was said and generated
78
5. It uses a StreamingCallbackHandler to stream output to the screen which prevents having to wait for the final answer
8-
6. It allows for new Context to be uploaded, Vectorized and Stored into the Astra DB Vector Database
9-
10-
![Q&A App using RAG](./assets/QA-app-RAG.png)
9+
6. It allows for new Content to be uploaded, Vectorized and Stored into the Astra DB Vector Database so it can be used as Context
10+
7. It offers a configurable localization through `localization.csv`
11+
8. It offers a guided experience on-rails through `rails.csv`
1112

1213
## Preparations
1314
1. First install the Python dependencies using:
1415
```
1516
pip3 install -r requirements.txt
1617
```
1718
2. Download your Astra DB Secure Connect Bundle and place it in the `streamlit-langchain` directory.
18-
3. Then update the secrets in `streamlit-langchain/.streamlit/secrets.toml`. There is an example provided at `streamlit-langchain/.streamlit/secrets.toml.example`.
19+
3. Then update the `OpenAI`, `AstraDB` and optionally `LangSmith` secrets in `streamlit-langchain/.streamlit/secrets.toml`. There is an example provided at `secrets.toml.example`.
20+
21+
## Customization
22+
Now it's time to customize the app for your specific situation or customers.
23+
### Step 1
24+
Define credentials by adding a new username and password in the `[passwords]` section in `streamlit-langchain/.streamlit/secrets.toml`.
25+
### Step 2
26+
Define the UI language of the app by adding a localization code in the `[languages]` section in `streamlit-langchain/.streamlit/secrets.toml`. Currently `en_US` and `nl_NL` are supported. However it is easy to add additional languages in `localization.csv`.
27+
### Step 3
28+
Create a guided experience by providing sample prompts in `rails.csv`. The convention here is that `<username>` from Step 1 is used to define the experience.
29+
### Step 4
30+
Start up the app and pre-load relevant PDF and Text files so that the app has content that can be used as context for the questions/prompts in the next step. All this data will be loaded into a user specific table defined by `<username>`.
31+
### Step 5
32+
Create a customized welcome page in the root folder. The convention here is to create a markdown file called `<username>.md`. Ideally, list which files have been pre-loaded.
1933

2034
## Getting started
2135
You're ready to run the app as follows:
2236
```
2337
streamlit run rag_app.py
2438
```
25-
Now upload a piece of text, like for instance the [State of the Union](streamlit-langchain/assets/state_of_the_union.txt) located at `streamlit-langchain/assets/state_of_the_union.txt` and start asking questions about it.
39+
In addition to the pre-loaded content, a user can add additional content that will be used as context for prompts.
2640

27-
Currently the App is configured to answer as a Pirate would do. Of cource you can change this as required by changing the `template`.
41+
## Deploy to the internet
42+
It's easy to upload this app to the community edition of Streamlit. As the app uses a login page it is safe to have it publicly available.
2843

29-
## Extensive comments
30-
This repo is means to get you started using Streamlit as well. Check out the extensive comments in the code. The best way to get a better understanding is to check out the simpler app at `streamlit-langchain/qa_app.py`
44+
## Warning
45+
The goal of this app is to be easily shared within enterprises. Just be aware that YOUR OPENAI subscription is being used for creating embeddings and LLM calls. This WILL incur cost.

app.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ def password_entered():
101101
st.error('😕 User not known or password incorrect')
102102
return False
103103

104+
def logout():
105+
del st.session_state['password_correct']
106+
del st.session_state['username']
107+
104108
# Function for Vectorizing uploaded data into Astra DB
105109
def vectorize_text(uploaded_files):
106110
for uploaded_file in uploaded_files:
@@ -169,6 +173,7 @@ def load_rails(username):
169173
# Check for username/password and set the username accordingly
170174
if not check_password():
171175
st.stop() # Do not continue if check_password is not True.
176+
172177
username = st.session_state['username']
173178
language = st.secrets.languages[username]
174179
lang_dict = load_localization(language)
@@ -283,16 +288,23 @@ def load_prompt():
283288
### Main ###
284289
############
285290

286-
with st.sidebar:
287-
st.image('./assets/datastax-logo.svg')
288-
st.text('')
289-
290291
# Write the welcome text
291292
try:
292293
st.markdown(Path(f"""{username}.md""").read_text())
293294
except:
294295
st.markdown(Path('welcome.md').read_text())
295296

297+
# DataStax logo
298+
with st.sidebar:
299+
st.image('./assets/datastax-logo.svg')
300+
st.text('')
301+
302+
# Logout button
303+
with st.sidebar:
304+
with st.form('logout'):
305+
st.caption(f"""{lang_dict['logout_caption']} '{username}'""")
306+
st.form_submit_button(lang_dict['logout_button'], on_click=logout)
307+
296308
# Initialize
297309
with st.sidebar:
298310
rails_dict = load_rails(username)

localization.csv

+26-22
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,47 @@
11
locale,key,value
22
en_US,connect_astra,Setting up Astra DB connection...
3-
nl_NL,connect_astra,Verkrijgen van de Astra DB verbinding...
43
en_US,load_embedding,Getting the OpenAI embedding...
5-
nl_NL,load_embedding,Verkrijgen van de OpenAI embedding...
64
en_US,load_vectorstore,Getting the Vector Store from Astra DB...
7-
nl_NL,load_vectorstore,Verkrijgen van de vector opslag...
85
en_US,load_retriever,Getting the retriever...
9-
nl_NL,load_retriever,Verkrijgen van de retriever...
106
en_US,load_message_history,Getting the Message History from Astra DB...
11-
nl_NL,load_message_history,Verkrijgen van Message History...
127
en_US,load_model,Getting the OpenAI Chat Model...
13-
nl_NL,load_model,Verkrijgen van het OpenAI chat model...
148
en_US,load_context,Upload a document for additional context
15-
nl_NL,load_context,Upload een document voor additionele context
169
en_US,load_context_button,Save
17-
nl_NL,load_context_button,Opslaan
1810
en_US,delete_context,"Delete the context, history and start over. This deletes vector embeddings for ALL users!"
19-
nl_NL,delete_context,"Verwijder de context, historie en begin opnieuw. Dit verwijderd vector data voor ALLE gebruikers!"
11+
nl_NL,delete_context_button,Delete context
2012
en_US,deleting_context,Removing context and intialising...
21-
nl_NL,deleting_context,Context verwijderen en herinitialiseren...
22-
en_US,delete_context_button,Delete context
23-
nl_NL,delete_context_button,Verwijder context
2413
en_US,delete_memory,"Delete the history in the conversational memory."
25-
nl_NL,delete_memory,"Verwijder de historie uit het chat geheugen."
2614
en_US,deleting_memory,Removing memory...
27-
nl_NL,deleting_memory,Memory verwijderen...
2815
en_US,delete_memory_button,Delete chat history
29-
nl_NL,delete_memory_button,Verwijder chat historie
3016
en_US,assistant_welcome,"Hi, I'm your personal assistant and am ready to help!"
31-
nl_NL,assistant_welcome,"Hallo, ik ben je persoonlijke assistent en sta voor je klaar!"
3217
en_US,assistant_question,What's up?
33-
nl_NL,assistant_question,Waar kan ik mee helpen?
3418
en_US,load_text,chuncks loaded into Astra DB
35-
nl_NL,load_text,chuncks geladen in Astra DB
3619
en_US,load_pdf,pages loaded into Astra DB
37-
nl_NL,load_pdf,paginas geladen in Astra DB
3820
en_US,assistant_leadin,Type for example:
39-
nl_NL,assistant_leadin,Bijvoorbeeld:
4021
en_US,rails_1,🤩 Try the following prompts ⬇️
41-
nl_NL,rails_1,🤩 Probeer de volgende prompts ⬇️
4222
en_US,rails_2,(copy and paste in the chat box)
43-
nl_NL,rails_2,(kopieer en plak in de chat)
23+
en_US,logout_caption,Welcome! Logged in as
24+
en_US,logout_button,Logout
25+
nl_NL,connect_astra,Verkrijgen van de Astra DB verbinding...
26+
nl_NL,load_embedding,Verkrijgen van de OpenAI embedding...
27+
nl_NL,load_vectorstore,Verkrijgen van de vector opslag...
28+
nl_NL,load_retriever,Verkrijgen van de retriever...
29+
nl_NL,load_message_history,Verkrijgen van Message History...
30+
nl_NL,load_model,Verkrijgen van het OpenAI chat model...
31+
nl_NL,load_context,Upload een document voor additionele context
32+
nl_NL,load_context_button,Opslaan
33+
nl_NL,delete_context,"Verwijder de context, historie en begin opnieuw. Dit verwijderd vector data voor ALLE gebruikers!"
34+
nl_NL,delete_context_button,Verwijder context
35+
nl_NL,deleting_context,Context verwijderen en herinitialiseren...
36+
nl_NL,delete_memory,"Verwijder de historie uit het chat geheugen."
37+
nl_NL,deleting_memory,Memory verwijderen...
38+
nl_NL,delete_memory_button,Verwijder chat historie
39+
nl_NL,assistant_welcome,"Hallo, ik ben je persoonlijke assistent en sta voor je klaar!"
40+
nl_NL,assistant_question,Waar kan ik mee helpen?
41+
nl_NL,load_text,chuncks geladen in Astra DB
42+
nl_NL,load_pdf,paginas geladen in Astra DB
43+
nl_NL,assistant_leadin,Bijvoorbeeld:
44+
nl_NL,rails_1,🤩 Probeer de volgende prompts ⬇️
45+
nl_NL,rails_2,(kopieer en plak in de chat)
46+
nl_NL,logout_caption,Welkom! Ingelogd als
47+
nl_NL,logout_button,Uitloggen

postnl.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
## Your personal effectivity booster
2-
Generative AI is considered to bring the next Industrial Revolution.
1+
## Jouw persoonlijke effectiviteitsbooster
2+
Er wordt aangenomen dat generatieve AI de volgende industriële revolutie zal brengen.
33

4-
Why? Studies show a **37% efficiency boost** in day to day work activities!
4+
Waarom? Uit onderzoek blijkt dat de **efficiëntie van de dagelijkse werkzaamheden met 37% toeneemt!**
55

6-
#### What is this app?
7-
This app is a Chat Agent which takes into account Enterprise Context to provide meaningfull and contextual responses.
8-
Why is this a big thing? It is because the underlying Foundational Large Language Models are not trained on Enterprise Data. They have no way of knowing anything about your organization.
9-
Also they are trained upon a moment in time, so typically miss out on relevant and recent information.
6+
#### Wat is deze app?
7+
Deze app is een chatagent die rekening houdt met Enterprise Content om zinvolle en contextuele antwoorden te bieden.
8+
Waarom is dit iets groots? Dit komt omdat de onderliggende Foundational Large Language Models niet zijn getraind op bedrijfsgegevens. Ze kunnen niets over uw organisatie weten.
9+
Ze zijn bovendien op een bepaald moment getraind, waardoor ze doorgaans relevante en recente informatie missen.
1010

11-
#### What does it know?
12-
The app has been preloaded with the following context:
11+
#### Wat weet het?
12+
De app is vooraf geladen met de volgende content:
1313
- [PDF met Business Principles](https://www.postnl.nl/Images/business-principles-nl_tcm10-66407.pdf)
1414
- [PDF met haalservice aanbod](https://www.postnl.nl/Images/aanleveren-pakketten_tcm10-236964.pdf)
1515
- [Webpagina over zakelijk aanbod](https://www.postnl.nl/zakelijke-oplossingen/)
1616
- [Webpagina over duurzaamheid](https://www.postnl.nl/zakelijke-oplossingen/duurzaamheid/)
1717

18-
This means you can start interacting with your personal assistant based on the above topics.
18+
Dit betekent dat u op basis van de bovenstaande onderwerpen kunt beginnen met de interactie met uw persoonlijke assistent.
1919

20-
#### Adding additional context
21-
On top of the above you have the opportunity to add additional information which then can be taken into account by the personal assistant. Just drop a PDF or Text file into the upload box in the sidebar and hit `Save`.
20+
#### Extra content toevoegen
21+
Bovenop het bovenstaande heeft u de mogelijkheid om aanvullende informatie toe te voegen, waarmee de persoonlijke assistent rekening kan houden. Plaats gewoon een PDF- of tekstbestand in het uploadvak in de zijbalk en klik op 'Opslaan'.
2222

23-
By the way... Be careful with the `Delete context` button. As this will do exactly that. I deletes the preloaded content mentioned above rendering the personal assistant non-contextual 😉
23+
Overigens... Wees voorzichtig met de knop `Context verwijderen`. Omdat dit precies dat zal doen. Het verwijderd de hierboven genoemde vooraf geladen inhoud, waardoor de persoonlijke assistent niet-contextueel wordt 😉
2424

2525
---

welcome.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ Also they are trained upon a moment in time, so typically miss out on relevant a
1111
#### What does it know?
1212
Just drop a PDF or Text file into the upload box in the sidebar and hit `Save`.
1313

14-
By the way... Be careful with the `Delete context` button. As this will do exactly that. I deletes the preloaded content mentioned above rendering the personal assistant non-contextual 😉
14+
By the way... Be careful with the `Delete context` button. As this will do exactly that. It deletes the preloaded content mentioned above rendering the personal assistant non-contextual 😉
1515

1616
---

0 commit comments

Comments
 (0)