ZOTHEOS commited on
Commit
63a104d
·
verified ·
1 Parent(s): a2f5d42

Update main_web.py

Browse files
Files changed (1) hide show
  1. main_web.py +34 -59
main_web.py CHANGED
@@ -1,4 +1,4 @@
1
- # FILE: main_web.py (Hugging Face Demo - FINAL v1.0 - Obsidian Pro)
2
 
3
  import gradio as gr
4
  import asyncio
@@ -26,94 +26,69 @@ except Exception as e:
26
  logger.error(f"CRITICAL: Failed to initialize AI system: {e}")
27
  ai_system = None
28
 
29
- # --- DEFINITIVE "OBSIDIAN PRO" CSS ---
30
- zotheos_pro_css = """
31
  @import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Inter:wght@400;600;700&display=swap');
32
- body { background: #0a0a0a !important; font-family: 'Inter', sans-serif !important; }
33
- .gradio-container { max-width: 960px !important; margin: 0 auto !important; padding-top: 2rem !important; }
34
  #main_layout { display:flex; flex-direction:column; align-items:center; gap: 1.5rem; }
35
  #header_logo img { max-height: 70px !important; filter: brightness(0) invert(1) !important; }
36
- #header_subtitle { font-family: 'Bebas Neue', cursive !important; font-size: 2rem !important; letter-spacing: 2px !important; text-align: center; }
37
- #header_tagline { color: #a0a0a0 !important; text-align: center; margin-top: -1rem !important; }
38
- .gradio-accordion { background-color: #1a1a1a !important; border: 1px solid #333 !important; }
 
39
  .cta-button { background: #FFFFFF !important; color: #000000 !important; font-weight: bold !important; }
40
- .gradio-textbox textarea { font-size: 1.1rem !important; }
41
- #results_box { background-color: rgba(18, 18, 18, 0.9) !important; border: 1px solid #333 !important; backdrop-filter: blur(5px); }
42
- #results_box h2 { font-family: 'Bebas Neue', cursive !important; font-size: 1.5rem !important; border-bottom: 1px solid #333; padding-bottom: 0.75rem; margin-bottom: 1rem; }
43
  footer { display: none !important; }
44
  """
45
 
46
  # --- Build Gradio Interface ---
47
  def build_interface():
48
- theme = gr.themes.Base(primary_hue=gr.themes.colors.neutral, secondary_hue=gr.themes.colors.neutral).set(
49
- button_primary_background_fill="white", button_primary_text_color="black", block_radius="12px"
50
  )
51
 
52
- with gr.Blocks(theme=theme, css=zotheos_pro_css, title=APP_TITLE) as demo:
53
  with gr.Column(elem_id="main_layout"):
54
- gr.Image(value=logo_path_verified, elem_id="header_logo", show_label=False, container=False)
55
- gr.Markdown("<h1 id='header_subtitle'>Ethical Fusion AI for Synthesized Intelligence</h1>", elem_id="header-title-wrapper")
56
  gr.Markdown("<p id='header_tagline'>Fusing perspectives for deeper truth.</p>", elem_id="tagline-wrapper")
57
 
58
  with gr.Accordion("🔥 Get the Full Offline Desktop Version", open=True):
59
- gr.Markdown("This web demo uses smaller, slower models. For the full-power, GPU-accelerated, 100% private experience, download the ZOTHEOS Public Beta for your Windows PC.")
60
  gr.Button("Download Full Version on Gumroad", link=GUMROAD_LINK, elem_classes="cta-button")
61
 
62
- query_input = gr.Textbox(label="Your Inquiry:", placeholder="e.g., What is universal peace?", lines=5)
63
-
64
- with gr.Row():
65
- clear_button = gr.Button("Clear")
66
- submit_button = gr.Button("Process Inquiry (Web Demo)", variant="primary")
67
 
68
- # --- REAL-TIME PROGRESS BAR ---
69
- progress_bar = gr.Progress(track_tqdm=True, visible=False)
70
 
71
- with gr.Column(elem_id="results_box", visible=False) as results_box:
72
- synthesized_summary_output = gr.Markdown()
73
- fusion_output = gr.Markdown()
74
-
75
- # --- Backend Logic ---
76
- async def process_query(query, progress=gr.Progress(track_tqdm=True)):
77
- if not ai_system:
78
- return {"results_box": gr.update(visible=True), "synthesized_summary_output": "## SYSTEM OFFLINE\n\n[The AI engine failed to load.]", "fusion_output": ""}
79
 
80
- progress(0, desc="Initiating Fusion...")
81
- await asyncio.sleep(0.5)
82
-
83
- # This is a simplified progress simulation for the web demo
84
- for i in progress.tqdm(range(10), desc="Querying AI Cores..."):
85
- await asyncio.sleep(0.2)
86
 
87
- progress(0.5, desc="Generating Final Synthesis...")
 
88
 
89
  response = await ai_system.process_query_with_fusion(query)
90
- summary = response.split("###")[0].replace("## ✨ ZOTHEOS Final Synthesized Insight ✨", "").strip()
91
  perspectives = "###" + response.split("###", 1)[1] if "###" in response else ""
92
 
93
- for i in progress.tqdm(range(5), desc="Formatting Response..."):
94
- await asyncio.sleep(0.1)
95
-
96
- return {
97
- results_box: gr.update(visible=True),
98
- synthesized_summary_output: "## ✨ ZOTHEOS Final Synthesized Insight ✨\n\n" + summary,
99
- fusion_output: perspectives
100
- }
101
 
102
  submit_button.click(
103
- fn=process_query,
104
- inputs=query_input,
105
- outputs=[results_box, synthesized_summary_output, fusion_output],
106
- show_progress="hidden" # We use our custom progress bar
107
- ).then(lambda: gr.update(visible=True), outputs=progress_bar).then(
108
- process_query, inputs=query_input, outputs=[results_box, synthesized_summary_output, fusion_output]
109
- ).then(lambda: gr.update(visible=False), outputs=progress_bar)
110
-
111
- clear_button.click(lambda: ("", gr.update(visible=False), "", ""), outputs=[query_input, results_box, synthesized_summary_output, fusion_output])
112
-
113
  return demo
114
 
115
  # --- Main Execution Block ---
116
  if __name__ == "__main__":
117
- logger.info("--- Initializing ZOTHEOS Hugging Face Demo (v4.0 - Obsidian Pro) ---")
118
  zotheos_interface = build_interface()
119
  zotheos_interface.queue().launch()
 
1
+ # FILE: main_web.py (Hugging Face Demo - v1.0 - )
2
 
3
  import gradio as gr
4
  import asyncio
 
26
  logger.error(f"CRITICAL: Failed to initialize AI system: {e}")
27
  ai_system = None
28
 
29
+ # --- DEFINITIVE "OBSIDIAN PRO" CSS ---
30
+ zotheos_web_css = """
31
  @import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Inter:wght@400;600;700&display=swap');
32
+ body { background: linear-gradient(135deg, #000000, #1c1c1c) !important; font-family: 'Inter', sans-serif !important; color: #f0f0f0 !important; }
33
+ .gradio-container { max-width: 900px !important; margin: 0 auto !important; padding: 1.5rem !important; background: transparent !important; }
34
  #main_layout { display:flex; flex-direction:column; align-items:center; gap: 1.5rem; }
35
  #header_logo img { max-height: 70px !important; filter: brightness(0) invert(1) !important; }
36
+ #header_subtitle { font-family: 'Bebas Neue', cursive !important; font-size: 1.8rem !important; letter-spacing: 2px !important; }
37
+ #header_tagline { color: #a0a0a0 !important; text-align: center; margin-top: -10px !important; margin-bottom: 1.5rem !important; }
38
+ .result-box { background-color: rgba(18, 18, 18, 0.9) !important; border: 1px solid #333 !important; border-radius: 12px !important; padding: 1.5rem !important; }
39
+ .result-box h2 { font-family: 'Bebas Neue', cursive !important; font-size: 1.5rem !important; border-bottom: 1px solid #333; padding-bottom: 0.75rem; margin-bottom: 1rem; }
40
  .cta-button { background: #FFFFFF !important; color: #000000 !important; font-weight: bold !important; }
 
 
 
41
  footer { display: none !important; }
42
  """
43
 
44
  # --- Build Gradio Interface ---
45
  def build_interface():
46
+ theme = gr.themes.Base(primary_hue=gr.themes.colors.neutral).set(
47
+ button_primary_background_fill="white", button_primary_text_color="black"
48
  )
49
 
50
+ with gr.Blocks(theme=theme, css=zotheos_web_css, title=APP_TITLE) as demo:
51
  with gr.Column(elem_id="main_layout"):
52
+ gr.Image(value=logo_path_verified, elem_id="header_logo", show_label=False, container=False, interactive=False)
53
+ gr.Markdown("<h1 id='header_subtitle' style='text-align:center;'>Ethical Fusion AI</h1>", elem_id="header-title-wrapper")
54
  gr.Markdown("<p id='header_tagline'>Fusing perspectives for deeper truth.</p>", elem_id="tagline-wrapper")
55
 
56
  with gr.Accordion("🔥 Get the Full Offline Desktop Version", open=True):
57
+ gr.Markdown("This web demo uses smaller, slower models. For the full-power, GPU-accelerated, 100% private experience, download the ZOTHEOS Public Beta for Windows.")
58
  gr.Button("Download Full Version on Gumroad", link=GUMROAD_LINK, elem_classes="cta-button")
59
 
60
+ gr.Markdown("---")
 
 
 
 
61
 
62
+ query_input = gr.Textbox(label="Your Inquiry:", placeholder="e.g., What is universal peace?", lines=5)
63
+ submit_button = gr.Button("Process Inquiry (Web Demo)", variant="primary")
64
 
65
+ with gr.Column(elem_id="results_box", visible=True): # Always visible now
66
+ synthesized_summary_output = gr.Markdown("Synthesized insight will appear here...")
67
+ fusion_output = gr.Markdown("Detailed perspectives will appear here...")
 
 
 
 
 
68
 
69
+ # --- ✅ FAILSAFE EVENT HANDLER ---
70
+ async def process_query_wrapper(query):
71
+ # Show a simple "Processing..." message
72
+ yield "## Synthesizing...\n\nPlease wait, the AI cores are thinking.", ""
 
 
73
 
74
+ if not ai_system:
75
+ return "## SYSTEM OFFLINE\n\n[The AI engine failed to load.]", ""
76
 
77
  response = await ai_system.process_query_with_fusion(query)
78
+ summary = response.split("###")[0].strip()
79
  perspectives = "###" + response.split("###", 1)[1] if "###" in response else ""
80
 
81
+ yield summary, perspectives
 
 
 
 
 
 
 
82
 
83
  submit_button.click(
84
+ fn=process_query_wrapper,
85
+ inputs=[query_input],
86
+ outputs=[synthesized_summary_output, fusion_output]
87
+ )
 
 
 
 
 
 
88
  return demo
89
 
90
  # --- Main Execution Block ---
91
  if __name__ == "__main__":
92
+ logger.info("--- Initializing ZOTHEOS Hugging Face Demo (v4.1 - Failsafe) ---")
93
  zotheos_interface = build_interface()
94
  zotheos_interface.queue().launch()