Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,42 +1,95 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
-
from genesis.pipeline import research_once
|
|
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
-
|
|
|
|
|
|
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
img_out = gr.Image(type="filepath", label="Generated Research Diagram")
|
27 |
-
audio_out = gr.Audio(type="filepath", label="AI Narration")
|
28 |
|
29 |
-
|
30 |
with gr.Row():
|
|
|
31 |
for q in DEMO_QUERIES:
|
32 |
-
btn = gr.Button(q)
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
-
#
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
41 |
|
42 |
-
|
|
|
|
1 |
+
# app.py
|
2 |
import gradio as gr
|
3 |
+
from genesis.pipeline import research_once
|
4 |
+
from genesis.visualization import generate_pathway_graph, generate_funding_network
|
5 |
|
6 |
+
# Predefined demo queries
|
7 |
+
DEMO_QUERIES = [
|
8 |
+
"Map all CRISPR-based living therapeutics in clinical trials since 2020",
|
9 |
+
"Graph metabolic engineering pathways for bio-based drug production",
|
10 |
+
"Synthetic biology startups developing oncolytic viruses β funding + trials",
|
11 |
+
"3D bioprinting advances for organ transplantation with regulatory analysis",
|
12 |
+
"AI-driven biosensor design for early cancer detection"
|
13 |
+
]
|
14 |
+
|
15 |
+
def run_pipeline(query):
|
16 |
+
"""Run GENESIS-AI pipeline and return all outputs for UI."""
|
17 |
report = research_once(query)
|
|
|
|
|
|
|
18 |
|
19 |
+
# Markdown citations
|
20 |
+
cites_md = "### Citations\n"
|
21 |
+
if report["citations"]:
|
22 |
+
for c in report["citations"]:
|
23 |
+
cites_md += f"- [{c['type']}]({c['url']})\n"
|
24 |
+
else:
|
25 |
+
cites_md += "_No citations found_"
|
26 |
|
27 |
+
# Build pathway graph (demo: using expanded_terms as nodes)
|
28 |
+
pathway_fig = generate_pathway_graph(
|
29 |
+
entities=report["expanded_terms"],
|
30 |
+
relationships=[{"source": report["expanded_terms"][i],
|
31 |
+
"target": report["expanded_terms"][i+1],
|
32 |
+
"type": "related"}
|
33 |
+
for i in range(len(report["expanded_terms"]) - 1)]
|
34 |
+
)
|
35 |
|
36 |
+
# Funding graph (only demo; in real use, use data from pipeline)
|
37 |
+
funding_fig = generate_funding_network(
|
38 |
+
companies=[
|
39 |
+
{"name": "SynBioTech", "investors": "BioFund, HealthCapital"},
|
40 |
+
{"name": "GeneWorks", "investors": "BioFund, InnovationAngels"}
|
41 |
+
]
|
42 |
+
)
|
43 |
+
|
44 |
+
return (
|
45 |
+
report["summary"],
|
46 |
+
cites_md,
|
47 |
+
report["visual_image_url"] or "No image generated",
|
48 |
+
pathway_fig,
|
49 |
+
funding_fig
|
50 |
+
)
|
51 |
|
52 |
+
# ---- Build UI ----
|
53 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
54 |
+
gr.Markdown("# π± GENESIS-AI β Synthetic Biology Intelligence Platform")
|
55 |
+
gr.Markdown("Cutting-edge research synthesis, citations, structures, and interactive graphs.")
|
56 |
|
57 |
+
with gr.Row():
|
58 |
+
query_input = gr.Textbox(label="Enter your research topic", placeholder="e.g., CRISPR gene therapy for cancer")
|
59 |
+
run_btn = gr.Button("Run Research", variant="primary")
|
|
|
|
|
60 |
|
61 |
+
gr.Markdown("### Quick Demo Queries")
|
62 |
with gr.Row():
|
63 |
+
demo_buttons = []
|
64 |
for q in DEMO_QUERIES:
|
65 |
+
btn = gr.Button(q, variant="secondary")
|
66 |
+
demo_buttons.append((btn, q))
|
67 |
+
|
68 |
+
with gr.Tab("Summary"):
|
69 |
+
summary_output = gr.Markdown()
|
70 |
+
with gr.Tab("Citations"):
|
71 |
+
cites_output = gr.Markdown()
|
72 |
+
with gr.Tab("Image / Diagram"):
|
73 |
+
image_output = gr.Image(type="filepath")
|
74 |
+
with gr.Tab("Pathway Graph"):
|
75 |
+
pathway_output = gr.Plot()
|
76 |
+
with gr.Tab("Funding Network"):
|
77 |
+
funding_output = gr.Plot()
|
78 |
+
|
79 |
+
# Link run button
|
80 |
+
run_btn.click(
|
81 |
+
fn=run_pipeline,
|
82 |
+
inputs=query_input,
|
83 |
+
outputs=[summary_output, cites_output, image_output, pathway_output, funding_output]
|
84 |
+
)
|
85 |
|
86 |
+
# Link each demo query button
|
87 |
+
for btn, q in demo_buttons:
|
88 |
+
btn.click(
|
89 |
+
fn=run_pipeline,
|
90 |
+
inputs=gr.Textbox(value=q, visible=False),
|
91 |
+
outputs=[summary_output, cites_output, image_output, pathway_output, funding_output]
|
92 |
+
)
|
93 |
|
94 |
+
if __name__ == "__main__":
|
95 |
+
demo.launch()
|