File size: 4,144 Bytes
1e9d8aa 3454584 1e9d8aa 3454584 1e9d8aa 3454584 1e9d8aa 3454584 aad31df 3454584 bcac0d3 3454584 1e9d8aa 3454584 faaca54 3454584 15503bb 3b1a51d 1e9d8aa 3454584 8e199b9 b51b657 8e199b9 3b1a51d 3454584 3b1a51d 788f0fa 3454584 8a09dd6 1e9d8aa 3454584 8a09dd6 1e9d8aa 3454584 1e9d8aa 3454584 1e9d8aa 3454584 |
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 |
"""
Gradio UI entry‑point for the WellBe+ Assistant.
This file focuses *exclusively* on building and launching the UI. Business
logic remains in ``wellbe_agent.py`` so that the web interface stays lean and
maintainable.
"""
from __future__ import annotations
import gradio as gr
from wellbe_agent import answer_sync
DESCRIPTION_MD = (
"WellBe+ AI Agent is a multi‑context assistant built with the Agents SDK framework "
"from OpenAI. It orchestrates **three secure MCP servers**: a public drug‑knowledge FDA "
"service, PubMed and WHOOP biometric feed.\n\n"
"Ask how medications, habits or workouts influence your sleep and recovery – the agent "
"combines **medical knowledge** with your **personal Whoop data** to craft evidence‑backed "
"answers.\n\n"
"### Example questions\n"
"- *What are the adverse effects of Tamoxifen?*\n"
"- *I started taking Prozac three months ago. Have you noticed any trends in my sleep quality? Also, what are its most common side effects?*\n\n"
"### MCP Servers in use\n"
"- [Whoop](https://huggingface.co/spaces/Agents-MCP-Hackathon/whoop-mcp-server)\n"
"- [Healthcare MCP with PubMed, FDA and other APIs](https://huggingface.co/spaces/Agents-MCP-Hackathon/healthcare-mcp-public)\n"
)
logo_html = """
<img src="https://raw.githubusercontent.com/Alea4jacta6est/drug-interaction-checker-agent/main/docs/images/logo.png"
alt="WellBe+" width="80">
<h1>WellBe+ Assistant</h1>
"""
def build_interface() -> gr.Blocks:
"""Construct and return the Gradio interface for the WellBe+ Assistant."""
custom_css = """
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600&display=swap');
* {
font-family: 'Nunito', sans-serif;
}
"""
with gr.Blocks(title="WellBe+ Assistant", css=custom_css) as app:
gr.HTML(logo_html) # Logo and title together
gr.Markdown("")
with gr.Row():
with gr.Column(scale=2):
gr.Markdown(DESCRIPTION_MD)
with gr.Column(scale=1):
gr.Markdown("### How to use")
gr.Video(value="docs/demo.mp4", autoplay=True)
with gr.Row():
# -----------------------------------------------------------------
# Left column – credential inputs
# -----------------------------------------------------------------
with gr.Column(scale=1):
gr.Markdown("### Credentials")
openai_key_box = gr.Textbox(
label="OpenAI API Key",
type="password",
placeholder="sk‑…",
)
whoop_email_box = gr.Textbox(label="Whoop e‑mail", type="password")
whoop_pass_box = gr.Textbox(label="Whoop password", type="password")
# -----------------------------------------------------------------
# Right column – chat interface
# -----------------------------------------------------------------
with gr.Column(scale=2):
gr.Markdown("### Chat")
question_box = gr.Textbox(
label="Question",
lines=3,
placeholder="e.g. How has my sleep changed since starting Prozac last month?",
)
answer_box = gr.Textbox(label="Assistant", lines=8, interactive=False)
ask_btn = gr.Button("Explore Insights", variant="primary")
ask_btn.click(
fn=answer_sync,
inputs=[
question_box,
openai_key_box,
whoop_email_box,
whoop_pass_box,
],
outputs=answer_box,
)
gr.Markdown(
"---\nBuilt by [Natalia B.](https://www.linkedin.com/in/natalia-bobkova/), [Victoria L.](https://www.linkedin.com/in/victoria-latynina/)"
)
return app
if __name__ == "__main__":
build_interface().launch()
|