Spaces:
Sleeping
Sleeping
import gradio as gr | |
import random | |
from datetime import datetime | |
from genesis.pipeline import research_once | |
# --- Color scheme --- | |
PRIMARY_COLOR = "#00ff88" # Biotech green | |
SECONDARY_COLOR = "#ff8800" # Biotech orange | |
BG_COLOR = "#0b0f0c" # Dark lab background | |
# --- Demo queries --- | |
DEMO_QUERIES = { | |
"Literature & Regulatory Analysis": [ | |
"CRISPR living therapeutics in clinical trials since 2020", | |
"AI-designed enzymes for plastic degradation β literature + pathways", | |
], | |
"Molecule / Gene Explorer": [ | |
"BRCA1 structure and docking predictions", | |
"Spike protein mutations in SARS-CoV-2 β molecular modeling" | |
], | |
"Pathway Mapping": [ | |
"Metabolic pathway for artemisinin biosynthesis in yeast", | |
"Synthetic biology pathway for PHB bioplastic production" | |
], | |
"Funding Network": [ | |
"Synthetic biology startups in oncology β funding map", | |
"Venture capital in microbial biofactories since 2018" | |
], | |
"Microscopy & Image Analysis": [ | |
"Analyze fluorescence microscopy for cancer cell segmentation", | |
"Detect bacterial morphology in electron microscopy images" | |
] | |
} | |
# --- Function to run queries --- | |
def run_query(query): | |
if not query.strip(): | |
return "Please enter a query.", None, None | |
result = research_once(query) | |
return result["summary"], result.get("visual_image_url"), result.get("audio_url") | |
# --- Custom CSS for neon biotech theme --- | |
custom_css = f""" | |
body {{ | |
background-color: {BG_COLOR}; | |
}} | |
.gradio-container {{ | |
background: {BG_COLOR} !important; | |
color: white !important; | |
}} | |
button {{ | |
border-radius: 12px !important; | |
border: 2px solid {PRIMARY_COLOR} !important; | |
background-color: transparent !important; | |
color: {PRIMARY_COLOR} !important; | |
transition: 0.3s; | |
}} | |
button:hover {{ | |
background-color: {PRIMARY_COLOR} !important; | |
color: black !important; | |
box-shadow: 0px 0px 15px {PRIMARY_COLOR}; | |
}} | |
.particle-bg {{ | |
position: fixed; | |
width: 100%; | |
height: 100%; | |
z-index: -1; | |
background: radial-gradient(circle at center, {PRIMARY_COLOR}11, {BG_COLOR} 80%); | |
}} | |
.demo-chip {{ | |
display: inline-block; | |
padding: 8px 14px; | |
margin: 4px; | |
border-radius: 20px; | |
border: 1px solid {SECONDARY_COLOR}; | |
color: {SECONDARY_COLOR}; | |
cursor: pointer; | |
transition: 0.3s; | |
}} | |
.demo-chip:hover {{ | |
background-color: {SECONDARY_COLOR}; | |
color: black; | |
box-shadow: 0px 0px 10px {SECONDARY_COLOR}; | |
}} | |
""" | |
# --- Build UI --- | |
with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo: | |
gr.HTML(f"<div class='particle-bg'></div>") | |
gr.HTML(f"<h1 style='color:{PRIMARY_COLOR};text-align:center'>𧬠GENESIS-AI</h1>") | |
gr.HTML(f"<h3 style='color:{SECONDARY_COLOR};text-align:center'>The Synthetic Biology Brain</h3>") | |
with gr.Tabs(): | |
for mode, queries in DEMO_QUERIES.items(): | |
with gr.Tab(mode): | |
query_box = gr.Textbox(label=f"Enter your query for {mode}", placeholder="Type here...") | |
run_btn = gr.Button(f"Run {mode}") | |
result_text = gr.Textbox(label="Summary", lines=8) | |
result_image = gr.Image(label="Generated Diagram / Analysis", type="filepath") | |
result_audio = gr.Audio(label="Narrated Summary", type="filepath") | |
# Demo query chips | |
with gr.Row(): | |
for q in queries: | |
btn = gr.Button(q) | |
btn.click(fn=lambda x=q: (x,), outputs=query_box) | |
# Link run button | |
run_btn.click(fn=run_query, inputs=query_box, outputs=[result_text, result_image, result_audio]) | |
# Launch | |
if __name__ == "__main__": | |
demo.launch(server_name="0.0.0.0", server_port=7860) | |