AIencoder commited on
Commit
0dbf1cb
·
verified ·
1 Parent(s): 152a6c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -9,8 +9,13 @@ except Exception as e:
9
  print(f"Startup Error: {e}")
10
 
11
  def chat_logic(message, history, mode_selection):
 
 
 
 
12
  if not chimera:
13
- history.append({"role": "assistant", "content": "❌ Error: API Keys missing. Check Settings -> Secrets."})
 
14
  return history, ""
15
 
16
  # Map friendly names
@@ -28,10 +33,10 @@ def chat_logic(message, history, mode_selection):
28
  # Format output
29
  final_response = f"**[{active_module} Active]**\n\n{response_text}"
30
 
31
- # --- THE FIX: DICTIONARY FORMAT ---
32
- # The error explicitly asked for 'role' and 'content' keys.
33
- history.append({"role": "user", "content": message})
34
- history.append({"role": "assistant", "content": final_response})
35
 
36
  return history, ""
37
 
@@ -54,8 +59,7 @@ with gr.Blocks(title="Axon Trinity") as demo:
54
 
55
  with gr.Row():
56
  with gr.Column(scale=4):
57
- # We do NOT put type="messages" here (to avoid the first error)
58
- # But we DO feed it dictionaries (to avoid the second error)
59
  chatbot = gr.Chatbot(elem_id="chatbot")
60
 
61
  with gr.Column(scale=1):
 
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
+
16
  if not chimera:
17
+ # Universal Format: [User Message, Bot Message]
18
+ history.append([message, "❌ Error: API Keys missing. Check Settings -> Secrets."])
19
  return history, ""
20
 
21
  # Map friendly names
 
33
  # Format output
34
  final_response = f"**[{active_module} Active]**\n\n{response_text}"
35
 
36
+ # --- THE FIX: UNIVERSAL LIST FORMAT ---
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, ""
42
 
 
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):