Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -65,7 +65,7 @@ def process_chat(message, history, session_id):
|
|
65 |
else:
|
66 |
assistant_response = "β οΈ Assistant did not respond."
|
67 |
|
68 |
-
#
|
69 |
image_url = None
|
70 |
match = re.search(r'https://raw\.githubusercontent\.com/AndrewLORTech/surgical-pathology-manual/main/[\w\-/]*\.png', assistant_response)
|
71 |
if match:
|
@@ -99,11 +99,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
99 |
session_id = gr.State(value=reset_session())
|
100 |
client_id = gr.State()
|
101 |
|
102 |
-
# ---------- Section 1:
|
103 |
-
with gr.Row():
|
104 |
-
image_display = gr.Image(label="π Document Page (auto-extracted if available)", interactive=False, visible=False)
|
105 |
-
|
106 |
-
# ---------- Section 2: Chat Interface ----------
|
107 |
with gr.Row():
|
108 |
chatbot = gr.ChatInterface(
|
109 |
fn=lambda message, history, session_id: (
|
@@ -118,14 +114,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
118 |
title="π¬ Document Assistant"
|
119 |
)
|
120 |
|
121 |
-
#
|
122 |
-
def update_image_display(message, history, session_id):
|
123 |
-
_, image_url = process_chat(message, history, session_id)
|
124 |
-
return gr.update(value=image_url, visible=bool(image_url))
|
125 |
-
|
126 |
-
chatbot.chatbot.change(fn=update_image_display, inputs=[chatbot.input, chatbot.chatbot, session_id], outputs=[image_display])
|
127 |
-
|
128 |
-
# ---------- Section 3: Voice Transcription ----------
|
129 |
gr.Markdown("## ποΈ Realtime Voice Transcription")
|
130 |
|
131 |
with gr.Row():
|
|
|
65 |
else:
|
66 |
assistant_response = "β οΈ Assistant did not respond."
|
67 |
|
68 |
+
# Optional: detect GitHub image URL
|
69 |
image_url = None
|
70 |
match = re.search(r'https://raw\.githubusercontent\.com/AndrewLORTech/surgical-pathology-manual/main/[\w\-/]*\.png', assistant_response)
|
71 |
if match:
|
|
|
99 |
session_id = gr.State(value=reset_session())
|
100 |
client_id = gr.State()
|
101 |
|
102 |
+
# ---------- Section 1: Chat Interface ----------
|
|
|
|
|
|
|
|
|
103 |
with gr.Row():
|
104 |
chatbot = gr.ChatInterface(
|
105 |
fn=lambda message, history, session_id: (
|
|
|
114 |
title="π¬ Document Assistant"
|
115 |
)
|
116 |
|
117 |
+
# ---------- Section 2: Voice Transcription ----------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
gr.Markdown("## ποΈ Realtime Voice Transcription")
|
119 |
|
120 |
with gr.Row():
|