Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,29 +1,44 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
| 3 |
-
from codexbyte_vm import CodexByteVM
|
| 4 |
|
| 5 |
-
|
|
|
|
| 6 |
|
| 7 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
try:
|
| 9 |
-
|
| 10 |
-
ledger = vm.run(program)
|
| 11 |
return {
|
| 12 |
-
"
|
| 13 |
-
"
|
| 14 |
-
"
|
|
|
|
|
|
|
| 15 |
}
|
| 16 |
except Exception as e:
|
| 17 |
-
return {"
|
| 18 |
|
| 19 |
-
gr.Interface(
|
| 20 |
-
fn=
|
| 21 |
inputs=gr.Textbox(
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
),
|
| 26 |
-
outputs=gr.JSON(label="
|
| 27 |
-
title="
|
| 28 |
-
description=
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|