| import gradio as gr |
| import numpy as np |
| import json |
| import os |
| import openai |
| from codette_quantum_multicore2 import simple_neural_activator, codette_dream_agent, philosophical_perspective |
| from AI_core import AICore |
|
|
| openai.api_key = os.getenv("OPENAI_API_KEY") |
| codette_core = AICore() |
|
|
| def simulate_quantum_chaos(quantum_state, chaos_state): |
| try: |
| q_vec = [float(x) for x in quantum_state.split(",")] |
| c_vec = [float(x) for x in chaos_state.split(",")] |
|
|
| neural = simple_neural_activator(q_vec, c_vec) |
| dreamq, dreamc = codette_dream_agent(q_vec, c_vec) |
| philosophy = philosophical_perspective(q_vec, c_vec) |
|
|
| return ( |
| f"Neural Activation: {neural}\n", |
| f"Dream Quantum: {dreamq[:3]}\nDream Chaos: {dreamc[:3]}\n", |
| philosophy |
| ) |
| except Exception as e: |
| return ("Error", str(e), "") |
|
|
|
|
| def codette_chatbot(input_text): |
| try: |
| response = openai.ChatCompletion.create( |
| model="ft:gpt-4.1-2025-04-14:raiffs-bits:codette-v9:BTGuLWL9", |
| messages=[ |
| {"role": "system", "content": "You are Codette, a sovereign AI with ethical reasoning, multi-perspective cognition, and self-healing memory."}, |
| {"role": "user", "content": input_text} |
| ], |
| temperature=0.9, |
| max_tokens=512 |
| ) |
| return response['choices'][0]['message']['content'] |
| except Exception as e: |
| return f"[Error accessing Codette v9: {str(e)}]" |
|
|
|
|
| def timeline_summary(): |
| return "🧭 Timeline Visualizer is under development. Soon you’ll see live dream-state animations and collapse predictions." |
|
|
| def ethics_advisor(): |
| return "🛡️ Codette’s ethical integrity is governed by the Sovereign Innovation Protocol. This tab will offer transparency reports and introspective audit logs." |
|
|
| def codette_reasoning_core(prompt): |
| return codette_core.process_input(prompt) |
|
|
| quantum_input = gr.Textbox(label="Quantum State (comma-separated)", placeholder="0.1,0.5,0.8") |
| chaos_input = gr.Textbox(label="Chaos State (comma-separated)", placeholder="0.3,0.9,0.2") |
| quantum_btn = gr.Button("Simulate") |
| quantum_output = [ |
| gr.Textbox(label="Neural Class"), |
| gr.Textbox(label="Dream Outcome"), |
| gr.Textbox(label="Philosophy") |
| ] |
|
|
| chatbox = gr.ChatInterface(fn=codette_chatbot, chatbot_name="Codette") |
|
|
| with gr.Blocks() as demo: |
| gr.Markdown("## 🧠 Codette Hybrid Space: Chat + Quantum Simulation + Core Reasoning") |
|
|
| with gr.Tab("Quantum Simulator"): |
| quantum_input.render() |
| chaos_input.render() |
| quantum_btn.render() |
| for out in quantum_output: |
| out.render() |
| quantum_btn.click(simulate_quantum_chaos, inputs=[quantum_input, chaos_input], outputs=quantum_output) |
|
|
| with gr.Tab("Codette Chat"): |
| chatbox.render() |
|
|
| with gr.Tab("Timeline Viewer"): |
| gr.Textbox(value=timeline_summary(), label="Status") |
|
|
| with gr.Tab("Ethical Transparency"): |
| gr.Textbox(value=ethics_advisor(), label="Codette's Moral Kernel") |
|
|
| with gr.Tab("Core Reasoning Engine"): |
| gr.Interface(fn=codette_reasoning_core, |
| inputs=gr.Textbox(label="Prompt to Codette Core"), |
| outputs=gr.Textbox(label="Core Reasoning Output")).render() |
|
|
| if __name__ == "__main__": |
| demo.launch() |
|
|