File size: 2,645 Bytes
7ca7dca
335600f
45a73fa
335600f
7ca7dca
45a73fa
0f230a9
45a73fa
86b948e
45a73fa
0f230a9
45a73fa
 
 
0f230a9
45a73fa
971e38a
0f230a9
45a73fa
 
 
0f230a9
45a73fa
86b948e
45a73fa
 
 
86b948e
45a73fa
 
 
 
 
86b948e
0f230a9
45a73fa
 
 
 
 
 
971e38a
e3c954b
45a73fa
 
7ca7dca
45a73fa
 
 
 
 
 
 
 
 
 
7ca7dca
 
45a73fa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e3c954b
335600f
 
45a73fa
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 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![]({result['visual_image_url']})"

        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)