Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,65 +8,53 @@ except Exception as e:
|
|
| 8 |
chimera = None
|
| 9 |
print(f"Startup Error: {e}")
|
| 10 |
|
| 11 |
-
def
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
| 15 |
if not chimera:
|
| 16 |
-
|
| 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",
|
| 23 |
"π¬ SFE (Data/Science)": "SFE",
|
| 24 |
"π¨ CSM (Story/Creative)": "CSM"
|
| 25 |
}
|
|
|
|
| 26 |
selected_role = role_map.get(mode_selection, "Auto")
|
| 27 |
|
| 28 |
-
# Get response
|
| 29 |
response_text, active_module = chimera.process_request(message, history, selected_role)
|
| 30 |
|
| 31 |
-
#
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
# Universal List Format (Crash-Proof)
|
| 35 |
-
history.append([message, final_response])
|
| 36 |
-
|
| 37 |
-
return history, ""
|
| 38 |
|
| 39 |
# --- Sci-Fi Theme CSS ---
|
| 40 |
custom_css = """
|
| 41 |
body {background-color: #0b0f19; color: #c9d1d9;}
|
| 42 |
.gradio-container {font-family: 'IBM Plex Mono', monospace;}
|
| 43 |
-
header {display: none !important;}
|
| 44 |
-
#chatbot {
|
| 45 |
-
height: 600px;
|
| 46 |
-
border: 1px solid #30363d;
|
| 47 |
-
background-color: #0d1117;
|
| 48 |
-
border-radius: 12px;
|
| 49 |
-
}
|
| 50 |
"""
|
| 51 |
|
| 52 |
-
|
|
|
|
| 53 |
gr.Markdown("# βοΈ AXON: QWEN TRINITY")
|
| 54 |
-
gr.Markdown("*> Pipeline: Gemini (Plan) β Qwen 3 (Code) β Llama 3.3 (Refine)*")
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
choices=["Auto (Router)", "β‘ ASM (Qwen + Llama)", "π¬ SFE (Data/Science)", "π¨ CSM (Story/Creative)"],
|
| 63 |
-
value="Auto (Router)",
|
| 64 |
-
label="Persona Mode"
|
| 65 |
-
)
|
| 66 |
|
| 67 |
-
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
if __name__ == "__main__":
|
| 71 |
-
|
| 72 |
-
demo.launch(css=custom_css, ssr_mode=False)
|
|
|
|
| 8 |
chimera = None
|
| 9 |
print(f"Startup Error: {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."
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
# Map friendly names
|
| 20 |
role_map = {
|
| 21 |
"Auto (Router)": "Auto",
|
| 22 |
"β‘ ASM (Qwen + Llama)": "ASM",
|
| 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
|
| 33 |
+
return f"**[{active_module} Active]**\n\n{response_text}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
# --- Sci-Fi Theme CSS ---
|
| 36 |
custom_css = """
|
| 37 |
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)
|
|
|