AIencoder commited on
Commit
127099b
Β·
verified Β·
1 Parent(s): ced25cf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -10,8 +10,9 @@ except Exception as e:
10
 
11
  def generate_response(message, history, mode_selection):
12
  """
13
- ChatInterface automatically handles history.
14
- We just need to return the string response.
 
15
  """
16
  if not chimera:
17
  return "❌ Error: API Keys missing. Check Settings -> Secrets."
@@ -23,10 +24,10 @@ def generate_response(message, history, mode_selection):
23
  "πŸ”¬ SFE (Data/Science)": "SFE",
24
  "🎨 CSM (Story/Creative)": "CSM"
25
  }
26
- # If mode_selection is None (default), use Auto
27
  selected_role = role_map.get(mode_selection, "Auto")
28
 
29
- # Get response (Chimera handles the logic)
30
  response_text, active_module = chimera.process_request(message, history, selected_role)
31
 
32
  # Return formatted string
@@ -38,23 +39,23 @@ body {background-color: #0b0f19; color: #c9d1d9;}
38
  .gradio-container {font-family: 'IBM Plex Mono', monospace;}
39
  """
40
 
41
- # We use ChatInterface for maximum stability
42
- with gr.Blocks(css=custom_css, title="Axon Trinity") as demo:
43
  gr.Markdown("# βš”οΈ AXON: QWEN TRINITY")
44
 
45
- # The Mode Selector
46
  mode_picker = gr.Dropdown(
47
  choices=["Auto (Router)", "⚑ ASM (Qwen + Llama)", "πŸ”¬ SFE (Data/Science)", "🎨 CSM (Story/Creative)"],
48
  value="Auto (Router)",
49
  label="Persona Mode"
50
  )
51
 
52
- # The Chat Interface (Handles all UI logic automatically)
 
53
  chat = gr.ChatInterface(
54
  fn=generate_response,
55
- additional_inputs=[mode_picker],
56
- type="messages" # Trying the modern format one last time, safely
57
  )
58
 
59
  if __name__ == "__main__":
60
- demo.launch(ssr_mode=False)
 
 
10
 
11
  def generate_response(message, history, mode_selection):
12
  """
13
+ Standard ChatInterface logic.
14
+ Accepts: message (str), history (list of lists), mode_selection (str)
15
+ Returns: response (str)
16
  """
17
  if not chimera:
18
  return "❌ Error: API Keys missing. Check Settings -> Secrets."
 
24
  "πŸ”¬ SFE (Data/Science)": "SFE",
25
  "🎨 CSM (Story/Creative)": "CSM"
26
  }
27
+ # Handle case where mode is None
28
  selected_role = role_map.get(mode_selection, "Auto")
29
 
30
+ # Get response from Chimera Brain
31
  response_text, active_module = chimera.process_request(message, history, selected_role)
32
 
33
  # Return formatted string
 
39
  .gradio-container {font-family: 'IBM Plex Mono', monospace;}
40
  """
41
 
42
+ # 1. Removed 'css' from Blocks to fix the Warning
43
+ with gr.Blocks(title="Axon Trinity") as demo:
44
  gr.Markdown("# βš”οΈ AXON: QWEN TRINITY")
45
 
 
46
  mode_picker = gr.Dropdown(
47
  choices=["Auto (Router)", "⚑ ASM (Qwen + Llama)", "πŸ”¬ SFE (Data/Science)", "🎨 CSM (Story/Creative)"],
48
  value="Auto (Router)",
49
  label="Persona Mode"
50
  )
51
 
52
+ # 2. REMOVED 'type="messages"' completely.
53
+ # This forces it to use the default 'List of Lists' format which never crashes.
54
  chat = gr.ChatInterface(
55
  fn=generate_response,
56
+ additional_inputs=[mode_picker]
 
57
  )
58
 
59
  if __name__ == "__main__":
60
+ # 3. Moved CSS here and disabled SSR for safety
61
+ demo.launch(ssr_mode=False, css=custom_css)