Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from src.chimera_core import Chimera
|
| 3 |
|
| 4 |
-
# Initialize
|
| 5 |
try:
|
| 6 |
chimera = Chimera()
|
| 7 |
except Exception as e:
|
|
@@ -10,14 +10,13 @@ except Exception as e:
|
|
| 10 |
|
| 11 |
def chat_logic(message, history, mode_selection):
|
| 12 |
if not chimera:
|
| 13 |
-
|
| 14 |
-
history.append({"role": "assistant", "content": "β Error: API Key missing. Check Settings -> Secrets."})
|
| 15 |
return history, ""
|
| 16 |
|
| 17 |
-
# Map friendly names
|
| 18 |
role_map = {
|
| 19 |
"Auto (Router)": "Auto",
|
| 20 |
-
"
|
| 21 |
"π¬ SFE (Scientist)": "SFE",
|
| 22 |
"π¨ CSM (Writer)": "CSM"
|
| 23 |
}
|
|
@@ -26,50 +25,35 @@ def chat_logic(message, history, mode_selection):
|
|
| 26 |
# Get response
|
| 27 |
response_text, active_module = chimera.process_request(message, history, selected_role)
|
| 28 |
|
| 29 |
-
# Format
|
| 30 |
final_response = f"**[{active_module} Active]**\n\n{response_text}"
|
| 31 |
|
| 32 |
-
# --- THE FIX IS HERE ---
|
| 33 |
-
# Instead of history.append((message, final_response)), we do this:
|
| 34 |
history.append({"role": "user", "content": message})
|
| 35 |
history.append({"role": "assistant", "content": 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 |
-
|
| 44 |
-
#chatbot {
|
| 45 |
-
height: 600px;
|
| 46 |
-
border: 1px solid #30363d;
|
| 47 |
-
background-color: #0d1117;
|
| 48 |
-
border-radius: 12px;
|
| 49 |
-
}
|
| 50 |
-
.feedback {font-size: 12px; color: #8b949e;}
|
| 51 |
"""
|
| 52 |
|
| 53 |
-
with gr.Blocks(css=custom_css, title="
|
| 54 |
-
gr.Markdown("#
|
| 55 |
-
gr.Markdown("*>
|
| 56 |
|
| 57 |
with gr.Row():
|
| 58 |
with gr.Column(scale=4):
|
| 59 |
chatbot = gr.Chatbot(elem_id="chatbot", type="messages")
|
| 60 |
-
|
| 61 |
with gr.Column(scale=1):
|
| 62 |
-
gr.Markdown("### βοΈ System Controls")
|
| 63 |
mode = gr.Dropdown(
|
| 64 |
-
choices=["Auto (Router)", "
|
| 65 |
value="Auto (Router)",
|
| 66 |
-
label="Persona Mode"
|
| 67 |
-
interactive=True
|
| 68 |
)
|
| 69 |
-
gr.Markdown("*Select 'Auto' to let the AI decide, or force a specific module.*")
|
| 70 |
|
| 71 |
-
msg = gr.Textbox(placeholder="Enter
|
| 72 |
-
|
| 73 |
msg.submit(chat_logic, [msg, chatbot, mode], [chatbot, msg])
|
| 74 |
|
| 75 |
if __name__ == "__main__":
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from src.chimera_core import Chimera
|
| 3 |
|
| 4 |
+
# Initialize
|
| 5 |
try:
|
| 6 |
chimera = Chimera()
|
| 7 |
except Exception as 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
|
| 17 |
role_map = {
|
| 18 |
"Auto (Router)": "Auto",
|
| 19 |
+
"β‘ ASM (Dual-Core Code)": "ASM",
|
| 20 |
"π¬ SFE (Scientist)": "SFE",
|
| 21 |
"π¨ CSM (Writer)": "CSM"
|
| 22 |
}
|
|
|
|
| 25 |
# Get response
|
| 26 |
response_text, active_module = chimera.process_request(message, history, selected_role)
|
| 27 |
|
| 28 |
+
# Format output
|
| 29 |
final_response = f"**[{active_module} Active]**\n\n{response_text}"
|
| 30 |
|
|
|
|
|
|
|
| 31 |
history.append({"role": "user", "content": message})
|
| 32 |
history.append({"role": "assistant", "content": final_response})
|
| 33 |
|
| 34 |
return history, ""
|
| 35 |
|
|
|
|
| 36 |
custom_css = """
|
| 37 |
body {background-color: #0b0f19; color: #c9d1d9;}
|
| 38 |
.gradio-container {font-family: 'IBM Plex Mono', monospace;}
|
| 39 |
+
#chatbot {height: 600px; border: 1px solid #30363d; background-color: #0d1117;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
"""
|
| 41 |
|
| 42 |
+
with gr.Blocks(css=custom_css, title="Axon Dual-Core") as demo:
|
| 43 |
+
gr.Markdown("# βοΈ AXON: DUAL-CORE")
|
| 44 |
+
gr.Markdown("*> Pipeline: Gemini 2.5 (Draft) β GPT-4o (Refine)*")
|
| 45 |
|
| 46 |
with gr.Row():
|
| 47 |
with gr.Column(scale=4):
|
| 48 |
chatbot = gr.Chatbot(elem_id="chatbot", type="messages")
|
|
|
|
| 49 |
with gr.Column(scale=1):
|
|
|
|
| 50 |
mode = gr.Dropdown(
|
| 51 |
+
choices=["Auto (Router)", "β‘ ASM (Dual-Core Code)", "π¬ SFE (Scientist)", "π¨ CSM (Writer)"],
|
| 52 |
value="Auto (Router)",
|
| 53 |
+
label="Persona Mode"
|
|
|
|
| 54 |
)
|
|
|
|
| 55 |
|
| 56 |
+
msg = gr.Textbox(placeholder="Enter coding task...", autofocus=True)
|
|
|
|
| 57 |
msg.submit(chat_logic, [msg, chatbot, mode], [chatbot, msg])
|
| 58 |
|
| 59 |
if __name__ == "__main__":
|