Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,6 @@ except Exception as e:
|
|
| 9 |
print(f"Startup Error: {e}")
|
| 10 |
|
| 11 |
def chat_logic(message, history, mode_selection):
|
| 12 |
-
# Ensure history is a list
|
| 13 |
if history is None:
|
| 14 |
history = []
|
| 15 |
|
|
@@ -18,7 +17,6 @@ def chat_logic(message, history, mode_selection):
|
|
| 18 |
history.append([message, "❌ Error: API Keys missing. Check Settings -> Secrets."])
|
| 19 |
return history, ""
|
| 20 |
|
| 21 |
-
# Map friendly names
|
| 22 |
role_map = {
|
| 23 |
"Auto (Router)": "Auto",
|
| 24 |
"⚡ ASM (Qwen + Llama)": "ASM",
|
|
@@ -33,9 +31,7 @@ def chat_logic(message, history, mode_selection):
|
|
| 33 |
# Format output
|
| 34 |
final_response = f"**[{active_module} Active]**\n\n{response_text}"
|
| 35 |
|
| 36 |
-
#
|
| 37 |
-
# We append a simple list: [User, Assistant]
|
| 38 |
-
# This works on ALL Gradio versions.
|
| 39 |
history.append([message, final_response])
|
| 40 |
|
| 41 |
return history, ""
|
|
@@ -59,7 +55,6 @@ with gr.Blocks(title="Axon Trinity") as demo:
|
|
| 59 |
|
| 60 |
with gr.Row():
|
| 61 |
with gr.Column(scale=4):
|
| 62 |
-
# No 'type' argument -> Defaults to Universal Mode
|
| 63 |
chatbot = gr.Chatbot(elem_id="chatbot")
|
| 64 |
|
| 65 |
with gr.Column(scale=1):
|
|
@@ -73,4 +68,5 @@ with gr.Blocks(title="Axon Trinity") as demo:
|
|
| 73 |
msg.submit(chat_logic, [msg, chatbot, mode], [chatbot, msg])
|
| 74 |
|
| 75 |
if __name__ == "__main__":
|
| 76 |
-
|
|
|
|
|
|
| 9 |
print(f"Startup Error: {e}")
|
| 10 |
|
| 11 |
def chat_logic(message, history, mode_selection):
|
|
|
|
| 12 |
if history is None:
|
| 13 |
history = []
|
| 14 |
|
|
|
|
| 17 |
history.append([message, "❌ Error: API Keys missing. Check Settings -> Secrets."])
|
| 18 |
return history, ""
|
| 19 |
|
|
|
|
| 20 |
role_map = {
|
| 21 |
"Auto (Router)": "Auto",
|
| 22 |
"⚡ ASM (Qwen + Llama)": "ASM",
|
|
|
|
| 31 |
# Format output
|
| 32 |
final_response = f"**[{active_module} Active]**\n\n{response_text}"
|
| 33 |
|
| 34 |
+
# Universal List Format (Crash-Proof)
|
|
|
|
|
|
|
| 35 |
history.append([message, final_response])
|
| 36 |
|
| 37 |
return history, ""
|
|
|
|
| 55 |
|
| 56 |
with gr.Row():
|
| 57 |
with gr.Column(scale=4):
|
|
|
|
| 58 |
chatbot = gr.Chatbot(elem_id="chatbot")
|
| 59 |
|
| 60 |
with gr.Column(scale=1):
|
|
|
|
| 68 |
msg.submit(chat_logic, [msg, chatbot, mode], [chatbot, msg])
|
| 69 |
|
| 70 |
if __name__ == "__main__":
|
| 71 |
+
# FIX: Disable SSR to prevent the asyncio crash
|
| 72 |
+
demo.launch(css=custom_css, ssr_mode=False)
|