Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,59 +1,58 @@
|
|
1 |
# app.py
|
2 |
import gradio as gr
|
3 |
-
from genesis.pipeline import research_once
|
4 |
-
from genesis.pipeline import DEMO_QUERIES
|
5 |
|
6 |
-
# --------- UI Callback ---------
|
7 |
def run_pipeline_ui(query):
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
report["visual_image_url"] or "No image generated",
|
15 |
-
report["audio_url"] or None
|
16 |
-
)
|
17 |
-
except Exception as e:
|
18 |
-
return f"Error: {e}", [], [], None, None
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
23 |
gr.Markdown(
|
24 |
-
"
|
|
|
|
|
|
|
|
|
|
|
25 |
)
|
26 |
-
|
27 |
with gr.Row():
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
)
|
33 |
-
|
34 |
-
|
35 |
-
output_summary = gr.Textbox(label="Summary", lines=8)
|
36 |
-
output_citations = gr.JSON(label="Citations")
|
37 |
-
output_structures = gr.JSON(label="Molecular Structures")
|
38 |
-
output_image = gr.Image(label="Generated Diagram / Image")
|
39 |
-
output_audio = gr.Audio(label="Narration", type="filepath")
|
40 |
-
|
41 |
-
# Demo Queries Section
|
42 |
-
gr.Markdown("### Demo Queries")
|
43 |
with gr.Row():
|
44 |
for q in DEMO_QUERIES:
|
45 |
-
gr.Button(q).click(
|
46 |
fn=run_pipeline_ui,
|
47 |
-
inputs=
|
48 |
-
outputs=[
|
49 |
)
|
50 |
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
fn=run_pipeline_ui,
|
54 |
-
inputs=
|
55 |
-
outputs=[
|
56 |
)
|
57 |
|
58 |
-
|
59 |
-
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
1 |
# app.py
|
2 |
import gradio as gr
|
3 |
+
from genesis.pipeline import research_once, DEMO_QUERIES
|
|
|
4 |
|
|
|
5 |
def run_pipeline_ui(query):
|
6 |
+
if not query.strip():
|
7 |
+
return "Please enter a research topic.", "", None, None
|
8 |
+
report = research_once(query)
|
9 |
+
summary = report["summary"]
|
10 |
+
citations_md = "\n".join(f"- [{c['type']}]({c['url']})" for c in report["citations"]) or "No citations found."
|
11 |
+
return summary, citations_md, report["visual_image_url"], report["audio_url"]
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
with gr.Blocks(theme=gr.themes.Soft(primary_hue="green", secondary_hue="blue"), css="""
|
14 |
+
.demo-btn {border-radius: 25px; padding: 8px 14px; font-weight: bold;}
|
15 |
+
.demo-btn:hover {background-color: #28a745 !important; color: white !important;}
|
16 |
+
""") as demo:
|
17 |
+
|
18 |
gr.Markdown(
|
19 |
+
"""
|
20 |
+
# 𧬠GENESIS-AI β Synthetic Biology Research Engine
|
21 |
+
Ask about **CRISPR**, drug design, biosensors, metabolic engineering, and more.
|
22 |
+
_Your AI co-pilot for disruptive biotech discovery._
|
23 |
+
""",
|
24 |
+
elem_id="title"
|
25 |
)
|
26 |
+
|
27 |
with gr.Row():
|
28 |
+
query_box = gr.Textbox(label="Enter Your Research Topic", placeholder="e.g., Design a CRISPR-based living therapeutic for triple-negative breast cancer", scale=4)
|
29 |
+
run_btn = gr.Button("π Run Research", variant="primary", scale=1)
|
30 |
+
|
31 |
+
with gr.Row():
|
32 |
+
gr.Markdown("**Or try one of these expert-curated demo queries:**")
|
33 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
with gr.Row():
|
35 |
for q in DEMO_QUERIES:
|
36 |
+
gr.Button(q, elem_classes="demo-btn").click(
|
37 |
fn=run_pipeline_ui,
|
38 |
+
inputs=gr.Textbox(value=q, visible=False),
|
39 |
+
outputs=["summary_out", "cites_out", "img_out", "audio_out"]
|
40 |
)
|
41 |
|
42 |
+
with gr.Tab("π Summary"):
|
43 |
+
summary_out = gr.Textbox(label="Executive Summary", lines=15, interactive=False)
|
44 |
+
with gr.Tab("π Citations"):
|
45 |
+
cites_out = gr.Markdown()
|
46 |
+
with gr.Tab("πΌ Diagram"):
|
47 |
+
img_out = gr.Image(type="filepath", label="Generated Research Diagram")
|
48 |
+
with gr.Tab("π Narration"):
|
49 |
+
audio_out = gr.Audio(type="filepath", label="AI Narration")
|
50 |
+
|
51 |
+
# Main run button event
|
52 |
+
run_btn.click(
|
53 |
fn=run_pipeline_ui,
|
54 |
+
inputs=query_box,
|
55 |
+
outputs=[summary_out, cites_out, img_out, audio_out]
|
56 |
)
|
57 |
|
58 |
+
demo.launch()
|
|