Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
# app.py
|
2 |
import os
|
3 |
import time
|
4 |
import re
|
@@ -277,14 +276,14 @@ def check_connection(user_tz=None):
|
|
277 |
# UI
|
278 |
# -------------------
|
279 |
with gr.Blocks(theme=gr.themes.Default()) as demo:
|
280 |
-
#
|
281 |
-
|
282 |
|
283 |
-
# On load, capture browser timezone via JS and store in
|
284 |
demo.load(
|
285 |
fn=lambda tz: tz, # echo the JS value
|
286 |
inputs=None,
|
287 |
-
outputs=[
|
288 |
js="() => Intl.DateTimeFormat().resolvedOptions().timeZone"
|
289 |
)
|
290 |
|
@@ -303,20 +302,20 @@ with gr.Blocks(theme=gr.themes.Default()) as demo:
|
|
303 |
chat = gr.ChatInterface(
|
304 |
fn=chat_fn,
|
305 |
type="messages",
|
306 |
-
additional_inputs=[
|
307 |
description="A medical decision support system that provides healthcare-related information and decision making support.",
|
|
|
308 |
examples=[
|
309 |
["What are the symptoms of hypertension?", ""],
|
310 |
["What are common drug interactions with aspirin?", ""],
|
311 |
["What are the warning signs of diabetes?", ""],
|
312 |
],
|
313 |
-
cache_examples=
|
|
|
314 |
)
|
315 |
|
316 |
# Wire timezone into the connection check as well
|
317 |
-
btn.click(fn=check_connection, inputs=
|
318 |
|
319 |
if __name__ == "__main__":
|
320 |
demo.launch()
|
321 |
-
|
322 |
-
|
|
|
|
|
1 |
import os
|
2 |
import time
|
3 |
import re
|
|
|
276 |
# UI
|
277 |
# -------------------
|
278 |
with gr.Blocks(theme=gr.themes.Default()) as demo:
|
279 |
+
# Hidden textbox to hold browser timezone (Gradio expects components, not State)
|
280 |
+
tz_box = gr.Textbox(visible=False)
|
281 |
|
282 |
+
# On load, capture browser timezone via JS and store in tz_box
|
283 |
demo.load(
|
284 |
fn=lambda tz: tz, # echo the JS value
|
285 |
inputs=None,
|
286 |
+
outputs=[tz_box], # outputs must be a LIST of components
|
287 |
js="() => Intl.DateTimeFormat().resolvedOptions().timeZone"
|
288 |
)
|
289 |
|
|
|
302 |
chat = gr.ChatInterface(
|
303 |
fn=chat_fn,
|
304 |
type="messages",
|
305 |
+
additional_inputs=[tz_box], # pass timezone into chat_fn
|
306 |
description="A medical decision support system that provides healthcare-related information and decision making support.",
|
307 |
+
# Each example is [message, timezone]; second field is a dummy since tz comes from JS.
|
308 |
examples=[
|
309 |
["What are the symptoms of hypertension?", ""],
|
310 |
["What are common drug interactions with aspirin?", ""],
|
311 |
["What are the warning signs of diabetes?", ""],
|
312 |
],
|
313 |
+
cache_examples=True, # <- show examples on load (no precomputed outputs needed)
|
314 |
+
examples_per_page=3,
|
315 |
)
|
316 |
|
317 |
# Wire timezone into the connection check as well
|
318 |
+
btn.click(fn=check_connection, inputs=tz_box, outputs=status)
|
319 |
|
320 |
if __name__ == "__main__":
|
321 |
demo.launch()
|
|
|
|