Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,34 +8,69 @@ engine = DefragDeepCompute()
|
|
| 8 |
|
| 9 |
# --- THE LOGIC ---
|
| 10 |
def process_defrag(name, dob, time, city, user_input):
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
"""
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
visual_args = [
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 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():
|
|
@@ -44,13 +79,22 @@ with gr.Blocks(theme=gr.themes.Monochrome(), title="DEFRAG // OMNI-NODE") as dem
|
|
| 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) {
|
|
@@ -59,15 +103,23 @@ with gr.Blocks(theme=gr.themes.Monochrome(), title="DEFRAG // OMNI-NODE") as dem
|
|
| 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__":
|
|
|
|
| 8 |
|
| 9 |
# --- THE LOGIC ---
|
| 10 |
def process_defrag(name, dob, time, city, user_input):
|
| 11 |
+
# 1. Package Birth Data correctly for the new Engine API
|
| 12 |
+
birth_data = {
|
| 13 |
+
"name": name,
|
| 14 |
+
"dob": dob, # Format: YYYY-MM-DD
|
| 15 |
+
"year": int(dob.split('-')[0]),
|
| 16 |
+
"month": int(dob.split('-')[1]),
|
| 17 |
+
"day": int(dob.split('-')[2]),
|
| 18 |
+
"hour": int(time.split(':')[0]),
|
| 19 |
+
"minute": int(time.split(':')[1]),
|
| 20 |
+
"city": city,
|
| 21 |
+
"nation": "US" # Defaulting for prototype
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
# 2. Run the Deep Compute Engine
|
| 25 |
+
# FIXED: Calling the correct method 'execute_defrag' with dictionary
|
| 26 |
+
soul_log = engine.execute_defrag(birth_data, user_input)
|
| 27 |
+
|
| 28 |
+
# 3. Extract Data for Visuals
|
| 29 |
+
numerology = soul_log.get('numerology', {})
|
| 30 |
+
astrology = soul_log.get('astrology', {})
|
| 31 |
+
iching = soul_log.get('iching', {})
|
| 32 |
+
stability = soul_log.get('stability_score', 75)
|
| 33 |
+
|
| 34 |
+
# 4. Generate "System Admin" Response
|
| 35 |
+
life_path = numerology.get('life_path', 0)
|
| 36 |
+
personal_day = numerology.get('personal_day', 0)
|
| 37 |
+
sun_sign = astrology.get('sun_sign', 'Unknown')
|
| 38 |
+
hexagram_lines = iching.get('hexagram_lines', [])
|
| 39 |
+
|
| 40 |
+
system_status = f"SYSTEM STATUS: Stability {stability}%"
|
| 41 |
+
|
| 42 |
+
mechanics_text = f""" > LOG_ID: {soul_log.get('timestamp', 'N/A')}
|
| 43 |
+
> ASTRO_WEATHER: {sun_sign} Sun
|
| 44 |
+
> NUMEROLOGY: Life Path {life_path}, Personal Day {personal_day}
|
| 45 |
+
> HEXAGRAM: {len(hexagram_lines)} lines cast
|
| 46 |
+
|
| 47 |
+
ANALYSIS:
|
| 48 |
+
User is operating at {stability}% system stability.
|
| 49 |
+
Mechanical patterns detected in {user_input or 'normal'} mode.
|
| 50 |
"""
|
| 51 |
+
|
| 52 |
+
vector_text = f"VECTOR: Maintain {sun_sign} balance. Life Path {life_path} optimization active."
|
| 53 |
+
|
| 54 |
+
# 5. Return: Visual Data (for JS), Status, Mechanics, Vector
|
| 55 |
+
# We pass the JS update arguments as a list
|
| 56 |
visual_args = [
|
| 57 |
+
hexagram_lines[:6] if hexagram_lines else ["Yang", "Yin", "Yang", "Yin", "Yang", "Yin"], # Hexagram Array
|
| 58 |
+
personal_day or 1, # Petal Count
|
| 59 |
+
sun_sign or "Fire", # Element Color
|
| 60 |
+
stability / 100.0 # Stability (0-1)
|
| 61 |
]
|
| 62 |
+
|
| 63 |
return visual_args, system_status, mechanics_text, vector_text
|
| 64 |
|
| 65 |
# --- THE INTERFACE ---
|
| 66 |
with gr.Blocks(theme=gr.themes.Monochrome(), title="DEFRAG // OMNI-NODE") as demo:
|
| 67 |
+
|
| 68 |
+
# HEADER
|
| 69 |
gr.Markdown("# DEFRAG // OMNI-NODE")
|
| 70 |
gr.Markdown("> DETERMINISTIC CONSCIOUSNESS ENGINE v1.0")
|
| 71 |
+
|
| 72 |
with gr.Row():
|
| 73 |
+
# LEFT COLUMN: INPUTS
|
| 74 |
with gr.Column(scale=1):
|
| 75 |
gr.Markdown("### // SYSTEM PROFILE")
|
| 76 |
with gr.Row():
|
|
|
|
| 79 |
with gr.Row():
|
| 80 |
time_in = gr.Textbox(label="Time (HH:MM)", value="12:00")
|
| 81 |
city_in = gr.Textbox(label="Location", value="Los Angeles")
|
| 82 |
+
|
| 83 |
gr.Markdown("### // DIAGNOSTIC INPUT")
|
| 84 |
input_text = gr.Textbox(label="Input System Status", placeholder="Describe the interference...", lines=4)
|
| 85 |
+
|
| 86 |
btn_scan = gr.Button("EXECUTE DEFRAG", variant="primary")
|
| 87 |
+
|
| 88 |
+
# RIGHT COLUMN: VISUALS & OUTPUT
|
| 89 |
with gr.Column(scale=1):
|
| 90 |
+
# HTML COMPONENT FOR MANDALA
|
| 91 |
+
# We load the file content directly
|
| 92 |
with open("mandala_component.html", "r") as f:
|
| 93 |
html_code = f.read()
|
| 94 |
+
|
| 95 |
mandala_display = gr.HTML(value=html_code)
|
| 96 |
+
|
| 97 |
+
# JS Bridge to update the canvas
|
| 98 |
js_bridge = """
|
| 99 |
(args) => {
|
| 100 |
if (window.hexa) {
|
|
|
|
| 103 |
return args;
|
| 104 |
}
|
| 105 |
"""
|
| 106 |
+
|
| 107 |
+
# OUTPUT MONITORS
|
| 108 |
status_out = gr.Textbox(label="SYSTEM STATUS", interactive=False)
|
| 109 |
mech_out = gr.TextArea(label="MECHANICS LOG", interactive=False)
|
| 110 |
vector_out = gr.Textbox(label="VECTOR DIRECTIVE", interactive=False)
|
| 111 |
+
|
| 112 |
+
# Hidden component to pass data to JS
|
| 113 |
visual_data = gr.JSON(visible=False)
|
| 114 |
+
|
| 115 |
+
# WIRING
|
| 116 |
btn_scan.click(
|
| 117 |
fn=process_defrag,
|
| 118 |
inputs=[name_in, dob_in, time_in, city_in, input_text],
|
| 119 |
outputs=[visual_data, status_out, mech_out, vector_out]
|
| 120 |
)
|
| 121 |
+
|
| 122 |
+
# Trigger JS update when visual_data changes
|
| 123 |
visual_data.change(None, [visual_data], None, js=js_bridge)
|
| 124 |
|
| 125 |
if __name__ == "__main__":
|