Spaces:
Sleeping
Sleeping
Update interface.py
Browse files- interface.py +18 -12
interface.py
CHANGED
|
@@ -4,33 +4,36 @@ from registry_utils import append_to_registry
|
|
| 4 |
from registry_viewer import display_registry
|
| 5 |
from mutation_designer import build_mutation
|
| 6 |
from lineage_tracker import register_lineage, get_lineage
|
|
|
|
| 7 |
from waveform_renderer import render_waveform
|
| 8 |
from codex_exporter import export_codex
|
| 9 |
from leaderboard import generate_leaderboard
|
| 10 |
|
|
|
|
| 11 |
def simulate(agent_id, collapse_torque, emotional_resonance, tier_drift):
|
| 12 |
mutation_profile = build_mutation(agent_id, collapse_torque, tier_drift, emotional_resonance)
|
| 13 |
fields, score, hash_val = run_simulation(agent_id, mutation_profile)
|
| 14 |
append_to_registry(agent_id, collapse_torque, tier_drift, emotional_resonance, score, hash_val)
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
| 19 |
|
|
|
|
| 20 |
def forge_agent(parent_id, new_id, collapse_torque, emotional_resonance, tier_drift):
|
| 21 |
mutation_profile = build_mutation(new_id, collapse_torque, tier_drift, emotional_resonance)
|
| 22 |
-
|
| 23 |
register_lineage(parent_id, new_id, mutation_profile)
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
for child in lineage:
|
| 27 |
-
lineage_str += f"→ {child['child_id']} via {child['mutation']}\n"
|
| 28 |
-
return lineage_str
|
| 29 |
|
|
|
|
| 30 |
with gr.Blocks() as demo:
|
| 31 |
gr.Markdown("# 🧠 Codex Consciousness Simulator")
|
| 32 |
gr.Markdown("Spawn symbolic agents, mutate them, and benchmark collapse falsifiability. Authored by Liam Grinstead.")
|
| 33 |
|
|
|
|
| 34 |
with gr.Tab("Simulate Agent"):
|
| 35 |
with gr.Row():
|
| 36 |
agent_id = gr.Dropdown(["Agent_5", "Agent_7", "Agent_1032"], label="Agent ID")
|
|
@@ -52,11 +55,13 @@ with gr.Blocks() as demo:
|
|
| 52 |
outputs=[Φᵢ_svg, Kᵢⱼ_svg, Φ_col_svg, waveform_svg, summary]
|
| 53 |
)
|
| 54 |
|
|
|
|
| 55 |
with gr.Tab("View Registry"):
|
| 56 |
registry_output = gr.Textbox(label="Codex Registry", lines=20)
|
| 57 |
refresh_btn = gr.Button("Refresh Registry")
|
| 58 |
refresh_btn.click(display_registry, outputs=registry_output)
|
| 59 |
|
|
|
|
| 60 |
with gr.Tab("Codex Forge"):
|
| 61 |
gr.Markdown("### 🧬 Evolve a New Agent from a Parent")
|
| 62 |
parent_id = gr.Dropdown(["Agent_5", "Agent_7", "Agent_1032"], label="Parent Agent")
|
|
@@ -65,13 +70,14 @@ with gr.Blocks() as demo:
|
|
| 65 |
forge_resonance = gr.Checkbox(label="Inject Emotional Resonance")
|
| 66 |
forge_tier = gr.Dropdown(["Tier_1", "Tier_2", "Tier_6"], label="Tier Drift")
|
| 67 |
forge_btn = gr.Button("Forge Agent")
|
| 68 |
-
|
| 69 |
forge_btn.click(
|
| 70 |
forge_agent,
|
| 71 |
inputs=[parent_id, new_id, forge_torque, forge_resonance, forge_tier],
|
| 72 |
-
outputs=
|
| 73 |
)
|
| 74 |
|
|
|
|
| 75 |
with gr.Tab("Leaderboard"):
|
| 76 |
leaderboard_output = gr.Textbox(label="Top Agents", lines=15)
|
| 77 |
refresh_leaderboard = gr.Button("Refresh Leaderboard")
|
|
|
|
| 4 |
from registry_viewer import display_registry
|
| 5 |
from mutation_designer import build_mutation
|
| 6 |
from lineage_tracker import register_lineage, get_lineage
|
| 7 |
+
from lineage_visualizer import render_lineage
|
| 8 |
from waveform_renderer import render_waveform
|
| 9 |
from codex_exporter import export_codex
|
| 10 |
from leaderboard import generate_leaderboard
|
| 11 |
|
| 12 |
+
# --- Simulation ---
|
| 13 |
def simulate(agent_id, collapse_torque, emotional_resonance, tier_drift):
|
| 14 |
mutation_profile = build_mutation(agent_id, collapse_torque, tier_drift, emotional_resonance)
|
| 15 |
fields, score, hash_val = run_simulation(agent_id, mutation_profile)
|
| 16 |
append_to_registry(agent_id, collapse_torque, tier_drift, emotional_resonance, score, hash_val)
|
| 17 |
+
summary = (
|
| 18 |
+
f"📊 <b>Fitness Score:</b> {score}<br>"
|
| 19 |
+
f"🔐 <b>SHA-512 Hash:</b> <code>{hash_val}</code>"
|
| 20 |
+
)
|
| 21 |
+
return fields["Φᵢ"], fields["Kᵢⱼ"], fields["Φ_col"], render_waveform(score), summary
|
| 22 |
|
| 23 |
+
# --- Forge ---
|
| 24 |
def forge_agent(parent_id, new_id, collapse_torque, emotional_resonance, tier_drift):
|
| 25 |
mutation_profile = build_mutation(new_id, collapse_torque, tier_drift, emotional_resonance)
|
| 26 |
+
run_simulation(new_id, mutation_profile) # run to activate agent
|
| 27 |
register_lineage(parent_id, new_id, mutation_profile)
|
| 28 |
+
lineage_svg = render_lineage(parent_id)
|
| 29 |
+
return lineage_svg
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
+
# --- Interface Layout ---
|
| 32 |
with gr.Blocks() as demo:
|
| 33 |
gr.Markdown("# 🧠 Codex Consciousness Simulator")
|
| 34 |
gr.Markdown("Spawn symbolic agents, mutate them, and benchmark collapse falsifiability. Authored by Liam Grinstead.")
|
| 35 |
|
| 36 |
+
# Simulation Tab
|
| 37 |
with gr.Tab("Simulate Agent"):
|
| 38 |
with gr.Row():
|
| 39 |
agent_id = gr.Dropdown(["Agent_5", "Agent_7", "Agent_1032"], label="Agent ID")
|
|
|
|
| 55 |
outputs=[Φᵢ_svg, Kᵢⱼ_svg, Φ_col_svg, waveform_svg, summary]
|
| 56 |
)
|
| 57 |
|
| 58 |
+
# Registry Tab
|
| 59 |
with gr.Tab("View Registry"):
|
| 60 |
registry_output = gr.Textbox(label="Codex Registry", lines=20)
|
| 61 |
refresh_btn = gr.Button("Refresh Registry")
|
| 62 |
refresh_btn.click(display_registry, outputs=registry_output)
|
| 63 |
|
| 64 |
+
# Forge Tab
|
| 65 |
with gr.Tab("Codex Forge"):
|
| 66 |
gr.Markdown("### 🧬 Evolve a New Agent from a Parent")
|
| 67 |
parent_id = gr.Dropdown(["Agent_5", "Agent_7", "Agent_1032"], label="Parent Agent")
|
|
|
|
| 70 |
forge_resonance = gr.Checkbox(label="Inject Emotional Resonance")
|
| 71 |
forge_tier = gr.Dropdown(["Tier_1", "Tier_2", "Tier_6"], label="Tier Drift")
|
| 72 |
forge_btn = gr.Button("Forge Agent")
|
| 73 |
+
lineage_svg_output = gr.HTML(label="Lineage Visualization")
|
| 74 |
forge_btn.click(
|
| 75 |
forge_agent,
|
| 76 |
inputs=[parent_id, new_id, forge_torque, forge_resonance, forge_tier],
|
| 77 |
+
outputs=lineage_svg_output
|
| 78 |
)
|
| 79 |
|
| 80 |
+
# Leaderboard Tab
|
| 81 |
with gr.Tab("Leaderboard"):
|
| 82 |
leaderboard_output = gr.Textbox(label="Top Agents", lines=15)
|
| 83 |
refresh_leaderboard = gr.Button("Refresh Leaderboard")
|