File size: 2,395 Bytes
848bdee
9188a39
 
24fcefa
 
9188a39
848bdee
24fcefa
848bdee
9188a39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24fcefa
 
 
 
 
 
 
 
 
 
 
 
 
9188a39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
61
62
63
64
65
66
67
68
69
70
71
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

openai.api_key = os.getenv("OPENAI_API_KEY")

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)}]"


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")
    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()

if __name__ == "__main__":
    demo.launch()