File size: 1,857 Bytes
713e8e6
 
 
70f515f
713e8e6
 
 
 
 
 
ced25cf
 
 
 
 
713e8e6
ced25cf
713e8e6
ced25cf
713e8e6
 
4654bb9
 
 
713e8e6
ced25cf
713e8e6
 
ced25cf
713e8e6
 
ced25cf
 
713e8e6
8807fb0
713e8e6
 
 
 
 
ced25cf
 
4654bb9
713e8e6
ced25cf
 
 
 
 
 
713e8e6
ced25cf
 
 
 
 
 
713e8e6
 
ced25cf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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)