Spaces:
Sleeping
Sleeping
Update main_web.py
Browse files- main_web.py +133 -36
main_web.py
CHANGED
@@ -1,36 +1,133 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
#
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
#
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
#
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import asyncio # Use asyncio for async operations like your real fusion logic will need
|
3 |
+
|
4 |
+
# --- 1. ZOTHEOS STYLING (CSS) ---
|
5 |
+
# All the styling for the Gradio app is placed right here. No separate files needed.
|
6 |
+
ZOTHEOS_CSS = """
|
7 |
+
/* Hide the default Gradio footer */
|
8 |
+
footer {
|
9 |
+
display: none !important;
|
10 |
+
}
|
11 |
+
|
12 |
+
/* Main container styling for the dark, focused theme */
|
13 |
+
.gradio-container {
|
14 |
+
background: radial-gradient(ellipse at bottom, #0a0a15 0%, #050510 70%, #000000 100%);
|
15 |
+
}
|
16 |
+
|
17 |
+
/* Custom header styling */
|
18 |
+
#zotheos_header {
|
19 |
+
text-align: center;
|
20 |
+
margin-bottom: 20px;
|
21 |
+
border-bottom: 1px solid #333;
|
22 |
+
padding-bottom: 20px;
|
23 |
+
}
|
24 |
+
#zotheos_header h1 {
|
25 |
+
color: #f0f0f5;
|
26 |
+
font-size: 2.5rem;
|
27 |
+
font-weight: 700;
|
28 |
+
margin: 0;
|
29 |
+
}
|
30 |
+
#zotheos_header p {
|
31 |
+
color: #999;
|
32 |
+
font-size: 1.1rem;
|
33 |
+
margin-top: 5px;
|
34 |
+
}
|
35 |
+
|
36 |
+
/* Input/Output box styling */
|
37 |
+
.gradio-container .gr-input, .gradio-container .gr-output {
|
38 |
+
border-color: #333 !important;
|
39 |
+
background-color: #0f0f18 !important;
|
40 |
+
color: #f0f0f5 !important;
|
41 |
+
}
|
42 |
+
.gradio-container .gr-label {
|
43 |
+
color: #aaa !important;
|
44 |
+
}
|
45 |
+
|
46 |
+
/* Button styling */
|
47 |
+
.gradio-container .gr-button-primary {
|
48 |
+
background: linear-gradient(90deg, #4a90e2, #5fdfff);
|
49 |
+
color: white;
|
50 |
+
font-weight: bold;
|
51 |
+
border: none;
|
52 |
+
}
|
53 |
+
"""
|
54 |
+
|
55 |
+
# --- 2. THE CORE AI FUNCTION (Async Ready) ---
|
56 |
+
# This is where your fusion logic will go. It's set up to be async.
|
57 |
+
async def run_zotheos_fusion(question):
|
58 |
+
"""
|
59 |
+
This function takes a user's question, runs it through your fused models,
|
60 |
+
and returns the three distinct perspectives.
|
61 |
+
"""
|
62 |
+
|
63 |
+
# --- YOUR FUSION LOGIC GOES HERE ---
|
64 |
+
#
|
65 |
+
# Replace this placeholder logic with your actual call:
|
66 |
+
# result = await ai_system.process_query_with_fusion(...)
|
67 |
+
# mistral_output = result['mistral']
|
68 |
+
# gemma_output = result['gemma']
|
69 |
+
# qwen_output = result['qwen']
|
70 |
+
|
71 |
+
print(f"Received question: {question}") # For debugging in Hugging Face logs
|
72 |
+
|
73 |
+
# Placeholder logic that simulates async model processing:
|
74 |
+
await asyncio.sleep(2) # Simulate async delay
|
75 |
+
mistral_output = f"**Pragmatic Perspective (Mistral):** Based on the data points surrounding '{question}', the most logical path forward is..."
|
76 |
+
gemma_output = f"**Ethical & Human-Centric Perspective (Gemma):** Considering the human impact of '{question}', it's vital to prioritize compassion and fairness..."
|
77 |
+
qwen_output = f"**Creative & Alternative Perspective (Qwen):** What if we reframe '{question}' entirely? An unconventional approach might be..."
|
78 |
+
|
79 |
+
return mistral_output, gemma_output, qwen_output
|
80 |
+
# --- END OF YOUR FUSION LOGIC SECTION ---
|
81 |
+
|
82 |
+
|
83 |
+
# --- 3. GRADIO USER INTERFACE (UI) ---
|
84 |
+
# We use a base theme and apply our custom CSS on top of it.
|
85 |
+
with gr.Blocks(theme=gr.themes.Base(), css=ZOTHEOS_CSS, title="ZOTHEOS") as demo:
|
86 |
+
|
87 |
+
# Custom Header
|
88 |
+
with gr.Row():
|
89 |
+
gr.HTML("""
|
90 |
+
<div id="zotheos_header">
|
91 |
+
<h1>ZOTHEOS</h1>
|
92 |
+
<p>The Ethical Fusion AI for Multi-Perspective Understanding</p>
|
93 |
+
</div>
|
94 |
+
""")
|
95 |
+
|
96 |
+
# Main Input/Output Layout
|
97 |
+
with gr.Row():
|
98 |
+
with gr.Column(scale=3):
|
99 |
+
question_input = gr.Textbox(
|
100 |
+
label="Your Inquiry",
|
101 |
+
placeholder="e.g., What is the future of decentralized education?",
|
102 |
+
lines=4
|
103 |
+
)
|
104 |
+
submit_button = gr.Button("Synthesize Perspectives", variant="primary")
|
105 |
+
|
106 |
+
gr.Markdown("---")
|
107 |
+
|
108 |
+
with gr.Row():
|
109 |
+
# Using Markdown for better text formatting (like bolding the titles)
|
110 |
+
output_mistral = gr.Markdown(label="Perspective 1: The Pragmatist (Mistral)")
|
111 |
+
output_gemma = gr.Markdown(label="Perspective 2: The Ethicist (Gemma)")
|
112 |
+
output_qwen = gr.Markdown(label="Perspective 3: The Innovator (Qwen)")
|
113 |
+
|
114 |
+
# --- 4. CONNECTING THE UI TO THE FUNCTION ---
|
115 |
+
submit_button.click(
|
116 |
+
fn=run_zotheos_fusion,
|
117 |
+
inputs=question_input,
|
118 |
+
outputs=[output_mistral, output_gemma, output_qwen],
|
119 |
+
show_progress="dots" # Shows a loading animation
|
120 |
+
)
|
121 |
+
|
122 |
+
gr.Examples(
|
123 |
+
examples=[
|
124 |
+
"What are the ethical implications of AI in hiring?",
|
125 |
+
"How can technology bridge the gap between rural and urban healthcare?",
|
126 |
+
"Explain the concept of 'truth' from a philosophical and a scientific standpoint."
|
127 |
+
],
|
128 |
+
inputs=question_input
|
129 |
+
)
|
130 |
+
|
131 |
+
# --- 5. LAUNCH THE APP ---
|
132 |
+
if __name__ == "__main__":
|
133 |
+
demo.queue().launch()
|