datdevsteve commited on
Commit
a128dff
·
verified ·
1 Parent(s): 2b8772d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -17
app.py CHANGED
@@ -1,22 +1,55 @@
1
  import gradio as gr
2
  from nivra_agent import nivra_chat
3
 
4
-
5
  def chat_fn(message, history):
6
- # DO NOT touch history
7
- # ChatInterface manages it internally
8
- return nivra_chat(message, history)
9
-
10
-
11
- demo = gr.ChatInterface(
12
- fn=chat_fn,
13
- title="🩺 Nivra AI Agent",
14
- description="Space to access Nivra's Agentic Interface",
15
- examples=[
16
- "I have fever and chills",
17
- "Patient presents skin rash and itching",
18
- "Patient presents stomach pain and vomiting",
19
- ],
20
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  from nivra_agent import nivra_chat
3
 
 
4
  def chat_fn(message, history):
5
+ history = history or []
6
+ response = nivra_chat(message, history)
7
+ history.append((message, response))
8
+ return history, ""
9
+
10
+ CSS = """
11
+ #chatbot {
12
+ height: 420px;
13
+ overflow-y: auto;
14
+ border-radius: 12px;
15
+ }
16
+ .gradio-container {
17
+ max-width: 900px !important;
18
+ margin: auto;
19
+ }
20
+ """
21
+
22
+ with gr.Blocks(css=CSS, title="🩺 Nivra AI Agent") as demo:
23
+ gr.Markdown(
24
+ """
25
+ # 🩺 Nivra AI Agent
26
+ _AI-powered healthcare assistant for preliminary medical guidance._
27
+ """
28
+ )
29
+
30
+ chatbot = gr.Chatbot(
31
+ elem_id="chatbot",
32
+ bubble_full_width=False,
33
+ show_label=False,
34
+ )
35
 
36
+ with gr.Row():
37
+ txt = gr.Textbox(
38
+ placeholder="Describe your symptoms (e.g. fever, headache, chills)...",
39
+ scale=8,
40
+ show_label=False,
41
+ )
42
+ send = gr.Button("Send", scale=1)
43
+
44
+ send.click(chat_fn, inputs=[txt, chatbot], outputs=[chatbot, txt])
45
+ txt.submit(chat_fn, inputs=[txt, chatbot], outputs=[chatbot, txt])
46
+
47
+ gr.Markdown(
48
+ "⚠️ *Not a doctor. For emergencies, consult a medical professional immediately.*"
49
+ )
50
+
51
+ demo.launch(
52
+ server_name="0.0.0.0",
53
+ server_port=7860,
54
+ ssr_mode=False, # 🔥 THIS fixes layout weirdness on HF
55
+ )