Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -2030,7 +2030,17 @@ def create_gradio_interface():
|
|
| 2030 |
], f, indent=2)
|
| 2031 |
except Exception as e:
|
| 2032 |
print(f"[WARN] Could not persist KPI snapshots: {e}")
|
| 2033 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2034 |
|
| 2035 |
msg.submit(respond, [msg, chatbot], [chatbot, thinking_box])
|
| 2036 |
send_btn.click(respond, [msg, chatbot], [chatbot, thinking_box])
|
|
|
|
| 2030 |
], f, indent=2)
|
| 2031 |
except Exception as e:
|
| 2032 |
print(f"[WARN] Could not persist KPI snapshots: {e}")
|
| 2033 |
+
# Convert history to Gradio Chatbot format: list of [user, assistant] pairs
|
| 2034 |
+
formatted_history = []
|
| 2035 |
+
temp = []
|
| 2036 |
+
for h in history:
|
| 2037 |
+
if h["role"] == "user":
|
| 2038 |
+
temp = [h["content"]]
|
| 2039 |
+
elif h["role"] == "assistant" and temp:
|
| 2040 |
+
temp.append(h["content"])
|
| 2041 |
+
formatted_history.append(temp)
|
| 2042 |
+
temp = []
|
| 2043 |
+
return formatted_history, thinking
|
| 2044 |
|
| 2045 |
msg.submit(respond, [msg, chatbot], [chatbot, thinking_box])
|
| 2046 |
send_btn.click(respond, [msg, chatbot], [chatbot, thinking_box])
|