IAMTFRMZA commited on
Commit
f06d67c
ยท
verified ยท
1 Parent(s): ec26bc2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -20
app.py CHANGED
@@ -113,9 +113,6 @@ def handle_chat(user_input, history, thread_id, image_url):
113
  for msg in reversed(msgs.data):
114
  if msg.role == "assistant":
115
  content = msg.content[0].text.value
116
- # Optional: prevent repeating fallback messages
117
- # if history and content == history[-1][1]:
118
- # content += "\n๐Ÿ” Try asking a different type of question!"
119
  history.append((user_input, content))
120
  match = re.search(
121
  r'https://raw\.githubusercontent\.com/AndrewLORTech/surgical-pathology-manual/main/[\w\-/]*\.png',
@@ -171,24 +168,15 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
171
  client_id = gr.State()
172
 
173
  with gr.Row(equal_height=True):
174
- with gr.Column(scale=0.8):
175
- image_display = gr.Image(
176
- label="๐Ÿ–ผ๏ธ Document",
177
- type="filepath",
178
- show_download_button=False,
179
- height=480 # taller preview
180
- )
181
-
182
- with gr.Column(elem_classes="voice-area"):
183
- gr.Markdown("### ๐ŸŽ™๏ธ Voice Input")
184
- voice_input = gr.Audio(label="Tap to Record", streaming=True, type="numpy", show_label=True)
185
- voice_transcript = gr.Textbox(label="Transcript", lines=2, interactive=False)
186
 
187
- with gr.Row(equal_height=True):
188
- with gr.Column(scale=1):
189
- voice_send_btn = gr.Button("๐ŸŸข Send Voice to Assistant", elem_classes="big-btn")
190
- with gr.Column(scale=1):
191
- clear_transcript_btn = gr.Button("๐Ÿงน Clear Transcript", elem_classes="big-btn")
 
 
 
192
 
193
  with gr.Column(scale=2):
194
  chat = gr.Chatbot(label="๐Ÿ’ฌ Chat", height=480)
@@ -200,6 +188,18 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
200
  with gr.Row():
201
  clear_chat_btn = gr.Button("๐Ÿ—‘๏ธ Clear Chat", elem_classes="big-btn")
202
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  # Bindings
204
  send_btn.click(fn=handle_chat,
205
  inputs=[user_prompt, chat_state, thread_state, image_state],
 
113
  for msg in reversed(msgs.data):
114
  if msg.role == "assistant":
115
  content = msg.content[0].text.value
 
 
 
116
  history.append((user_input, content))
117
  match = re.search(
118
  r'https://raw\.githubusercontent\.com/AndrewLORTech/surgical-pathology-manual/main/[\w\-/]*\.png',
 
168
  client_id = gr.State()
169
 
170
  with gr.Row(equal_height=True):
 
 
 
 
 
 
 
 
 
 
 
 
171
 
172
+ with gr.Column(scale=1):
173
+ with gr.Accordion("๐Ÿ“„ Document Viewer", open=True):
174
+ image_display = gr.Image(
175
+ label="๐Ÿ–ผ๏ธ Document",
176
+ type="filepath",
177
+ show_download_button=False,
178
+ height=480
179
+ )
180
 
181
  with gr.Column(scale=2):
182
  chat = gr.Chatbot(label="๐Ÿ’ฌ Chat", height=480)
 
188
  with gr.Row():
189
  clear_chat_btn = gr.Button("๐Ÿ—‘๏ธ Clear Chat", elem_classes="big-btn")
190
 
191
+ with gr.Column(scale=1):
192
+ with gr.Accordion("๐ŸŽ™๏ธ Voice Input", open=True):
193
+ gr.Markdown("### ๐ŸŽ™๏ธ Voice Input")
194
+ voice_input = gr.Audio(label="Tap to Record", streaming=True, type="numpy", show_label=True)
195
+ voice_transcript = gr.Textbox(label="Transcript", lines=2, interactive=False)
196
+
197
+ with gr.Row(equal_height=True):
198
+ with gr.Column(scale=1):
199
+ voice_send_btn = gr.Button("๐ŸŸข Send Voice to Assistant", elem_classes="big-btn")
200
+ with gr.Column(scale=1):
201
+ clear_transcript_btn = gr.Button("๐Ÿงน Clear Transcript", elem_classes="big-btn")
202
+
203
  # Bindings
204
  send_btn.click(fn=handle_chat,
205
  inputs=[user_prompt, chat_state, thread_state, image_state],