Spaces:
Sleeping
Sleeping
# app.py | |
import gradio as gr | |
from genesis.pipeline import research_once | |
from genesis.molecule_viewer import get_molecule_view | |
# Preloaded demo queries for instant wow-factor | |
DEMO_QUERIES = [ | |
"CRISPR living therapeutics in clinical trials since 2020", | |
"AI-designed enzymes for plastic degradation β literature + pathways", | |
"Synthetic biology startups in oncology β funding map", | |
"Metabolic pathway for artemisinin biosynthesis in yeast", | |
"Oncolytic virus engineering β biosecurity risk analysis" | |
] | |
# ---- UI Functions ---- | |
def run_research(query): | |
result = research_once(query) | |
return ( | |
result["summary"], | |
"\n".join([f"{c['type']}: {c['url']}" for c in result["citations"]]), | |
result["visual_image_url"] or "No image", | |
result["audio_url"] or "No audio" | |
) | |
def explore_molecule(pdb_or_gene): | |
return get_molecule_view(pdb_or_gene) | |
# ---- UI Layout ---- | |
with gr.Blocks(css=".gradio-container {background-color: #0a0a0a; color: white;}") as demo: | |
gr.Markdown( | |
"<h1 style='color:#00ff99;text-shadow:0 0 20px #ff6600;'>𧬠GENESIS-AI: Synthetic Biology Command Center</h1>" | |
) | |
with gr.Tab("π Literature & Pathways"): | |
gr.Markdown("### Select a demo query or enter your own:") | |
with gr.Row(): | |
for q in DEMO_QUERIES: | |
gr.Button(q).click(fn=run_research, inputs=[gr.Textbox(value=q)], outputs=[ | |
gr.Textbox(label="Summary"), | |
gr.Textbox(label="Citations"), | |
gr.Image(label="Generated Diagram"), | |
gr.Audio(label="Narrated Summary") | |
]) | |
user_query = gr.Textbox(label="Custom Query") | |
submit_btn = gr.Button("Run Research") | |
summary = gr.Textbox(label="Summary") | |
citations = gr.Textbox(label="Citations") | |
diagram = gr.Image(label="Generated Diagram") | |
audio = gr.Audio(label="Narrated Summary") | |
submit_btn.click(fn=run_research, inputs=user_query, outputs=[summary, citations, diagram, audio]) | |
with gr.Tab("π§ͺ 3D Molecule Explorer"): | |
mol_input = gr.Textbox(label="Enter PDB ID or Gene/Protein Name") | |
mol_btn = gr.Button("Load Structure") | |
mol_view = gr.HTML(label="3D Structure") | |
mol_btn.click(fn=explore_molecule, inputs=mol_input, outputs=mol_view) | |
demo.launch() | |