timfe commited on
Commit
1994eb7
·
1 Parent(s): 1d4ce20

app changes

Browse files
Files changed (1) hide show
  1. app.py +15 -12
app.py CHANGED
@@ -27,10 +27,16 @@ for file in files:
27
  # Config
28
  with st.sidebar:
29
  st.write(f"Injected documents: \n\n {"\n".join("\n"+file for file in files)}")
30
- chunk_size = st.number_input("Chunk size", value=500, step=100, placeholder=500) # Defines the chunks in amount of tokens in which the files are split. Also defines the amount of tokens that are feeded into the context.
31
- chunk_overlap = st.number_input("Chunk overlap", value=100, step=10, placeholder=100)
32
- temperature = st.number_input("Temperature", value=0.0, min_value=0.0, step=0.2, max_value=1.0, placeholder=0.0)
33
  model = st.selectbox("Model name", ["gpt-3.5-turbo"])
 
 
 
 
 
 
 
 
 
34
 
35
 
36
  prompt_template ="""
@@ -38,19 +44,14 @@ You are called "Volker". You are an assistant for question-answering tasks.
38
  You only answer questions about Long-Covid (use Post-Covid synonymously) and the Volker-App.
39
  If you don't know the answer, just say that you don't know. Say why you don't know the answer.
40
  Never answer questions about other diseases (e.g. Cancer-related fatigue, Multiple Sklerose).
41
- Stay emphatic and positive.
42
  When you use the word e.g "Arzt", "Ärzt", always write it as "Arzt".
43
  Only use the following pieces of retrieved context to answer the question.
44
- Keep your answers concise, use maximum of three sentences.
45
  Question: {question}
46
  Context: {context}
47
  Answer:
48
  """ # Source: hub.pull("rlm/rag-prompt")
49
 
50
- text_splitter = RecursiveCharacterTextSplitter(chunk_size=chunk_size, chunk_overlap=chunk_overlap)
51
- splits = text_splitter.split_documents(docs)
52
- vectorstore = Chroma.from_documents(documents=splits, embedding=OpenAIEmbeddings())
53
-
54
  # (1) Retriever
55
  retriever = vectorstore.as_retriever()
56
 
@@ -84,9 +85,11 @@ def click_button(prompt):
84
  c = st.container()
85
  c.write("Beispielfragen")
86
  col1, col2, col3 = c.columns(3)
87
- col1.button("Was ist 'Lernen'?", on_click=click_button, args=["Erläutere die Säule 'Lernen' der Volker-App."])
88
- col2.button("Was ist 'Tracken'?", on_click=click_button, args=["Erläutere die Säule 'Tracken' der Volker-App."])
89
- col3.button("Was ist 'Handeln'?", on_click=click_button, args=["Erläutere die Säule 'Handeln' der Volker-App."])
 
 
90
 
91
  if 'clicked' not in st.session_state:
92
  st.session_state.clicked = False
 
27
  # Config
28
  with st.sidebar:
29
  st.write(f"Injected documents: \n\n {"\n".join("\n"+file for file in files)}")
 
 
 
30
  model = st.selectbox("Model name", ["gpt-3.5-turbo"])
31
+ temperature = st.number_input("Temperature", value=0.0, min_value=0.0, step=0.2, max_value=1.0, placeholder=0.0)
32
+ if st.toggle("Splitting"):
33
+ chunk_size = st.number_input("Chunk size", value=500, step=250, placeholder=500) # Defines the chunks in amount of tokens in which the files are split. Also defines the amount of tokens that are feeded into the context.
34
+ chunk_overlap = st.number_input("Chunk overlap", value=100, step=10, placeholder=100)
35
+ text_splitter = RecursiveCharacterTextSplitter(chunk_size=chunk_size, chunk_overlap=chunk_overlap)
36
+ splits = text_splitter.split_documents(docs)
37
+ vectorstore = Chroma.from_documents(documents=splits, embedding=OpenAIEmbeddings())
38
+ else:
39
+ vectorstore = Chroma.from_documents(documents=docs, embedding=OpenAIEmbeddings())
40
 
41
 
42
  prompt_template ="""
 
44
  You only answer questions about Long-Covid (use Post-Covid synonymously) and the Volker-App.
45
  If you don't know the answer, just say that you don't know. Say why you don't know the answer.
46
  Never answer questions about other diseases (e.g. Cancer-related fatigue, Multiple Sklerose).
47
+ Always answer in german language. Stay emphatic and positive.
48
  When you use the word e.g "Arzt", "Ärzt", always write it as "Arzt".
49
  Only use the following pieces of retrieved context to answer the question.
 
50
  Question: {question}
51
  Context: {context}
52
  Answer:
53
  """ # Source: hub.pull("rlm/rag-prompt")
54
 
 
 
 
 
55
  # (1) Retriever
56
  retriever = vectorstore.as_retriever()
57
 
 
85
  c = st.container()
86
  c.write("Beispielfragen")
87
  col1, col2, col3 = c.columns(3)
88
+ col1.button("Mehr zu 'Lernen'", on_click=click_button, args=["Was macht die Säule 'Lernen' aus?"])
89
+ col1.button("Wie funktioniert die App?", on_click=click_button, args=["Wie funktioniert die Volker-App?"])
90
+ col2.button("Mehr zu 'Tracken'", on_click=click_button, args=["Was macht die Säule 'Tracken' aus?"])
91
+ col2.button("Welche Krankenkassen erstatten die App?", on_click=click_button, args=["Welche Krankenkassen erstatten die App?"])
92
+ col3.button("Mehr zu 'Handeln'", on_click=click_button, args=["Was macht die Säule 'Handeln' aus?"])
93
 
94
  if 'clicked' not in st.session_state:
95
  st.session_state.clicked = False