Spaces:
Runtime error
Runtime error
wolfgangspoony commited on
Commit Β·
bf1369a
1
Parent(s): 2047b23
Revert to legacy Gradio format for compatibility
Browse files
app.py
CHANGED
|
@@ -27,7 +27,7 @@ def load_history():
|
|
| 27 |
with gr.Blocks(title="Brain") as demo:
|
| 28 |
with gr.Tabs():
|
| 29 |
with gr.TabItem("Chat"):
|
| 30 |
-
chatbot = gr.Chatbot(label="Brain", height=500
|
| 31 |
msg = gr.Textbox(placeholder="Type here...", show_label=False)
|
| 32 |
send_btn = gr.Button("Send")
|
| 33 |
|
|
@@ -35,19 +35,16 @@ with gr.Blocks(title="Brain") as demo:
|
|
| 35 |
if not message.strip():
|
| 36 |
return "", history
|
| 37 |
if agent is None or agent_ctx is None:
|
| 38 |
-
history.append(
|
| 39 |
-
history.append({"role": "assistant", "content": "Error: System failed to initialize."})
|
| 40 |
return "", history
|
| 41 |
try:
|
| 42 |
reasoning, response, searches = await run_with_trace(
|
| 43 |
agent, agent_ctx, message, memory
|
| 44 |
)
|
| 45 |
-
history.append(
|
| 46 |
-
history.append({"role": "assistant", "content": response})
|
| 47 |
return "", history
|
| 48 |
except Exception as e:
|
| 49 |
-
history.append(
|
| 50 |
-
history.append({"role": "assistant", "content": f"Error: {str(e)}"})
|
| 51 |
return "", history
|
| 52 |
|
| 53 |
send_btn.click(respond, [msg, chatbot], [msg, chatbot])
|
|
|
|
| 27 |
with gr.Blocks(title="Brain") as demo:
|
| 28 |
with gr.Tabs():
|
| 29 |
with gr.TabItem("Chat"):
|
| 30 |
+
chatbot = gr.Chatbot(label="Brain", height=500)
|
| 31 |
msg = gr.Textbox(placeholder="Type here...", show_label=False)
|
| 32 |
send_btn = gr.Button("Send")
|
| 33 |
|
|
|
|
| 35 |
if not message.strip():
|
| 36 |
return "", history
|
| 37 |
if agent is None or agent_ctx is None:
|
| 38 |
+
history.append([message, "Error: System failed to initialize."])
|
|
|
|
| 39 |
return "", history
|
| 40 |
try:
|
| 41 |
reasoning, response, searches = await run_with_trace(
|
| 42 |
agent, agent_ctx, message, memory
|
| 43 |
)
|
| 44 |
+
history.append([message, response])
|
|
|
|
| 45 |
return "", history
|
| 46 |
except Exception as e:
|
| 47 |
+
history.append([message, f"Error: {str(e)}"])
|
|
|
|
| 48 |
return "", history
|
| 49 |
|
| 50 |
send_btn.click(respond, [msg, chatbot], [msg, chatbot])
|