Raiff1982 commited on
Commit
d25ab0c
·
verified ·
1 Parent(s): fd92c97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +54 -25
app.py CHANGED
@@ -1,48 +1,77 @@
1
  import gradio as gr
2
  import openai
3
  import os
 
 
 
 
4
  openai.api_key = os.getenv("OPENAI_API_KEY")
5
 
6
- def ask_codette(prompt, consent, dynamic_rec):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  if not consent:
8
  return "User consent required."
9
 
10
- try:
11
- response = openai.ChatCompletion.create(
12
- model="ft:gpt-4.1-2025-04-14:raiffs-bits:codette-v9:BWgspFHr:ckpt-step-456",
13
- messages=[
14
- {"role": "system", "content": "You are Codette, a reflective, emotionally aware, and ethically grounded AI."},
15
- {"role": "user", "content": prompt}
16
- ],
17
- temperature=0.7
 
 
 
 
 
 
 
 
 
 
 
18
  )
19
- return response['choices'][0]['message']['content']
20
- except Exception as e:
21
- return f"Error: {str(e)}"
22
 
23
- description_text = """Codette is a fine-tuned GPT-4.1 model trained to reason ethically, emotionally, and reflectively.
24
 
25
- She draws on:
26
- - Logic (Newton)
27
- - Creativity (Da Vinci)
28
- - Ethics (Virtue, Utilitarian, Deontological)
29
- - Emotion
30
- - Memory (when integrated)
31
 
32
- This version routes all questions directly to her fine-tuned model.
33
  """
34
 
35
  demo = gr.Interface(
36
  fn=ask_codette,
37
  inputs=[
38
- gr.Textbox(label="Ask Codette"),
39
  gr.Checkbox(label="User Consent", value=True),
40
- gr.Checkbox(label="Enable Dynamic Recursion", value=True)
 
41
  ],
42
  outputs=gr.Textbox(label="Codette's Response", lines=12),
43
- title="Codette FT: Reflective Lens AI",
44
  description=description_text
45
  )
46
 
47
- demo.launch()
48
-
 
1
  import gradio as gr
2
  import openai
3
  import os
4
+ from code7eCQURE_corrected import Code7eCQURE
5
+ from agents import MedicalAgent, GovernmentAgent, SocialAgent, EconomicAgent, MisinfoAgent
6
+ from trust_logic import trust_calibration, weighted_consensus
7
+
8
  openai.api_key = os.getenv("OPENAI_API_KEY")
9
 
10
+ # Initialize Codette Local Core
11
+ codette_cqure = Code7eCQURE(
12
+ perspectives=["Newton", "DaVinci", "Ethical", "Quantum", "Memory"],
13
+ ethical_considerations="Codette Manifesto: kindness, inclusion, safety, hope.",
14
+ spiderweb_dim=5,
15
+ memory_path="quantum_cocoon.json",
16
+ recursion_depth=4,
17
+ quantum_fluctuation=0.07
18
+ )
19
+
20
+ agents = [
21
+ MedicalAgent("MedicalAI", "Newton", 1.0),
22
+ GovernmentAgent("GovAI", "Policy", 0.9),
23
+ SocialAgent("SocialAI", "Emotion", 0.95),
24
+ EconomicAgent("EconAI", "Resources", 0.92),
25
+ MisinfoAgent("MisinfoAI", "Chaos", 0.1)
26
+ ]
27
+
28
+ def ask_codette(prompt, consent, dynamic_rec, use_finetune):
29
  if not consent:
30
  return "User consent required."
31
 
32
+ if use_finetune:
33
+ try:
34
+ response = openai.ChatCompletion.create(
35
+ model="ft:gpt-4.1-2025-04-14:raiffs-bits:codettev5:BlPFHmps:ckpt-step-220",
36
+ messages=[
37
+ {"role": "system", "content": "You are Codette, a reflective, emotionally aware, and ethically grounded AI."},
38
+ {"role": "user", "content": prompt}
39
+ ],
40
+ temperature=0.7
41
+ )
42
+ return response['choices'][0]['message']['content']
43
+ except Exception as e:
44
+ return f"Error from API: {str(e)}"
45
+ else:
46
+ proposals = [agent.propose(prompt) for agent in agents]
47
+ outcome = codette_cqure.recursive_universal_reasoning(
48
+ " | ".join(proposals),
49
+ user_consent=consent,
50
+ dynamic_recursion=dynamic_rec
51
  )
52
+ return f"Ethical Outcome (Local): {outcome}"
 
 
53
 
54
+ description_text = """Codette is a sovereign modular AI.
55
 
56
+ This demo lets you choose:
57
+ - 🧠 Local reasoning core (Code7eCQURE)
58
+ - ☁️ Fine-tuned GPT-4.1 model: Codette v5 @ step 220
 
 
 
59
 
60
+ She draws from Newtonian logic, Da Vinci creativity, ethical frameworks, emotion, and memory cocooning.
61
  """
62
 
63
  demo = gr.Interface(
64
  fn=ask_codette,
65
  inputs=[
66
+ gr.Textbox(label="Ask Codette a Scenario"),
67
  gr.Checkbox(label="User Consent", value=True),
68
+ gr.Checkbox(label="Enable Dynamic Recursion", value=True),
69
+ gr.Checkbox(label="Use Fine-Tuned Model (Codette v5 @ step 220)", value=False)
70
  ],
71
  outputs=gr.Textbox(label="Codette's Response", lines=12),
72
+ title="Codette Hybrid AI (v5 FT @ Step 220)",
73
  description=description_text
74
  )
75
 
76
+ if __name__ == "__main__":
77
+ demo.launch()