IAMTFRMZA commited on
Commit
e4889b6
Β·
verified Β·
1 Parent(s): 84aaf41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -14
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
- # Detect image from GitHub
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: Document Image Display ----------
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
- # Link image preview if extracted
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():