RFTSystems commited on
Commit
4f7778d
·
verified ·
1 Parent(s): 1e83d3c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -10
app.py CHANGED
@@ -1,6 +1,6 @@
1
  # app.py
2
  # Author: Liam Grinstead
3
- # Purpose: Run agent simulations, mutations, and falsifiability checks with automatic logging
4
 
5
  from modules.agent_spawner import spawn_agent
6
  from modules.mutation_engine import mutate_agent
@@ -9,6 +9,9 @@ from modules.falsifiability_bench import run_falsifiability
9
  from modules.codex_logger import log_artifact
10
  from modules.codex_viewer import load_codex
11
 
 
 
 
12
  def run_simulation(agent_id, mutation_profile):
13
  """
14
  Run a full simulation cycle:
@@ -18,24 +21,47 @@ def run_simulation(agent_id, mutation_profile):
18
  4. Run falsifiability bench
19
  5. Log artifact with SHA-512 seal
20
  """
21
- # Step 1: Spawn agent
22
  agent = spawn_agent(agent_id)
23
-
24
- # Step 2: Mutate agent
25
  mutated = mutate_agent(agent, mutation_profile)
26
 
27
- # Step 3: Optional visualization
28
  try:
29
  render_fields(mutated)
30
  except Exception:
31
- # Visualization is non-critical, continue if it fails
32
  pass
33
 
34
- # Step 4: Falsifiability scoring
35
  score, hash_val = run_falsifiability(mutated)
36
-
37
- # Step 5: Log artifact (saved to JSON with timestamp + SHA-512 seal)
38
  log_artifact(mutated, score, hash_val)
39
 
40
- # Return mutated agent and hash for downstream use
41
  return mutated, hash_val
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # app.py
2
  # Author: Liam Grinstead
3
+ # Purpose: Run agent simulations, mutations, falsifiability checks, and validation stages with automatic logging
4
 
5
  from modules.agent_spawner import spawn_agent
6
  from modules.mutation_engine import mutate_agent
 
9
  from modules.codex_logger import log_artifact
10
  from modules.codex_viewer import load_codex
11
 
12
+ import gradio as gr
13
+ import stage1 # later add stage2, stage3, etc.
14
+
15
  def run_simulation(agent_id, mutation_profile):
16
  """
17
  Run a full simulation cycle:
 
21
  4. Run falsifiability bench
22
  5. Log artifact with SHA-512 seal
23
  """
 
24
  agent = spawn_agent(agent_id)
 
 
25
  mutated = mutate_agent(agent, mutation_profile)
26
 
 
27
  try:
28
  render_fields(mutated)
29
  except Exception:
 
30
  pass
31
 
 
32
  score, hash_val = run_falsifiability(mutated)
 
 
33
  log_artifact(mutated, score, hash_val)
34
 
 
35
  return mutated, hash_val
36
+
37
+ # ---------------- Validation Stage Wrapper ----------------
38
+ def run_stage(stage_name, mode, steps_or_epochs, batch, lr):
39
+ if stage_name == "Stage 1 — CIFAR-10 Baseline":
40
+ stage1.train(
41
+ mode=mode,
42
+ epochs=int(steps_or_epochs),
43
+ batch=int(batch),
44
+ lr=float(lr),
45
+ log_path="stage1_cifar10_log.jsonl"
46
+ )
47
+ return f"Stage 1 complete.\nMode: {mode}\nEpochs: {steps_or_epochs}\nBatch: {batch}\nLR: {lr}\nTelemetry saved to stage1_cifar10_log.jsonl"
48
+ else:
49
+ return "Stage not yet implemented."
50
+
51
+ # ---------------- Gradio Interface ----------------
52
+ iface = gr.Interface(
53
+ fn=run_stage,
54
+ inputs=[
55
+ gr.Dropdown(["Stage 1 — CIFAR-10 Baseline"], label="Select Stage"),
56
+ gr.Dropdown(["RFT", "BASE"], label="Mode"),
57
+ gr.Number(label="Epochs", value=5),
58
+ gr.Number(label="Batch Size", value=256),
59
+ gr.Number(label="Learning Rate", value=5e-4),
60
+ ],
61
+ outputs="text",
62
+ title="RFTSystems — Symbolic Mutations & Validation",
63
+ description="Run agent simulations or validation stages of Rendered Frame Theory (RFT)."
64
+ )
65
+
66
+ if __name__ == "__main__":
67
+ iface.launch()