Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -169,13 +169,13 @@ def handle_no_answer(response):
|
|
| 169 |
return random.choice(alternative_responses) # Randomly select a response
|
| 170 |
return response
|
| 171 |
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
|
| 180 |
def page1():
|
| 181 |
try:
|
|
@@ -240,25 +240,21 @@ def page1():
|
|
| 240 |
query = "Was bedeutet die Vorhaltefinanzierung?"
|
| 241 |
|
| 242 |
|
| 243 |
-
|
| 244 |
if query:
|
|
|
|
| 245 |
st.session_state['chat_history_page1'].append(("User", query, "new"))
|
| 246 |
-
|
| 247 |
# Start timing
|
| 248 |
start_time = time.time()
|
| 249 |
|
| 250 |
with st.spinner('Bot is thinking...'):
|
| 251 |
-
system_message = create_system_message() # Create system message
|
| 252 |
chain = load_chatbot()
|
| 253 |
docs = VectorStore.similarity_search(query=query, k=5)
|
| 254 |
-
|
| 255 |
-
# Include system message in conversation history
|
| 256 |
-
conversation_history = [{'role': 'system', 'content': system_message['content']}]
|
| 257 |
-
conversation_history.extend(docs) # Add the document search results
|
| 258 |
-
|
| 259 |
with get_openai_callback() as cb:
|
| 260 |
-
response = chain.run(input_documents=
|
| 261 |
-
response = handle_no_answer(response)
|
|
|
|
| 262 |
|
| 263 |
|
| 264 |
# Stop timing
|
|
@@ -292,7 +288,6 @@ def page1():
|
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
-
|
| 296 |
def page2():
|
| 297 |
try:
|
| 298 |
hide_streamlit_style = """
|
|
|
|
| 169 |
return random.choice(alternative_responses) # Randomly select a response
|
| 170 |
return response
|
| 171 |
|
| 172 |
+
def ask_bot(query):
|
| 173 |
+
# Definiere den standardmäßigen Prompt
|
| 174 |
+
standard_prompt = "Schreibe immer höflich und auf Deutsch und frage immer nach Jahren, wenn keines explizit angegeben ist. "
|
| 175 |
+
# Kombiniere den standardmäßigen Prompt mit der Benutzeranfrage
|
| 176 |
+
full_query = standard_prompt + query
|
| 177 |
+
return full_query
|
| 178 |
+
|
| 179 |
|
| 180 |
def page1():
|
| 181 |
try:
|
|
|
|
| 240 |
query = "Was bedeutet die Vorhaltefinanzierung?"
|
| 241 |
|
| 242 |
|
| 243 |
+
|
| 244 |
if query:
|
| 245 |
+
full_query = ask_bot(query)
|
| 246 |
st.session_state['chat_history_page1'].append(("User", query, "new"))
|
| 247 |
+
|
| 248 |
# Start timing
|
| 249 |
start_time = time.time()
|
| 250 |
|
| 251 |
with st.spinner('Bot is thinking...'):
|
|
|
|
| 252 |
chain = load_chatbot()
|
| 253 |
docs = VectorStore.similarity_search(query=query, k=5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
with get_openai_callback() as cb:
|
| 255 |
+
response = chain.run(input_documents=docs, question=full_query)
|
| 256 |
+
response = handle_no_answer(response) # Process the response through the new function
|
| 257 |
+
|
| 258 |
|
| 259 |
|
| 260 |
# Stop timing
|
|
|
|
| 288 |
|
| 289 |
|
| 290 |
|
|
|
|
| 291 |
def page2():
|
| 292 |
try:
|
| 293 |
hide_streamlit_style = """
|