LordXido commited on
Commit
8f5e96d
·
verified ·
1 Parent(s): 96ebea1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -19
app.py CHANGED
@@ -1,29 +1,44 @@
1
  import gradio as gr
2
- from compiler import compile_codexbyte
3
- from codexbyte_vm import CodexByteVM
4
 
5
- vm = CodexByteVM()
 
6
 
7
- def run_codexbyte(source: str):
 
 
 
 
 
 
8
  try:
9
- program = compile_codexbyte(source.strip().splitlines())
10
- ledger = vm.run(program)
11
  return {
12
- "registers": vm.reg,
13
- "memory": vm.mem,
14
- "omega_ledger": ledger
 
 
15
  }
16
  except Exception as e:
17
- return {"error": str(e)}
18
 
19
- gr.Interface(
20
- fn=run_codexbyte,
21
  inputs=gr.Textbox(
22
- lines=16,
23
- label="CodexByte Program",
24
- placeholder="LOAD_IMM 0 1000\nLOAD_MEM 1 0x20\nCMP 1 0\nJZ 10\nHALT"
25
  ),
26
- outputs=gr.JSON(label="Ω-State Proof"),
27
- title="CodexByte ΩΞ Runtime",
28
- description="Bytecode execution is enforcement. Execution trace is proof."
29
- ).launch()
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from codexflow_core import CodexFlowEngine
 
3
 
4
+ # Instantiate the core engine once
5
+ engine = CodexFlowEngine()
6
 
7
+ def run_codexflow(contract_json: str):
8
+ """
9
+ Main UI handler for CodexFlow_TM:
10
+ - Accepts a JSON contract or cashflow spec
11
+ - Executes distortion/confidence logic + enforced reconciliation
12
+ - Returns structured system output
13
+ """
14
  try:
15
+ result = engine.process(contract_json)
 
16
  return {
17
+ "status": "OK",
18
+ "distortion_index": result["distortion"],
19
+ "confidence_score": result["confidence"],
20
+ "harmonized_state": result["harmonized"],
21
+ "messages": result.get("messages", [])
22
  }
23
  except Exception as e:
24
+ return {"status": "ERROR", "message": str(e)}
25
 
26
+ demo = gr.Interface(
27
+ fn=run_codexflow,
28
  inputs=gr.Textbox(
29
+ label="CodexFlow Contract / Specification (JSON)",
30
+ placeholder='{"type":"cashflow","terms":{...}}',
31
+ lines=10
32
  ),
33
+ outputs=gr.JSON(label="CodexFlow System Output"),
34
+ title="CodexFlow™ Global Cashflow Orchestrator",
35
+ description=(
36
+ "Paste your CodexFlow contract or cashflow declaration. "
37
+ "The system evaluates distortion, confidence, "
38
+ "and produces harmonized state signals."
39
+ ),
40
+ theme="default"
41
+ )
42
+
43
+ if __name__ == "__main__":
44
+ demo.launch()