Spaces:
Sleeping
Sleeping
File size: 2,891 Bytes
7ca7dca 86b948e 335600f 7ca7dca 335600f 7ca7dca 0f230a9 86b948e 0f230a9 86b948e 0f230a9 971e38a 0f230a9 86b948e 0f230a9 86b948e 0f230a9 86b948e 0f230a9 971e38a 0f230a9 7ca7dca e3c954b 0f230a9 7ca7dca e3c954b 335600f 86b948e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# app.py
import os
import gradio as gr
from genesis.pipeline import research_once
from genesis.narration import narrate_text
def run_pipeline_ui(query):
"""Run the full synthetic biology research pipeline and handle flexible outputs."""
try:
# Call pipeline
output = research_once(query)
# Handle cases with more than 5 return values
report = output[0] if len(output) > 0 else "No report generated."
citations = output[1] if len(output) > 1 else []
structures = output[2] if len(output) > 2 else []
graph_status = output[3] if len(output) > 3 else "No graph status."
image_url = output[4] if len(output) > 4 else None
# Generate narration
audio_path = narrate_text(report) or None
# Citations
cites_md = "### Citations\n"
if citations:
for cite in citations:
cites_md += f"- [{cite.get('type','Ref')} {cite.get('id','')}]({cite.get('url','#')})\n"
else:
cites_md += "_No citations found._\n"
# Structures
struct_md = "### Molecular Structures\n"
if structures:
for s in structures:
struct_md += f"- {s.get('term','Unknown')}: [{s.get('pdb_id','')}]({s.get('pdbe_url','#')}) ([RCSB]({s.get('rcsb_url','#')}))\n"
else:
struct_md += "_No structures found._\n"
# Image
img_md = "### Generated Visual\n"
if image_url:
img_md += f"\n"
else:
img_md += "_No visual generated._\n"
return report, cites_md, struct_md, graph_status, audio_path, img_md
except Exception as e:
return f"Error: {str(e)}", "", "", "", None, ""
# Gradio UI
with gr.Blocks(title="GENESIS-AI: Synthetic Biology Deep Research") as demo:
gr.Markdown("# 𧬠GENESIS-AI\nThe most advanced synthetic biology research assistant ever built.")
with gr.Row():
query_box = gr.Textbox(label="Enter a Research Topic", placeholder="e.g. CRISPR-based probiotics for cancer therapy")
run_btn = gr.Button("π Run Research", variant="primary")
with gr.Tab("π Report"):
report_out = gr.Textbox(label="Full Research Report", lines=20)
with gr.Tab("π Citations"):
cites_out = gr.Markdown()
with gr.Tab("π¬ Structures"):
struct_out = gr.Markdown()
with gr.Tab("πΈ Graph"):
graph_status_out = gr.Textbox(label="Graph DB Status")
with gr.Tab("π Narration"):
audio_out = gr.Audio(label="Narrated Summary")
with gr.Tab("πΌ Visual Diagram"):
img_out = gr.Markdown()
run_btn.click(
fn=run_pipeline_ui,
inputs=[query_box],
outputs=[report_out, cites_out, struct_out, graph_status_out, audio_out, img_out]
)
if __name__ == "__main__":
demo.launch()
|