import gradio as gr from src.chimera_core import Chimera # Initialize try: chimera = Chimera() except Exception as e: chimera = None print(f"Startup Error: {e}") def generate_response(message, history, mode_selection): """ ChatInterface automatically handles history. We just need to return the string response. """ if not chimera: return "❌ Error: API Keys missing. Check Settings -> Secrets." # Map friendly names role_map = { "Auto (Router)": "Auto", "⚡ ASM (Qwen + Llama)": "ASM", "🔬 SFE (Data/Science)": "SFE", "🎨 CSM (Story/Creative)": "CSM" } # If mode_selection is None (default), use Auto selected_role = role_map.get(mode_selection, "Auto") # Get response (Chimera handles the logic) response_text, active_module = chimera.process_request(message, history, selected_role) # Return formatted string return f"**[{active_module} Active]**\n\n{response_text}" # --- Sci-Fi Theme CSS --- custom_css = """ body {background-color: #0b0f19; color: #c9d1d9;} .gradio-container {font-family: 'IBM Plex Mono', monospace;} """ # We use ChatInterface for maximum stability with gr.Blocks(css=custom_css, title="Axon Trinity") as demo: gr.Markdown("# ⚔️ AXON: QWEN TRINITY") # The Mode Selector mode_picker = gr.Dropdown( choices=["Auto (Router)", "⚡ ASM (Qwen + Llama)", "🔬 SFE (Data/Science)", "🎨 CSM (Story/Creative)"], value="Auto (Router)", label="Persona Mode" ) # The Chat Interface (Handles all UI logic automatically) chat = gr.ChatInterface( fn=generate_response, additional_inputs=[mode_picker], type="messages" # Trying the modern format one last time, safely ) if __name__ == "__main__": demo.launch(ssr_mode=False)