Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,64 +1,113 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
}
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
background-color: var(--bg-dark);
|
12 |
-
font-family: 'Orbitron', sans-serif;
|
13 |
-
}
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
}
|
21 |
|
22 |
-
#
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
text-
|
41 |
-
}
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
box-shadow: 0 0 20px var(--green);
|
52 |
-
animation: pulse 1.5s infinite;
|
53 |
-
}
|
54 |
|
55 |
-
#
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import random
|
3 |
+
from datetime import datetime
|
4 |
+
from genesis.pipeline import research_once
|
|
|
5 |
|
6 |
+
# --- Color scheme ---
|
7 |
+
PRIMARY_COLOR = "#00ff88" # Biotech green
|
8 |
+
SECONDARY_COLOR = "#ff8800" # Biotech orange
|
9 |
+
BG_COLOR = "#0b0f0c" # Dark lab background
|
|
|
|
|
|
|
10 |
|
11 |
+
# --- Demo queries ---
|
12 |
+
DEMO_QUERIES = {
|
13 |
+
"Literature & Regulatory Analysis": [
|
14 |
+
"CRISPR living therapeutics in clinical trials since 2020",
|
15 |
+
"AI-designed enzymes for plastic degradation β literature + pathways",
|
16 |
+
],
|
17 |
+
"Molecule / Gene Explorer": [
|
18 |
+
"BRCA1 structure and docking predictions",
|
19 |
+
"Spike protein mutations in SARS-CoV-2 β molecular modeling"
|
20 |
+
],
|
21 |
+
"Pathway Mapping": [
|
22 |
+
"Metabolic pathway for artemisinin biosynthesis in yeast",
|
23 |
+
"Synthetic biology pathway for PHB bioplastic production"
|
24 |
+
],
|
25 |
+
"Funding Network": [
|
26 |
+
"Synthetic biology startups in oncology β funding map",
|
27 |
+
"Venture capital in microbial biofactories since 2018"
|
28 |
+
],
|
29 |
+
"Microscopy & Image Analysis": [
|
30 |
+
"Analyze fluorescence microscopy for cancer cell segmentation",
|
31 |
+
"Detect bacterial morphology in electron microscopy images"
|
32 |
+
]
|
33 |
}
|
34 |
|
35 |
+
# --- Function to run queries ---
|
36 |
+
def run_query(query):
|
37 |
+
if not query.strip():
|
38 |
+
return "Please enter a query.", None, None
|
39 |
+
result = research_once(query)
|
40 |
+
return result["summary"], result.get("visual_image_url"), result.get("audio_url")
|
41 |
|
42 |
+
# --- Custom CSS for neon biotech theme ---
|
43 |
+
custom_css = f"""
|
44 |
+
body {{
|
45 |
+
background-color: {BG_COLOR};
|
46 |
+
}}
|
47 |
+
.gradio-container {{
|
48 |
+
background: {BG_COLOR} !important;
|
49 |
+
color: white !important;
|
50 |
+
}}
|
51 |
+
button {{
|
52 |
+
border-radius: 12px !important;
|
53 |
+
border: 2px solid {PRIMARY_COLOR} !important;
|
54 |
+
background-color: transparent !important;
|
55 |
+
color: {PRIMARY_COLOR} !important;
|
56 |
+
transition: 0.3s;
|
57 |
+
}}
|
58 |
+
button:hover {{
|
59 |
+
background-color: {PRIMARY_COLOR} !important;
|
60 |
+
color: black !important;
|
61 |
+
box-shadow: 0px 0px 15px {PRIMARY_COLOR};
|
62 |
+
}}
|
63 |
+
.particle-bg {{
|
64 |
+
position: fixed;
|
65 |
+
width: 100%;
|
66 |
+
height: 100%;
|
67 |
+
z-index: -1;
|
68 |
+
background: radial-gradient(circle at center, {PRIMARY_COLOR}11, {BG_COLOR} 80%);
|
69 |
+
}}
|
70 |
+
.demo-chip {{
|
71 |
+
display: inline-block;
|
72 |
+
padding: 8px 14px;
|
73 |
+
margin: 4px;
|
74 |
+
border-radius: 20px;
|
75 |
+
border: 1px solid {SECONDARY_COLOR};
|
76 |
+
color: {SECONDARY_COLOR};
|
77 |
+
cursor: pointer;
|
78 |
+
transition: 0.3s;
|
79 |
+
}}
|
80 |
+
.demo-chip:hover {{
|
81 |
+
background-color: {SECONDARY_COLOR};
|
82 |
+
color: black;
|
83 |
+
box-shadow: 0px 0px 10px {SECONDARY_COLOR};
|
84 |
+
}}
|
85 |
+
"""
|
86 |
|
87 |
+
# --- Build UI ---
|
88 |
+
with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
|
89 |
+
gr.HTML(f"<div class='particle-bg'></div>")
|
90 |
+
gr.HTML(f"<h1 style='color:{PRIMARY_COLOR};text-align:center'>𧬠GENESIS-AI</h1>")
|
91 |
+
gr.HTML(f"<h3 style='color:{SECONDARY_COLOR};text-align:center'>The Synthetic Biology Brain</h3>")
|
92 |
|
93 |
+
with gr.Tabs():
|
94 |
+
for mode, queries in DEMO_QUERIES.items():
|
95 |
+
with gr.Tab(mode):
|
96 |
+
query_box = gr.Textbox(label=f"Enter your query for {mode}", placeholder="Type here...")
|
97 |
+
run_btn = gr.Button(f"Run {mode}")
|
98 |
+
result_text = gr.Textbox(label="Summary", lines=8)
|
99 |
+
result_image = gr.Image(label="Generated Diagram / Analysis", type="filepath")
|
100 |
+
result_audio = gr.Audio(label="Narrated Summary", type="filepath")
|
|
|
|
|
|
|
101 |
|
102 |
+
# Demo query chips
|
103 |
+
with gr.Row():
|
104 |
+
for q in queries:
|
105 |
+
btn = gr.Button(q)
|
106 |
+
btn.click(fn=lambda x=q: (x,), outputs=query_box)
|
107 |
|
108 |
+
# Link run button
|
109 |
+
run_btn.click(fn=run_query, inputs=query_box, outputs=[result_text, result_image, result_audio])
|
110 |
+
|
111 |
+
# Launch
|
112 |
+
if __name__ == "__main__":
|
113 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|