cjo93 commited on
Commit
a2accb0
·
verified ·
1 Parent(s): 4a4b01a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +67 -37
app.py CHANGED
@@ -1,44 +1,74 @@
 
 
1
  import os
2
- import httpx
3
- from fastapi import FastAPI, HTTPException
4
- from fastapi.responses import HTMLResponse
5
- from fastapi.staticfiles import StaticFiles
6
- from fastapi.middleware.cors import CORSMiddleware
7
- from dotenv import load_dotenv
8
 
9
- load_dotenv()
 
10
 
11
- app = FastAPI(title="DEFRAG.APP // CORE_SYSTEM")
 
 
 
 
 
 
 
 
 
 
12
 
13
- app.add_middleware(
14
- CORSMiddleware,
15
- allow_origins=["*"],
16
- allow_credentials=True,
17
- allow_methods=["*"],
18
- allow_headers=["*"],
19
- )
 
 
 
 
 
20
 
21
- if os.path.exists("assets"):
22
- app.mount("/assets", StaticFiles(directory="assets"), name="assets")
23
-
24
- @app.get("/api/get-signed-url")
25
- async def get_signed_url():
26
- ELEVENLABS_API_KEY = os.environ.get("ELEVENLABS_API_KEY")
27
- AGENT_ID = "agent_4101kfyny563e168da90yze4vva4"
28
-
29
- if not ELEVENLABS_API_KEY:
30
- raise HTTPException(status_code=500, detail="ELEVENLABS_API_KEY not found")
31
-
32
- async with httpx.AsyncClient() as client:
33
- url = f"https://api.elevenlabs.io/v1/convai/conversation/get_signed_url?agent_id={AGENT_ID}"
34
- response = await client.get(url, headers={"xi-api-key": ELEVENLABS_API_KEY})
35
- return response.json()
36
-
37
- @app.get("/", response_class=HTMLResponse)
38
- async def serve_dashboard():
39
- with open("index.html", "r") as f:
40
- return f.read()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
  if __name__ == "__main__":
43
- import uvicorn
44
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
1
+ import gradio as gr
2
+ import json
3
  import os
4
+ from defrag_engine import DefragDeepCompute
 
 
 
 
 
5
 
6
+ # Initialize Engine
7
+ engine = DefragDeepCompute()
8
 
9
+ # --- THE LOGIC ---
10
+ def process_defrag(name, dob, time, city, user_input):
11
+ soul_log = engine.run_deep_compute(name, dob, time, city, user_input)
12
+ vector = soul_log['computed_vector']
13
+ numerology_day = soul_log['weather']['hexagram']['gate']
14
+ system_status = "SYSTEM ALERT: " + vector['friction_level']
15
+ mechanics_text = f"""
16
+ > LOG_ID: {soul_log['timestamp']}
17
+ > ASTRO_WEATHER: {soul_log['weather']['astro']['dominant_element'].upper()} Dominance
18
+ > NUMEROLOGY: Personal Day {soul_log['hardware']['numerology']['personal_day']}
19
+ > HEXAGRAM: Gate {soul_log['weather']['hexagram']['gate']} Active
20
 
21
+ ANALYSIS:
22
+ User is attempting to process '{user_input}' while in a Personal Day {soul_log['hardware']['numerology']['personal_day']} cycle.
23
+ Mechanical friction detected in the {soul_log['weather']['astro']['dominant_element']} sector.
24
+ """
25
+ vector_text = f"VECTOR: Stabilize {soul_log['weather']['astro']['dominant_element']} elements. Do not initiate action until Gate {numerology_day} transit clears."
26
+ visual_args = [
27
+ vector['visual_code'],
28
+ vector['visual_seed'],
29
+ vector['visual_element'],
30
+ 0.3 if vector['friction_level'] == "CRITICAL" else 1.0
31
+ ]
32
+ return visual_args, system_status, mechanics_text, vector_text
33
 
34
+ # --- THE INTERFACE ---
35
+ with gr.Blocks(theme=gr.themes.Monochrome(), title="DEFRAG // OMNI-NODE") as demo:
36
+ gr.Markdown("# DEFRAG // OMNI-NODE")
37
+ gr.Markdown("> DETERMINISTIC CONSCIOUSNESS ENGINE v1.0")
38
+ with gr.Row():
39
+ with gr.Column(scale=1):
40
+ gr.Markdown("### // SYSTEM PROFILE")
41
+ with gr.Row():
42
+ name_in = gr.Textbox(label="User ID", value="User_01")
43
+ dob_in = gr.Textbox(label="DOB (YYYY-MM-DD)", value="1990-01-01")
44
+ with gr.Row():
45
+ time_in = gr.Textbox(label="Time (HH:MM)", value="12:00")
46
+ city_in = gr.Textbox(label="Location", value="Los Angeles")
47
+ gr.Markdown("### // DIAGNOSTIC INPUT")
48
+ input_text = gr.Textbox(label="Input System Status", placeholder="Describe the interference...", lines=4)
49
+ btn_scan = gr.Button("EXECUTE DEFRAG", variant="primary")
50
+ with gr.Column(scale=1):
51
+ with open("mandala_component.html", "r") as f:
52
+ html_code = f.read()
53
+ mandala_display = gr.HTML(value=html_code)
54
+ js_bridge = """
55
+ (args) => {
56
+ if (window.hexa) {
57
+ window.hexa.updateParams(args[0], args[1], args[2], args[3]);
58
+ }
59
+ return args;
60
+ }
61
+ """
62
+ status_out = gr.Textbox(label="SYSTEM STATUS", interactive=False)
63
+ mech_out = gr.TextArea(label="MECHANICS LOG", interactive=False)
64
+ vector_out = gr.Textbox(label="VECTOR DIRECTIVE", interactive=False)
65
+ visual_data = gr.JSON(visible=False)
66
+ btn_scan.click(
67
+ fn=process_defrag,
68
+ inputs=[name_in, dob_in, time_in, city_in, input_text],
69
+ outputs=[visual_data, status_out, mech_out, vector_out]
70
+ )
71
+ visual_data.change(None, [visual_data], None, js=js_bridge)
72
 
73
  if __name__ == "__main__":
74
+ demo.launch()