Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -169,18 +169,24 @@ 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 combine_history_with_query(current_query, history):
|
| 181 |
-
combined_history = "
|
| 182 |
-
|
| 183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
def page1():
|
| 186 |
try:
|
|
|
|
| 169 |
return random.choice(alternative_responses) # Randomly select a response
|
| 170 |
return response
|
| 171 |
|
| 172 |
+
# Funktion zum sicheren Hinzufügen zur Chat-Historie
|
| 173 |
+
def add_to_chat_history(speaker, message, history_key):
|
| 174 |
+
if history_key in st.session_state:
|
| 175 |
+
st.session_state[history_key].append((speaker, message))
|
| 176 |
+
|
| 177 |
+
# Beispiel für das Hinzufügen zur Chat-Historie
|
| 178 |
+
add_to_chat_history("User", user_input, 'chat_history_page1')
|
| 179 |
+
add_to_chat_history("Bot", bot_response, 'chat_history_page1')
|
| 180 |
+
|
| 181 |
+
# Funktion zum sicheren Kombinieren der Chat-Historie mit der aktuellen Anfrage
|
| 182 |
def combine_history_with_query(current_query, history):
|
| 183 |
+
combined_history = ""
|
| 184 |
+
for chat in history:
|
| 185 |
+
# Stelle sicher, dass das Tupel zwei Elemente hat
|
| 186 |
+
if len(chat) >= 2:
|
| 187 |
+
combined_history += f"{chat[0]}: {chat[1]} "
|
| 188 |
+
return combined_history + current_query
|
| 189 |
+
|
| 190 |
|
| 191 |
def page1():
|
| 192 |
try:
|