mgbam commited on
Commit
6edcaf6
Β·
verified Β·
1 Parent(s): 247541a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -43
app.py CHANGED
@@ -1,59 +1,58 @@
1
  # app.py
2
  import gradio as gr
3
- from genesis.pipeline import research_once
4
- from genesis.pipeline import DEMO_QUERIES
5
 
6
- # --------- UI Callback ---------
7
  def run_pipeline_ui(query):
8
- try:
9
- report = research_once(query)
10
- return (
11
- report["summary"],
12
- report["citations"],
13
- report["structures"],
14
- report["visual_image_url"] or "No image generated",
15
- report["audio_url"] or None
16
- )
17
- except Exception as e:
18
- return f"Error: {e}", [], [], None, None
19
 
20
- # --------- Gradio UI ---------
21
- with gr.Blocks(title="GENESIS-AI β€” Synthetic Biology Research Engine") as demo:
22
- gr.Markdown("## 🧬 GENESIS-AI β€” Synthetic Biology Research Engine")
 
 
23
  gr.Markdown(
24
- "Ask about synthetic biology, drug design, CRISPR, biosensors, and more."
 
 
 
 
 
25
  )
26
-
27
  with gr.Row():
28
- query_input = gr.Textbox(
29
- label="Enter your research topic",
30
- placeholder="e.g., Design a CRISPR-based living therapeutic for triple-negative breast cancer",
31
- lines=2
32
- )
33
- run_button = gr.Button("πŸš€ Run Research", variant="primary")
34
-
35
- output_summary = gr.Textbox(label="Summary", lines=8)
36
- output_citations = gr.JSON(label="Citations")
37
- output_structures = gr.JSON(label="Molecular Structures")
38
- output_image = gr.Image(label="Generated Diagram / Image")
39
- output_audio = gr.Audio(label="Narration", type="filepath")
40
-
41
- # Demo Queries Section
42
- gr.Markdown("### Demo Queries")
43
  with gr.Row():
44
  for q in DEMO_QUERIES:
45
- gr.Button(q).click(
46
  fn=run_pipeline_ui,
47
- inputs=[gr.Textbox(value=q, visible=False)],
48
- outputs=[output_summary, output_citations, output_structures, output_image, output_audio]
49
  )
50
 
51
- # Main run button
52
- run_button.click(
 
 
 
 
 
 
 
 
 
53
  fn=run_pipeline_ui,
54
- inputs=[query_input],
55
- outputs=[output_summary, output_citations, output_structures, output_image, output_audio]
56
  )
57
 
58
- if __name__ == "__main__":
59
- demo.launch(server_name="0.0.0.0", server_port=7860)
 
1
  # app.py
2
  import gradio as gr
3
+ from genesis.pipeline import research_once, DEMO_QUERIES
 
4
 
 
5
  def run_pipeline_ui(query):
6
+ if not query.strip():
7
+ return "Please enter a research topic.", "", None, None
8
+ report = research_once(query)
9
+ summary = report["summary"]
10
+ citations_md = "\n".join(f"- [{c['type']}]({c['url']})" for c in report["citations"]) or "No citations found."
11
+ return summary, citations_md, report["visual_image_url"], report["audio_url"]
 
 
 
 
 
12
 
13
+ with gr.Blocks(theme=gr.themes.Soft(primary_hue="green", secondary_hue="blue"), css="""
14
+ .demo-btn {border-radius: 25px; padding: 8px 14px; font-weight: bold;}
15
+ .demo-btn:hover {background-color: #28a745 !important; color: white !important;}
16
+ """) as demo:
17
+
18
  gr.Markdown(
19
+ """
20
+ # 🧬 GENESIS-AI β€” Synthetic Biology Research Engine
21
+ Ask about **CRISPR**, drug design, biosensors, metabolic engineering, and more.
22
+ _Your AI co-pilot for disruptive biotech discovery._
23
+ """,
24
+ elem_id="title"
25
  )
26
+
27
  with gr.Row():
28
+ query_box = gr.Textbox(label="Enter Your Research Topic", placeholder="e.g., Design a CRISPR-based living therapeutic for triple-negative breast cancer", scale=4)
29
+ run_btn = gr.Button("πŸš€ Run Research", variant="primary", scale=1)
30
+
31
+ with gr.Row():
32
+ gr.Markdown("**Or try one of these expert-curated demo queries:**")
33
+
 
 
 
 
 
 
 
 
 
34
  with gr.Row():
35
  for q in DEMO_QUERIES:
36
+ gr.Button(q, elem_classes="demo-btn").click(
37
  fn=run_pipeline_ui,
38
+ inputs=gr.Textbox(value=q, visible=False),
39
+ outputs=["summary_out", "cites_out", "img_out", "audio_out"]
40
  )
41
 
42
+ with gr.Tab("πŸ“„ Summary"):
43
+ summary_out = gr.Textbox(label="Executive Summary", lines=15, interactive=False)
44
+ with gr.Tab("πŸ”— Citations"):
45
+ cites_out = gr.Markdown()
46
+ with gr.Tab("πŸ–Ό Diagram"):
47
+ img_out = gr.Image(type="filepath", label="Generated Research Diagram")
48
+ with gr.Tab("πŸ”Š Narration"):
49
+ audio_out = gr.Audio(type="filepath", label="AI Narration")
50
+
51
+ # Main run button event
52
+ run_btn.click(
53
  fn=run_pipeline_ui,
54
+ inputs=query_box,
55
+ outputs=[summary_out, cites_out, img_out, audio_out]
56
  )
57
 
58
+ demo.launch()