IAMTFRMZA commited on
Commit
dda2dda
·
verified ·
1 Parent(s): 5338b7d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -14
app.py CHANGED
@@ -113,7 +113,8 @@ 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
- history.append((user_input, content))
 
117
  match = re.search(
118
  r'https://raw\\.githubusercontent\\.com/AndrewLORTech/surgical-pathology-manual/main/[\\w\\-/]*\\.png',
119
  content
@@ -130,6 +131,20 @@ def handle_chat(user_input, history, thread_id, image_url):
130
  with gr.Blocks(theme=gr.themes.Soft()) as app:
131
  gr.Markdown("# 📄 Document AI Assistant")
132
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  chat_state = gr.State([])
134
  thread_state = gr.State()
135
  image_state = gr.State()
@@ -140,8 +155,8 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
140
  with gr.Column(scale=1):
141
  image_display = gr.Image(label="🖼️ Document", type="filepath", show_download_button=False)
142
 
143
- with gr.Column(scale=1.4):
144
- chat = gr.Chatbot(label="💬 Chat", height=460)
145
 
146
  with gr.Row():
147
  user_prompt = gr.Textbox(placeholder="Ask your question...", show_label=False, scale=6)
@@ -184,14 +199,4 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
184
  outputs=[chat, voice_transcript, thread_state, image_state])
185
  app.load(fn=create_ws, outputs=[client_id])
186
 
187
- app.launch(css="""
188
- #ask-btn, #clear-chat-btn {
189
- font-size: 16px !important;
190
- padding: 10px 20px !important;
191
- }
192
- .record-button button {
193
- font-size: 16px !important;
194
- padding: 12px 24px !important;
195
- background-color: #f2f2f2;
196
- }
197
- """)
 
113
  for msg in reversed(msgs.data):
114
  if msg.role == "assistant":
115
  content = msg.content[0].text.value
116
+ history.append({"role": "user", "content": user_input})
117
+ history.append({"role": "assistant", "content": content})
118
  match = re.search(
119
  r'https://raw\\.githubusercontent\\.com/AndrewLORTech/surgical-pathology-manual/main/[\\w\\-/]*\\.png',
120
  content
 
131
  with gr.Blocks(theme=gr.themes.Soft()) as app:
132
  gr.Markdown("# 📄 Document AI Assistant")
133
 
134
+ gr.HTML("""
135
+ <style>
136
+ #ask-btn, #clear-chat-btn {
137
+ font-size: 16px !important;
138
+ padding: 10px 20px !important;
139
+ }
140
+ .record-button button {
141
+ font-size: 16px !important;
142
+ padding: 12px 24px !important;
143
+ background-color: #f2f2f2;
144
+ }
145
+ </style>
146
+ """)
147
+
148
  chat_state = gr.State([])
149
  thread_state = gr.State()
150
  image_state = gr.State()
 
155
  with gr.Column(scale=1):
156
  image_display = gr.Image(label="🖼️ Document", type="filepath", show_download_button=False)
157
 
158
+ with gr.Column(scale=2):
159
+ chat = gr.Chatbot(label="💬 Chat", height=460, type="messages")
160
 
161
  with gr.Row():
162
  user_prompt = gr.Textbox(placeholder="Ask your question...", show_label=False, scale=6)
 
199
  outputs=[chat, voice_transcript, thread_state, image_state])
200
  app.load(fn=create_ws, outputs=[client_id])
201
 
202
+ app.launch()