Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,12 @@
|
|
1 |
-
# app.py
|
2 |
import gradio as gr
|
|
|
3 |
from genesis.pipeline import research_once
|
4 |
-
from genesis.molecule_viewer import get_molecule_view
|
5 |
|
6 |
-
#
|
|
|
|
|
|
|
|
|
7 |
DEMO_QUERIES = [
|
8 |
"CRISPR living therapeutics in clinical trials since 2020",
|
9 |
"AI-designed enzymes for plastic degradation β literature + pathways",
|
@@ -12,49 +15,67 @@ DEMO_QUERIES = [
|
|
12 |
"Oncolytic virus engineering β biosecurity risk analysis"
|
13 |
]
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
result["summary"],
|
20 |
-
"\n".join([f"{c['type']}: {c['url']}" for c in result["citations"]]),
|
21 |
-
result["visual_image_url"] or "No image",
|
22 |
-
result["audio_url"] or "No audio"
|
23 |
-
)
|
24 |
|
25 |
-
|
26 |
-
return get_molecule_view(pdb_or_gene)
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
-
with gr.
|
35 |
-
gr.
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
for q in DEMO_QUERIES:
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import os
|
3 |
from genesis.pipeline import research_once
|
|
|
4 |
|
5 |
+
# Load custom biotech theme
|
6 |
+
with open("static/style.css", "r") as f:
|
7 |
+
custom_css = f.read()
|
8 |
+
|
9 |
+
# Demo queries to impress the scientific audience
|
10 |
DEMO_QUERIES = [
|
11 |
"CRISPR living therapeutics in clinical trials since 2020",
|
12 |
"AI-designed enzymes for plastic degradation β literature + pathways",
|
|
|
15 |
"Oncolytic virus engineering β biosecurity risk analysis"
|
16 |
]
|
17 |
|
18 |
+
def run_pipeline(query, narration_enabled):
|
19 |
+
"""Run the research pipeline with optional narration."""
|
20 |
+
if not query or query.strip() == "":
|
21 |
+
return "Please enter a query.", None, None, None, None
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
+
report = research_once(query, narration=narration_enabled)
|
|
|
24 |
|
25 |
+
summary = report.get("summary", "No summary available.")
|
26 |
+
citations = report.get("citations", [])
|
27 |
+
structures = report.get("structures", [])
|
28 |
+
visual_image_url = report.get("visual_image_url", None)
|
29 |
+
audio_url = report.get("audio_url", None)
|
30 |
+
|
31 |
+
cites_md = ""
|
32 |
+
for c in citations:
|
33 |
+
cites_md += f"- **{c['type']}**: [{c['id'] or 'link'}]({c['url']})\n"
|
34 |
+
|
35 |
+
return summary, cites_md, structures, visual_image_url, audio_url
|
36 |
+
|
37 |
+
|
38 |
+
with gr.Blocks(css=custom_css, theme="default") as demo:
|
39 |
+
gr.Markdown("# 𧬠GENESIS-AI β Synthetic Biology Research Console")
|
40 |
+
gr.Markdown("### Explore CRISPR, metabolic engineering, living therapeutics, and beyond β powered by AI.")
|
41 |
|
42 |
+
with gr.Row():
|
43 |
+
with gr.Column(scale=2):
|
44 |
+
query_box = gr.Textbox(
|
45 |
+
placeholder="Enter your research question...",
|
46 |
+
label="Research Query",
|
47 |
+
lines=3
|
48 |
+
)
|
49 |
+
narration_toggle = gr.Checkbox(label="Enable narration (uses API credits)", value=False)
|
50 |
+
run_btn = gr.Button("π Run Research")
|
51 |
+
|
52 |
+
gr.Markdown("**Quick Demo Queries**")
|
53 |
+
demo_query_buttons = []
|
54 |
for q in DEMO_QUERIES:
|
55 |
+
btn = gr.Button(q)
|
56 |
+
demo_query_buttons.append((btn, q))
|
57 |
+
|
58 |
+
with gr.Column(scale=3):
|
59 |
+
output_summary = gr.Markdown(label="Research Summary")
|
60 |
+
output_citations = gr.Markdown(label="Citations")
|
61 |
+
output_structures = gr.JSON(label="Structures Data")
|
62 |
+
output_visual = gr.Image(label="Generated Diagram")
|
63 |
+
output_audio = gr.Audio(label="Narrated Summary")
|
64 |
+
|
65 |
+
# Main run button
|
66 |
+
run_btn.click(
|
67 |
+
fn=run_pipeline,
|
68 |
+
inputs=[query_box, narration_toggle],
|
69 |
+
outputs=[output_summary, output_citations, output_structures, output_visual, output_audio]
|
70 |
+
)
|
71 |
+
|
72 |
+
# Demo query buttons
|
73 |
+
for btn, q in demo_query_buttons:
|
74 |
+
btn.click(
|
75 |
+
fn=run_pipeline,
|
76 |
+
inputs=[gr.Textbox(value=q, visible=False), narration_toggle],
|
77 |
+
outputs=[output_summary, output_citations, output_structures, output_visual, output_audio]
|
78 |
+
)
|
79 |
+
|
80 |
+
if __name__ == "__main__":
|
81 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|