Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,46 +1,60 @@
|
|
1 |
# app.py
|
2 |
import os
|
3 |
import gradio as gr
|
4 |
-
|
5 |
from genesis.pipeline import research_once
|
6 |
from genesis.narration import narrate_text
|
7 |
|
8 |
-
# Preloaded demo queries for tomorrow
|
9 |
-
demo_queries = [
|
10 |
-
"Designing synthetic gene circuits for targeted cancer therapy",
|
11 |
-
"CRISPR-based microbial engineering for biofuel production",
|
12 |
-
"Synthetic biology approaches to carbon capture and sequestration",
|
13 |
-
"Engineering probiotics for mental health treatments",
|
14 |
-
"DNA-based nanorobots for targeted drug delivery"
|
15 |
-
]
|
16 |
-
|
17 |
def run_pipeline_ui(query):
|
18 |
-
"""Run the full synthetic biology research pipeline."""
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
-
|
|
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
34 |
|
35 |
-
|
36 |
|
|
|
|
|
37 |
|
|
|
38 |
with gr.Blocks(title="GENESIS-AI: Synthetic Biology Deep Research") as demo:
|
39 |
gr.Markdown("# 𧬠GENESIS-AI\nThe most advanced synthetic biology research assistant ever built.")
|
40 |
|
41 |
with gr.Row():
|
42 |
-
query_box = gr.
|
43 |
-
run_btn = gr.Button("π Run Research")
|
44 |
|
45 |
with gr.Tab("π Report"):
|
46 |
report_out = gr.Textbox(label="Full Research Report", lines=20)
|
|
|
1 |
# app.py
|
2 |
import os
|
3 |
import gradio as gr
|
|
|
4 |
from genesis.pipeline import research_once
|
5 |
from genesis.narration import narrate_text
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
def run_pipeline_ui(query):
|
8 |
+
"""Run the full synthetic biology research pipeline and handle flexible outputs."""
|
9 |
+
try:
|
10 |
+
# Call pipeline
|
11 |
+
output = research_once(query)
|
12 |
+
|
13 |
+
# Handle cases with more than 5 return values
|
14 |
+
report = output[0] if len(output) > 0 else "No report generated."
|
15 |
+
citations = output[1] if len(output) > 1 else []
|
16 |
+
structures = output[2] if len(output) > 2 else []
|
17 |
+
graph_status = output[3] if len(output) > 3 else "No graph status."
|
18 |
+
image_url = output[4] if len(output) > 4 else None
|
19 |
|
20 |
+
# Generate narration
|
21 |
+
audio_path = narrate_text(report) or None
|
22 |
|
23 |
+
# Citations
|
24 |
+
cites_md = "### Citations\n"
|
25 |
+
if citations:
|
26 |
+
for cite in citations:
|
27 |
+
cites_md += f"- [{cite.get('type','Ref')} {cite.get('id','')}]({cite.get('url','#')})\n"
|
28 |
+
else:
|
29 |
+
cites_md += "_No citations found._\n"
|
30 |
|
31 |
+
# Structures
|
32 |
+
struct_md = "### Molecular Structures\n"
|
33 |
+
if structures:
|
34 |
+
for s in structures:
|
35 |
+
struct_md += f"- {s.get('term','Unknown')}: [{s.get('pdb_id','')}]({s.get('pdbe_url','#')}) ([RCSB]({s.get('rcsb_url','#')}))\n"
|
36 |
+
else:
|
37 |
+
struct_md += "_No structures found._\n"
|
38 |
|
39 |
+
# Image
|
40 |
+
img_md = "### Generated Visual\n"
|
41 |
+
if image_url:
|
42 |
+
img_md += f"\n"
|
43 |
+
else:
|
44 |
+
img_md += "_No visual generated._\n"
|
45 |
|
46 |
+
return report, cites_md, struct_md, graph_status, audio_path, img_md
|
47 |
|
48 |
+
except Exception as e:
|
49 |
+
return f"Error: {str(e)}", "", "", "", None, ""
|
50 |
|
51 |
+
# Gradio UI
|
52 |
with gr.Blocks(title="GENESIS-AI: Synthetic Biology Deep Research") as demo:
|
53 |
gr.Markdown("# 𧬠GENESIS-AI\nThe most advanced synthetic biology research assistant ever built.")
|
54 |
|
55 |
with gr.Row():
|
56 |
+
query_box = gr.Textbox(label="Enter a Research Topic", placeholder="e.g. CRISPR-based probiotics for cancer therapy")
|
57 |
+
run_btn = gr.Button("π Run Research", variant="primary")
|
58 |
|
59 |
with gr.Tab("π Report"):
|
60 |
report_out = gr.Textbox(label="Full Research Report", lines=20)
|