Tobias Geisler
commited on
Commit
·
43f3a3c
1
Parent(s):
ab638cf
fix chat history display
Browse files
app.py
CHANGED
@@ -30,12 +30,17 @@ def chat_with_gpt(user_input, system_message, temperature, history):
|
|
30 |
history.append({"role": "assistant", "content": assistant_message})
|
31 |
|
32 |
# Convert history to the format expected by gr.Chatbot
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
35 |
|
36 |
return formatted_history, history
|
37 |
|
38 |
|
|
|
39 |
def reset_history(system_message):
|
40 |
# Return an empty conversation history
|
41 |
return [], []
|
|
|
30 |
history.append({"role": "assistant", "content": assistant_message})
|
31 |
|
32 |
# Convert history to the format expected by gr.Chatbot
|
33 |
+
formatted_history = []
|
34 |
+
for msg in history:
|
35 |
+
if msg["role"] == "user":
|
36 |
+
formatted_history.append([msg["content"], None])
|
37 |
+
else: # msg["role"] == "assistant"
|
38 |
+
formatted_history.append([None, msg["content"]])
|
39 |
|
40 |
return formatted_history, history
|
41 |
|
42 |
|
43 |
+
|
44 |
def reset_history(system_message):
|
45 |
# Return an empty conversation history
|
46 |
return [], []
|