Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,79 +1,59 @@
|
|
1 |
# app.py
|
2 |
import gradio as gr
|
3 |
-
from genesis.pipeline import research_once
|
|
|
4 |
|
|
|
5 |
def run_pipeline_ui(query):
|
6 |
-
"""Run the full GENESIS-AI pipeline for the given query."""
|
7 |
try:
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
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"
|
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 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
46 |
|
47 |
with gr.Row():
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
with gr.Row():
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
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=[
|
76 |
)
|
77 |
|
78 |
if __name__ == "__main__":
|
79 |
-
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
|
4 |
+
from genesis.pipeline import DEMO_QUERIES
|
5 |
|
6 |
+
# --------- UI Callback ---------
|
7 |
def run_pipeline_ui(query):
|
|
|
8 |
try:
|
9 |
+
report = research_once(query)
|
10 |
+
return (
|
11 |
+
report["summary"],
|
12 |
+
report["citations"],
|
13 |
+
report["structures"],
|
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 |
+
# --------- Gradio UI ---------
|
21 |
+
with gr.Blocks(title="GENESIS-AI β Synthetic Biology Research Engine") as demo:
|
22 |
+
gr.Markdown("## 𧬠GENESIS-AI β Synthetic Biology Research Engine")
|
23 |
+
gr.Markdown(
|
24 |
+
"Ask about synthetic biology, drug design, CRISPR, biosensors, and more."
|
25 |
+
)
|
26 |
|
27 |
with gr.Row():
|
28 |
+
query_input = gr.Textbox(
|
29 |
+
label="Enter your research topic",
|
30 |
+
placeholder="e.g., Design a CRISPR-based living therapeutic for triple-negative breast cancer",
|
31 |
+
lines=2
|
32 |
+
)
|
33 |
+
run_button = gr.Button("π Run Research", variant="primary")
|
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=[gr.Textbox(value=q, visible=False)],
|
48 |
+
outputs=[output_summary, output_citations, output_structures, output_image, output_audio]
|
49 |
+
)
|
50 |
+
|
51 |
+
# Main run button
|
52 |
+
run_button.click(
|
53 |
+
fn=run_pipeline_ui,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
inputs=[query_input],
|
55 |
+
outputs=[output_summary, output_citations, output_structures, output_image, output_audio]
|
56 |
)
|
57 |
|
58 |
if __name__ == "__main__":
|
59 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|