Spaces:
Sleeping
Sleeping
File size: 4,684 Bytes
7984ae1 2f85a76 48c2479 2f85a76 8cec585 2f85a76 7984ae1 2f85a76 8cec585 2f85a76 8cec585 2f85a76 8cec585 2f85a76 7984ae1 2f85a76 7984ae1 2f85a76 7984ae1 2f85a76 7984ae1 2f85a76 8cec585 2f85a76 7984ae1 8cec585 2f85a76 7984ae1 2f85a76 7984ae1 |
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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
import os
import gradio as gr
from genesis.pipeline import research_once
from genesis.visualization import generate_pathway_graph, generate_funding_network
# Environment variables
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
ELEVEN_LABS_API_KEY = os.getenv("ELEVEN_LABS_API_KEY")
# Preloaded demo queries
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"
]
# Custom LCARS biotech theme
CUSTOM_CSS = """
body {background-color: #001f1f; color: #ccffcc;}
.gradio-container {font-family: 'Orbitron', sans-serif;}
button {background-color: #ff6600 !important; color: white !important;}
textarea, input {background-color: #003333; color: #ccffcc;}
.tab-nav {background-color: #004d4d !important;}
"""
# -------------------- UI Functions -------------------- #
def run_text_query(query, narration):
result = research_once(query, narration=narration)
return (
result["summary"],
format_citations(result["citations"]),
result["visual_image_url"],
result["structures"],
result["audio_url"] if narration else None
)
def run_pathway_query(pathway_name):
return generate_pathway_graph(pathway_name)
def run_funding_query(topic):
return generate_funding_network(topic)
def format_citations(citations):
if not citations:
return "No citations found."
md = ""
for cite in citations:
md += f"- [{cite['type']}]({cite['url']})\n"
return md
# -------------------- Build UI -------------------- #
with gr.Blocks(css=CUSTOM_CSS, theme="default") as demo:
gr.Markdown("# 𧬠GENESIS-AI β Synthetic Biology Command Center")
gr.Markdown("**Multi-modal AI platform linking molecules, pathways, funding, and regulations**")
with gr.Tabs():
# ---------- TEXT QUERY TAB ----------
with gr.Tab("π Literature & Regulatory Analysis"):
narration = gr.Checkbox(label="Enable Narration", value=False)
text_input = gr.Textbox(label="Enter your query", placeholder="Type your synthetic biology research question...")
run_btn = gr.Button("Run Research")
demo_btns = gr.Row()
for q in DEMO_QUERIES:
demo_btns.add(gr.Button(q))
summary_out = gr.Textbox(label="Summary")
cites_out = gr.Markdown()
img_out = gr.Image(label="Generated Diagram")
struct_out = gr.JSON(label="Molecular Structures")
audio_out = gr.Audio(label="Narration", type="filepath")
run_btn.click(
fn=run_text_query,
inputs=[text_input, narration],
outputs=[summary_out, cites_out, img_out, struct_out, audio_out]
)
for q in DEMO_QUERIES:
demo_btns.children[DEMO_QUERIES.index(q)].click(
fn=run_text_query,
inputs=[gr.Textbox(value=q, visible=False), narration],
outputs=[summary_out, cites_out, img_out, struct_out, audio_out]
)
# ---------- PATHWAY TAB ----------
with gr.Tab("π§ͺ Metabolic Pathway Mapping"):
pathway_input = gr.Textbox(label="Pathway Name", placeholder="e.g., artemisinin biosynthesis")
pathway_btn = gr.Button("Generate Pathway Graph")
pathway_graph_out = gr.Image(label="Pathway Graph")
pathway_btn.click(run_pathway_query, inputs=pathway_input, outputs=pathway_graph_out)
# ---------- FUNDING TAB ----------
with gr.Tab("π° Funding & Investor Networks"):
funding_input = gr.Textbox(label="Topic", placeholder="e.g., synthetic biology oncology startups")
funding_btn = gr.Button("Generate Funding Map")
funding_graph_out = gr.Image(label="Funding Network")
funding_btn.click(run_funding_query, inputs=funding_input, outputs=funding_graph_out)
# ---------- IMAGE ANALYSIS TAB ----------
with gr.Tab("πΌοΈ Microscopy / Image Analysis"):
img_upload = gr.Image(type="filepath", label="Upload Image")
img_btn = gr.Button("Analyze Image")
img_analysis_out = gr.Textbox(label="Analysis Result")
# Hook to your vision model here
img_btn.click(lambda img: f"Analysis for {img}", inputs=img_upload, outputs=img_analysis_out)
demo.launch(server_name="0.0.0.0", server_port=7860)
|