Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,79 +1,79 @@
|
|
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
|
9 |
try:
|
10 |
-
|
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 |
-
|
21 |
-
audio_path = narrate_text(report) or None
|
22 |
-
|
23 |
-
# Citations
|
24 |
cites_md = "### Citations\n"
|
25 |
-
if citations:
|
26 |
-
for
|
27 |
-
cites_md += f"- [{
|
28 |
else:
|
29 |
-
cites_md += "_No citations found._
|
30 |
|
31 |
-
# Structures
|
32 |
struct_md = "### Molecular Structures\n"
|
33 |
-
if structures:
|
34 |
-
for s in structures:
|
35 |
-
struct_md += f"- {s
|
36 |
else:
|
37 |
-
struct_md += "_No structures found._
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
img_md += f"\n"
|
43 |
-
else:
|
44 |
-
img_md += "_No visual generated._\n"
|
45 |
|
46 |
-
|
|
|
|
|
|
|
|
|
47 |
|
48 |
except Exception as e:
|
49 |
-
return f"Error
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
57 |
-
run_btn = gr.Button("
|
58 |
|
59 |
-
with gr.
|
60 |
-
|
61 |
-
with gr.
|
62 |
-
|
63 |
-
with gr.
|
64 |
-
|
65 |
-
with gr.
|
66 |
-
|
67 |
-
with gr.
|
68 |
-
|
69 |
-
with gr.Tab("πΌ Visual Diagram"):
|
70 |
-
img_out = gr.Markdown()
|
71 |
|
72 |
run_btn.click(
|
73 |
-
|
74 |
-
inputs=[
|
75 |
-
outputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
)
|
77 |
|
78 |
if __name__ == "__main__":
|
79 |
-
demo.launch()
|
|
|
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 |
+
"""Run the full GENESIS-AI pipeline for the given query."""
|
7 |
try:
|
8 |
+
result = research_once(query)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
summary_md = f"### Research Summary\n{result['summary']}"
|
|
|
|
|
|
|
11 |
cites_md = "### Citations\n"
|
12 |
+
if result["citations"]:
|
13 |
+
for c in result["citations"]:
|
14 |
+
cites_md += f"- [{c['type']} {c['id'] or ''}]({c['url']})\n"
|
15 |
else:
|
16 |
+
cites_md += "_No citations found._"
|
17 |
|
|
|
18 |
struct_md = "### Molecular Structures\n"
|
19 |
+
if result["structures"]:
|
20 |
+
for s in result["structures"]:
|
21 |
+
struct_md += f"- **{s['name']}** β [View]({s['url']})\n"
|
22 |
else:
|
23 |
+
struct_md += "_No structures found._"
|
24 |
|
25 |
+
img_md = ""
|
26 |
+
if result["visual_image_url"]:
|
27 |
+
img_md = f"### Visual Diagram\n"
|
|
|
|
|
|
|
28 |
|
29 |
+
audio_component = None
|
30 |
+
if result["audio_url"]:
|
31 |
+
audio_component = result["audio_url"]
|
32 |
+
|
33 |
+
return summary_md, cites_md, struct_md, img_md, audio_component
|
34 |
|
35 |
except Exception as e:
|
36 |
+
return f"**Error:** {e}", "", "", "", None
|
37 |
+
|
38 |
+
|
39 |
+
with gr.Blocks(title="GENESIS-AI β Synthetic Biology Research Engine", theme="default") as demo:
|
40 |
+
gr.Markdown("# 𧬠GENESIS-AI β Synthetic Biology Research Engine")
|
41 |
+
gr.Markdown("Ask about synthetic biology, drug design, CRISPR, biosensors, and more.")
|
42 |
|
|
|
|
|
|
|
|
|
43 |
with gr.Row():
|
44 |
+
query_input = gr.Textbox(label="Enter your research topic", placeholder="e.g., AI-driven biosensor design for early cancer detection")
|
45 |
+
run_btn = gr.Button("Run Research", variant="primary")
|
46 |
|
47 |
+
with gr.Row():
|
48 |
+
summary_output = gr.Markdown()
|
49 |
+
with gr.Row():
|
50 |
+
cites_output = gr.Markdown()
|
51 |
+
with gr.Row():
|
52 |
+
struct_output = gr.Markdown()
|
53 |
+
with gr.Row():
|
54 |
+
img_output = gr.Markdown()
|
55 |
+
with gr.Row():
|
56 |
+
audio_output = gr.Audio()
|
|
|
|
|
57 |
|
58 |
run_btn.click(
|
59 |
+
run_pipeline_ui,
|
60 |
+
inputs=[query_input],
|
61 |
+
outputs=[summary_output, cites_output, struct_output, img_output, audio_output]
|
62 |
+
)
|
63 |
+
|
64 |
+
gr.Markdown("## Demo Queries")
|
65 |
+
demo_gallery = gr.Dataset(
|
66 |
+
components=[gr.Textbox()],
|
67 |
+
samples=[[q] for q in DEMO_QUERIES],
|
68 |
+
type="values",
|
69 |
+
label="Click a demo query to run it"
|
70 |
+
)
|
71 |
+
|
72 |
+
demo_gallery.click(
|
73 |
+
run_pipeline_ui,
|
74 |
+
inputs=[query_input],
|
75 |
+
outputs=[summary_output, cites_output, struct_output, img_output, audio_output]
|
76 |
)
|
77 |
|
78 |
if __name__ == "__main__":
|
79 |
+
demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
|