File size: 2,378 Bytes
8cec585
48c2479
 
8cec585
 
 
 
 
 
 
 
 
 
 
 
 
48c2479
8cec585
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# 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()