Spaces:
Running
Running
Update main_web.py
Browse files- main_web.py +70 -307
main_web.py
CHANGED
@@ -1,334 +1,97 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import asyncio
|
3 |
import logging
|
4 |
import os
|
5 |
import sys
|
6 |
-
import
|
7 |
-
import random
|
8 |
-
from typing import Optional, Dict, Any, List, Union, Tuple
|
9 |
-
import html
|
10 |
-
import json
|
11 |
-
import tempfile
|
12 |
|
13 |
-
# ---
|
14 |
APP_TITLE = "ZOTHEOS - Ethical Fusion AI"
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
# --- Logger (Your existing code is perfect) ---
|
19 |
-
def init_logger():
|
20 |
-
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", datefmt="%Y-%m-%d %H:%M:%S")
|
21 |
-
logger_instance = logging.getLogger("ZOTHEOS_Interface")
|
22 |
-
if not logger_instance.handlers:
|
23 |
-
handler = logging.StreamHandler(sys.stdout); handler.setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s", datefmt="%Y-%m-%d %H:%M:%S")); logger_instance.addHandler(handler)
|
24 |
-
return logger_instance
|
25 |
-
logger = init_logger()
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
for path in [os.path.join(base_dir, 'assets', filename), os.path.join(base_dir, filename)]:
|
31 |
-
if os.path.exists(path):
|
32 |
-
logger.info(f"Asset found: '{filename}' -> '{path}'")
|
33 |
-
return path
|
34 |
-
logger.warning(f"Asset NOT FOUND: '{filename}'.")
|
35 |
-
return None
|
36 |
|
37 |
-
logo_path_verified = get_asset_path(
|
38 |
-
|
39 |
|
40 |
-
# --- Core Logic Imports
|
41 |
-
MainFusionPublic = None; initialization_error: Optional[Exception] = None; DEFAULT_INFERENCE_PRESET_INTERFACE = "balanced"; get_user_tier = lambda token: "error (auth module failed)"
|
42 |
try:
|
43 |
-
script_dir = os.path.dirname(os.path.abspath(__file__)); project_root = script_dir
|
44 |
-
if project_root not in sys.path: sys.path.insert(0, project_root)
|
45 |
from modules.main_fusion_public import MainFusionPublic
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
except Exception as e: initialization_error = e
|
50 |
-
|
51 |
-
# --- Initialize AI System (Your existing code is perfect) ---
|
52 |
-
ai_system: Optional[MainFusionPublic] = None
|
53 |
-
if 'MainFusionPublic' in globals() and MainFusionPublic is not None and initialization_error is None:
|
54 |
-
try: ai_system = MainFusionPublic()
|
55 |
-
except Exception as e_init: initialization_error = e_init
|
56 |
-
elif initialization_error is None: initialization_error = ModuleNotFoundError("MainFusionPublic module could not be imported.")
|
57 |
-
|
58 |
-
# --- TIER_FEATURES Dictionary (Your existing code is perfect) ---
|
59 |
-
TIER_FEATURES = {"free": {"display_name": "Free Tier", "memory_enabled": False, "export_enabled": False}, "starter": {"display_name": "Starter Tier", "memory_enabled": True, "export_enabled": False}, "pro": {"display_name": "Pro Tier", "memory_enabled": True, "export_enabled": True}, "error (auth module failed)": {"display_name": "Error", "memory_enabled": False, "export_enabled": False}}
|
60 |
|
61 |
-
# ---
|
62 |
-
|
63 |
@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Inter:wght@400;600;700&display=swap');
|
64 |
-
|
65 |
-
:
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
--font-display: 'Bebas Neue', 'Staatliches', cursive;
|
76 |
-
--font-body: 'Inter', sans-serif;
|
77 |
-
|
78 |
-
--radius-md: 12px;
|
79 |
-
--radius-sm: 8px;
|
80 |
-
--shadow-glow: 0 0 15px rgba(0, 191, 255, 0.2);
|
81 |
-
}
|
82 |
-
|
83 |
-
/* --- Base & Reset --- */
|
84 |
-
footer, canvas { display: none !important; }
|
85 |
-
html, body {
|
86 |
-
background-color: var(--bg-main) !important;
|
87 |
-
font-family: var(--font-body);
|
88 |
-
color: var(--text-primary);
|
89 |
-
line-height: 1.6;
|
90 |
-
scroll-behavior: smooth;
|
91 |
-
}
|
92 |
-
.gradio-container {
|
93 |
-
max-width: 800px !important;
|
94 |
-
margin: 0 auto !important;
|
95 |
-
padding: 2rem 1.5rem !important;
|
96 |
-
background-color: transparent !important;
|
97 |
-
}
|
98 |
-
|
99 |
-
/* --- Typographic Hierarchy --- */
|
100 |
-
h1, h2, h3, #header_subtitle, #welcome_message {
|
101 |
-
font-family: var(--font-display) !important;
|
102 |
-
text-transform: uppercase;
|
103 |
-
letter-spacing: 1.5px;
|
104 |
-
color: var(--text-primary);
|
105 |
-
text-align: center;
|
106 |
-
}
|
107 |
-
|
108 |
-
/* --- Header & Branding --- */
|
109 |
-
#header_column { margin-bottom: 2rem; }
|
110 |
-
#header_logo img {
|
111 |
-
max-height: 70px;
|
112 |
-
filter: brightness(0) invert(1); /* Force pure white logo */
|
113 |
-
}
|
114 |
-
#header_subtitle { font-size: 1.2rem !important; color: var(--text-secondary); }
|
115 |
-
#welcome_message {
|
116 |
-
font-size: 1.5rem !important;
|
117 |
-
color: var(--text-primary);
|
118 |
-
margin-bottom: 2.5rem;
|
119 |
-
}
|
120 |
-
|
121 |
-
/* --- Interactive Elements & Input Areas --- */
|
122 |
-
.gradio-group {
|
123 |
-
background: transparent !important;
|
124 |
-
border: none !important;
|
125 |
-
padding: 0 !important;
|
126 |
-
}
|
127 |
-
.gradio-textbox textarea, .gradio-textbox input {
|
128 |
-
background-color: var(--bg-surface) !important;
|
129 |
-
color: var(--text-primary) !important;
|
130 |
-
border: 1px solid var(--border-subtle) !important;
|
131 |
-
border-radius: var(--radius-md) !important;
|
132 |
-
padding: 1rem !important;
|
133 |
-
transition: border-color 0.3s, box-shadow 0.3s;
|
134 |
-
}
|
135 |
-
.gradio-textbox textarea:focus, .gradio-textbox input:focus {
|
136 |
-
border-color: var(--accent-glow) !important;
|
137 |
-
box-shadow: var(--shadow-glow) !important;
|
138 |
-
}
|
139 |
-
#query_input textarea { min-height: 180px !important; }
|
140 |
-
|
141 |
-
/* --- Buttons: The Core Interaction --- */
|
142 |
-
.gradio-button {
|
143 |
-
border-radius: var(--radius-md) !important;
|
144 |
-
transition: all 0.2s ease-in-out;
|
145 |
-
border: none !important;
|
146 |
-
}
|
147 |
-
#submit_button {
|
148 |
-
background: var(--accent-glow) !important;
|
149 |
-
color: var(--bg-main) !important;
|
150 |
-
font-weight: 700 !important;
|
151 |
-
text-transform: uppercase;
|
152 |
-
}
|
153 |
-
#submit_button:hover {
|
154 |
-
background: var(--text-primary) !important;
|
155 |
-
transform: translateY(-2px);
|
156 |
-
box-shadow: 0 4px 20px rgba(0,0,0,0.2);
|
157 |
-
}
|
158 |
-
#clear_button {
|
159 |
-
background: var(--bg-surface-raised) !important;
|
160 |
-
color: var(--text-secondary) !important;
|
161 |
-
}
|
162 |
-
#clear_button:hover {
|
163 |
-
background: var(--border-subtle) !important;
|
164 |
-
color: var(--text-primary) !important;
|
165 |
-
}
|
166 |
-
#export_memory_button {
|
167 |
-
background: transparent !important;
|
168 |
-
color: var(--text-secondary) !important;
|
169 |
-
border: 1px solid var(--border-subtle) !important;
|
170 |
-
}
|
171 |
-
#export_memory_button:hover {
|
172 |
-
color: var(--text-primary) !important;
|
173 |
-
border-color: var(--accent-glow) !important;
|
174 |
-
}
|
175 |
-
|
176 |
-
/* --- Output & Information Display --- */
|
177 |
-
#synthesized_summary_output, #fusion_output {
|
178 |
-
background-color: var(--bg-surface) !important;
|
179 |
-
border: 1px solid var(--border-subtle) !important;
|
180 |
-
border-radius: var(--radius-md) !important;
|
181 |
-
padding: 1.5rem !important;
|
182 |
-
margin-top: 1rem;
|
183 |
-
}
|
184 |
-
#synthesized_summary_output h2, #fusion_output h2 { font-size: 1.2rem; color: var(--accent-glow); }
|
185 |
-
|
186 |
-
/* --- Accordions & Tier Status --- */
|
187 |
-
.gradio-accordion { border: none !important; }
|
188 |
-
.gradio-accordion > .label-wrap {
|
189 |
-
background: var(--bg-surface-raised) !important;
|
190 |
-
border-radius: var(--radius-sm) !important;
|
191 |
-
padding: 0.75rem 1rem !important;
|
192 |
-
color: var(--text-secondary) !important;
|
193 |
-
}
|
194 |
-
#tier_status_display { text-align: right !important; }
|
195 |
-
#tier_status_display small { color: var(--text-secondary) !important; }
|
196 |
-
|
197 |
-
/* --- Loading Indicator --- */
|
198 |
-
.cosmic-loading { padding: 3rem; }
|
199 |
-
.orbital-spinner {
|
200 |
-
border-color: var(--border-subtle);
|
201 |
-
border-top-color: var(--accent-glow);
|
202 |
-
}
|
203 |
-
.thinking-text { font-family: var(--font-body); color: var(--text-secondary); }
|
204 |
-
|
205 |
-
/* --- Footer --- */
|
206 |
-
#footer_attribution {
|
207 |
-
font-size: 0.8rem;
|
208 |
-
color: #555;
|
209 |
-
text-align: center;
|
210 |
-
margin-top: 4rem;
|
211 |
-
padding-bottom: 1rem;
|
212 |
-
line-height: 1.5;
|
213 |
-
}
|
214 |
-
#footer_attribution strong { color: #777; font-weight: 600; }
|
215 |
"""
|
216 |
|
217 |
-
# ---
|
218 |
-
def
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
def format_tier_status_for_ui(tier_name: str) -> str:
|
231 |
-
features = TIER_FEATURES.get(tier_name, TIER_FEATURES["error (auth module failed)"])
|
232 |
-
return f"<small>Tier: **{features['display_name']}** | Memory: {'✅' if features['memory_enabled'] else '❌'} | Export: {'✅' if features['export_enabled'] else '❌'}</small>"
|
233 |
-
|
234 |
-
def update_tier_display_and_features_ui(user_token_str: Optional[str]) -> Tuple:
|
235 |
-
tier_name = get_user_tier(user_token_str or "")
|
236 |
-
tier_features = TIER_FEATURES.get(tier_name, TIER_FEATURES["free"])
|
237 |
-
return (gr.update(value=format_tier_status_for_ui(tier_name)), gr.update(interactive=tier_features["export_enabled"]))
|
238 |
-
|
239 |
-
def export_user_memory_data_for_download(user_token_str: Optional[str]):
|
240 |
-
# This is a placeholder for your actual export logic
|
241 |
-
gr.Info("Export functionality would be triggered here for Pro users.")
|
242 |
-
return None
|
243 |
-
|
244 |
-
# --- Build Gradio Interface (Main Structure is Yours, Components are Styled) ---
|
245 |
-
def build_interface(logo_path_param: Optional[str], favicon_path_param: Optional[str]) -> gr.Blocks:
|
246 |
-
theme = gr.themes.Base(font=[gr.themes.GoogleFont("Inter"), "sans-serif"])
|
247 |
-
initial_tier_name = get_user_tier("")
|
248 |
-
initial_tier_features = TIER_FEATURES.get(initial_tier_name, TIER_FEATURES["free"])
|
249 |
-
|
250 |
-
with gr.Blocks(theme=theme, css=zotheos_base_css, title=APP_TITLE) as demo:
|
251 |
-
with gr.Column(elem_classes="centered-container"):
|
252 |
-
# --- Header ---
|
253 |
-
with gr.Column(elem_id="header_column"):
|
254 |
-
if logo_path_param:
|
255 |
-
gr.Image(value=logo_path_param, elem_id="header_logo", show_label=False, container=False, interactive=False)
|
256 |
-
gr.Markdown("Ethical Fusion AI for Synthesized Intelligence", elem_id="header_subtitle")
|
257 |
|
258 |
-
gr.
|
259 |
-
|
260 |
-
|
261 |
-
with gr.Row(equal_height=False):
|
262 |
-
user_token_input = gr.Textbox(label="Access Token", placeholder="Enter token...", type="password", scale=3, container=False)
|
263 |
-
# --- FIX IS HERE ---
|
264 |
-
tier_status_display = gr.Markdown(value=format_tier_status_for_ui(initial_tier_name), elem_id="tier_status_display")
|
265 |
-
|
266 |
-
# --- Core Input ---
|
267 |
-
with gr.Group():
|
268 |
-
query_input_component = gr.Textbox(label="Your Inquiry:", placeholder="e.g., Analyze the ethical implications of AI in art...", lines=6, elem_id="query_input")
|
269 |
-
status_indicator_component = gr.HTML(elem_id="status_indicator", visible=False)
|
270 |
-
with gr.Row():
|
271 |
-
clear_button_component = gr.Button("Clear", elem_id="clear_button", variant="secondary")
|
272 |
-
submit_button_component = gr.Button("Process Inquiry", elem_id="submit_button", variant="primary", scale=3)
|
273 |
-
|
274 |
-
# --- Main Outputs ---
|
275 |
-
with gr.Group():
|
276 |
-
synthesized_summary_component = gr.Markdown(elem_id="synthesized_summary_output", value="Synthesized insight will appear here...", visible=True)
|
277 |
-
fused_response_output_component = gr.Markdown(elem_id="fusion_output", value="Detailed perspectives will appear here...", visible=True)
|
278 |
|
279 |
-
|
280 |
-
export_memory_button = gr.Button("Export Memory Log", elem_id="export_memory_button", interactive=initial_tier_features["export_enabled"])
|
281 |
-
with gr.Accordion("System Status & Active Models", open=False):
|
282 |
-
active_models_display_component = gr.Markdown("**Status:** Initializing...")
|
283 |
-
with gr.Accordion("Recent Interaction Chronicle", open=False):
|
284 |
-
memory_display_panel_html = gr.HTML("<div class='memory-entry'>No memory entries yet.</div>")
|
285 |
-
|
286 |
-
# --- Footer ---
|
287 |
-
gr.Markdown("---", elem_id="footer_separator")
|
288 |
-
gr.Markdown("ZOTHEOS © 2025 ZOTHEOS LLC. System Architect: David A. Garcia. All Rights Reserved.", elem_id="footer_attribution")
|
289 |
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
tier_name = get_user_tier(token or ""); display_name = TIER_FEATURES.get(tier_name, {})["display_name"]
|
294 |
-
loading_html = f"<div class='cosmic-loading'><div class='orbital-spinner'></div><div class='thinking-text'>Synthesizing (Tier: {display_name})...</div></div>"
|
295 |
-
yield (gr.update(value=loading_html, visible=True), gr.update(interactive=False), gr.update(interactive=False), "Processing...", "Processing...", "Processing...", "Processing...")
|
296 |
-
if not ai_system:
|
297 |
-
yield (gr.update(value="<p style='color:red;'>SYSTEM OFFLINE</p>", visible=True), gr.update(interactive=True), gr.update(interactive=True), "Error", "Error", "Offline", "Error")
|
298 |
-
return
|
299 |
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
|
|
|
|
|
|
307 |
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
mem_html = render_memory_entries_as_html(mem_data)
|
312 |
-
|
313 |
-
status_md = "**Status:** `Ready`"
|
314 |
-
if hasattr(ai_system, 'get_status_report'):
|
315 |
-
status_report = await ai_system.get_status_report()
|
316 |
-
status_md = f"**Last Used:** {', '.join(status_report.get('models_last_queried_for_perspectives', ['N/A']))}"
|
317 |
|
318 |
-
|
319 |
-
|
320 |
-
# Connect events
|
321 |
-
submit_button_component.click(fn=process_query_wrapper_internal, inputs=[query_input_component, user_token_input], outputs=[status_indicator_component, submit_button_component, clear_button_component, synthesized_summary_component, fused_response_output_component, active_models_display_component, memory_display_panel_html], show_progress="hidden")
|
322 |
-
clear_button_component.click(lambda: ("", "", "Synthesized insight...", "Detailed perspectives..."), outputs=[query_input_component, user_token_input, synthesized_summary_component, fused_response_output_component])
|
323 |
-
user_token_input.change(fn=update_tier_display_and_features_ui, inputs=[user_token_input], outputs=[tier_status_display, export_memory_button])
|
324 |
-
export_memory_button.click(fn=export_user_memory_data_for_download, inputs=[user_token_input], outputs=[])
|
325 |
|
|
|
|
|
|
|
|
|
|
|
326 |
return demo
|
327 |
|
328 |
# --- Main Execution Block ---
|
329 |
if __name__ == "__main__":
|
330 |
-
logger.info("--- Initializing ZOTHEOS
|
331 |
-
zotheos_interface = build_interface(
|
332 |
-
logger.info("✅
|
333 |
-
|
334 |
-
zotheos_interface.queue().launch(**launch_kwargs)
|
|
|
1 |
+
# FILE: main_web.py (Hugging Face Demo - Final Upgraded Version)
|
2 |
+
|
3 |
import gradio as gr
|
4 |
import asyncio
|
5 |
import logging
|
6 |
import os
|
7 |
import sys
|
8 |
+
from typing import Optional, List, Dict, Any
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
# --- Basic Setup ---
|
11 |
APP_TITLE = "ZOTHEOS - Ethical Fusion AI"
|
12 |
+
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
13 |
+
logger = logging.getLogger("ZOTHEOS_Interface_HF")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
def get_asset_path(filename: str) -> str:
|
16 |
+
# In Hugging Face Spaces, assets are in the root or /assets
|
17 |
+
return filename if os.path.exists(filename) else os.path.join('assets', filename)
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
+
logo_path_verified = get_asset_path("zotheos_logo.png")
|
20 |
+
GUMROAD_LINK = "YOUR_GUMROAD_LINK_HERE" # <-- IMPORTANT: REPLACE WITH YOUR GUMROAD LINK
|
21 |
|
22 |
+
# --- Core Logic Imports ---
|
|
|
23 |
try:
|
|
|
|
|
24 |
from modules.main_fusion_public import MainFusionPublic
|
25 |
+
except ImportError:
|
26 |
+
MainFusionPublic = None
|
27 |
+
ai_system = MainFusionPublic() if MainFusionPublic else None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
+
# --- ✅ DEFINITIVE "OBSIDIAN" CSS THEME ---
|
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; }
|
33 |
+
.gradio-container { background: transparent !important; max-width: 900px !important; }
|
34 |
+
#header_logo img { max-height: 70px !important; filter: brightness(0) invert(1) !important; }
|
35 |
+
#header_subtitle { font-family: 'Bebas Neue', cursive !important; font-size: 1.8rem !important; text-transform: uppercase !important; letter-spacing: 2px !important; }
|
36 |
+
#header_tagline { color: #a0a0a0 !important; margin-top: -10px !important; margin-bottom: 1.5rem !important; }
|
37 |
+
.gradio-textbox textarea { font-size: 1.1rem !important; }
|
38 |
+
.result-box { background-color: rgba(18, 18, 18, 0.8) !important; border: 1px solid #333 !important; border-radius: 12px !important; padding: 1.5rem 2rem !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 |
+
.cta-button:hover { background: #e0e0e0 !important; }
|
42 |
+
footer { display: none !important; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
"""
|
44 |
|
45 |
+
# --- Build Gradio Interface ---
|
46 |
+
def build_interface():
|
47 |
+
zotheos_theme = gr.themes.Base(primary_hue=gr.themes.colors.neutral, secondary_hue=gr.themes.colors.neutral).set(
|
48 |
+
button_primary_background_fill="white", button_primary_text_color="black"
|
49 |
+
)
|
50 |
+
|
51 |
+
with gr.Blocks(theme=zotheos_theme, css=zotheos_web_css, title=APP_TITLE) as demo:
|
52 |
+
with gr.Column(elem_classes="gradio-container"):
|
53 |
+
# --- ✅ UPGRADED HEADER WITH CALL TO ACTION ---
|
54 |
+
gr.Image(value=logo_path_verified, elem_id="header_logo", show_label=False, container=False, interactive=False)
|
55 |
+
gr.Markdown("Ethical Fusion AI for Synthesized Intelligence", elem_id="header_subtitle")
|
56 |
+
gr.Markdown("Fusing perspectives for deeper truth.", elem_id="header_tagline")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
download_button = gr.Button("Download Full Version on Gumroad", link=GUMROAD_LINK, elem_classes="cta-button")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
+
gr.Markdown("---") # Separator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
+
# --- Main Interaction Area ---
|
65 |
+
query_input = gr.Textbox(label="Your Inquiry:", placeholder="e.g., Analyze the ethical implications of AI in art...", lines=6)
|
66 |
+
submit_button = gr.Button("Process Inquiry (Web Demo)", variant="primary")
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
+
with gr.Column(visible=False) as results_box:
|
69 |
+
gr.Markdown("## ✨ ZOTHEOS Final Synthesized Insight ✨")
|
70 |
+
synthesized_summary_output = gr.Markdown()
|
71 |
+
gr.Markdown("### 💬 Detailed Individual Perspectives")
|
72 |
+
fusion_output = gr.Markdown()
|
73 |
+
|
74 |
+
# --- Backend Logic ---
|
75 |
+
async def process_query_wrapper(query):
|
76 |
+
if not ai_system:
|
77 |
+
return gr.update(visible=True), "[SYSTEM OFFLINE] The AI engine failed to load.", ""
|
78 |
|
79 |
+
response = await ai_system.process_query_with_fusion(query)
|
80 |
+
summary = response.split("###")[0].replace("## ✨ ZOTHEOS Final Synthesized Insight ✨", "").strip()
|
81 |
+
perspectives = "###" + response.split("###", 1)[1] if "###" in response else ""
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
+
return gr.update(visible=True), summary, perspectives
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
+
submit_button.click(
|
86 |
+
fn=process_query_wrapper,
|
87 |
+
inputs=[query_input],
|
88 |
+
outputs=[results_box, synthesized_summary_output, fusion_output]
|
89 |
+
)
|
90 |
return demo
|
91 |
|
92 |
# --- Main Execution Block ---
|
93 |
if __name__ == "__main__":
|
94 |
+
logger.info("--- Initializing ZOTHEOS Hugging Face Demo ---")
|
95 |
+
zotheos_interface = build_interface()
|
96 |
+
logger.info("✅ HF Demo UI built.")
|
97 |
+
zotheos_interface.queue().launch()
|
|