Spaces:
Sleeping
Sleeping
# app.py | |
import gradio as gr | |
from genesis.pipeline import research_once, DEMO_QUERIES | |
def run_pipeline_ui(query): | |
"""Run the full GENESIS-AI pipeline for the given query.""" | |
try: | |
result = research_once(query) | |
summary_md = f"### Research Summary\n{result['summary']}" | |
cites_md = "### Citations\n" | |
if result["citations"]: | |
for c in result["citations"]: | |
cites_md += f"- [{c['type']} {c['id'] or ''}]({c['url']})\n" | |
else: | |
cites_md += "_No citations found._" | |
struct_md = "### Molecular Structures\n" | |
if result["structures"]: | |
for s in result["structures"]: | |
struct_md += f"- **{s['name']}** β [View]({s['url']})\n" | |
else: | |
struct_md += "_No structures found._" | |
img_md = "" | |
if result["visual_image_url"]: | |
img_md = f"### Visual Diagram\n" | |
audio_component = None | |
if result["audio_url"]: | |
audio_component = result["audio_url"] | |
return summary_md, cites_md, struct_md, img_md, audio_component | |
except Exception as e: | |
return f"**Error:** {e}", "", "", "", None | |
with gr.Blocks(title="GENESIS-AI β Synthetic Biology Research Engine", theme="default") as demo: | |
gr.Markdown("# 𧬠GENESIS-AI β Synthetic Biology Research Engine") | |
gr.Markdown("Ask about synthetic biology, drug design, CRISPR, biosensors, and more.") | |
with gr.Row(): | |
query_input = gr.Textbox(label="Enter your research topic", placeholder="e.g., AI-driven biosensor design for early cancer detection") | |
run_btn = gr.Button("Run Research", variant="primary") | |
with gr.Row(): | |
summary_output = gr.Markdown() | |
with gr.Row(): | |
cites_output = gr.Markdown() | |
with gr.Row(): | |
struct_output = gr.Markdown() | |
with gr.Row(): | |
img_output = gr.Markdown() | |
with gr.Row(): | |
audio_output = gr.Audio() | |
run_btn.click( | |
run_pipeline_ui, | |
inputs=[query_input], | |
outputs=[summary_output, cites_output, struct_output, img_output, audio_output] | |
) | |
gr.Markdown("## Demo Queries") | |
demo_gallery = gr.Dataset( | |
components=[gr.Textbox()], | |
samples=[[q] for q in DEMO_QUERIES], | |
type="values", | |
label="Click a demo query to run it" | |
) | |
demo_gallery.click( | |
run_pipeline_ui, | |
inputs=[query_input], | |
outputs=[summary_output, cites_output, struct_output, img_output, audio_output] | |
) | |
if __name__ == "__main__": | |
demo.launch(server_name="0.0.0.0", server_port=7860, share=True) | |