KarthiEz commited on
Commit
4dfba61
·
verified ·
1 Parent(s): 526e5ae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -234,6 +234,7 @@ def main():
234
  chatbot = gr.Chatbot(
235
  label="HunyuanOCR Chat",
236
  height=600,
 
237
  )
238
  user_input = gr.Textbox(
239
  label="Your question",
@@ -278,13 +279,13 @@ def main():
278
  # If nothing to do, return unchanged
279
  if (not text or not text.strip()) and not img_path:
280
  return chat_value, history_msgs, ""
281
-
282
  # 1) Build messages with new user turn
283
  messages = build_hunyuan_messages(history_msgs, text.strip(), img_path)
284
-
285
  # 2) Call model
286
  answer = call_local_model(messages)
287
-
288
  # 3) Append assistant turn to history
289
  messages.append(
290
  {
@@ -292,12 +293,10 @@ def main():
292
  "content": [{"type": "text", "text": answer}],
293
  }
294
  )
295
-
296
- # 4) Rebuild visible chat (list of (user, assistant) tuples)
297
- chat_display = rebuild_chat_display(messages)
298
-
299
- # 5) Return updated chat, messages, and clear textbox
300
- return chat_display, messages, ""
301
 
302
  send_btn.click(
303
  on_send,
 
234
  chatbot = gr.Chatbot(
235
  label="HunyuanOCR Chat",
236
  height=600,
237
+ type="messages", # ✅ explicitly say we are using messages format
238
  )
239
  user_input = gr.Textbox(
240
  label="Your question",
 
279
  # If nothing to do, return unchanged
280
  if (not text or not text.strip()) and not img_path:
281
  return chat_value, history_msgs, ""
282
+
283
  # 1) Build messages with new user turn
284
  messages = build_hunyuan_messages(history_msgs, text.strip(), img_path)
285
+
286
  # 2) Call model
287
  answer = call_local_model(messages)
288
+
289
  # 3) Append assistant turn to history
290
  messages.append(
291
  {
 
293
  "content": [{"type": "text", "text": answer}],
294
  }
295
  )
296
+
297
+ # 4) Return updated messages both to Chatbot and history_state
298
+ # Chatbot (type="messages") expects this format directly
299
+ return messages, messages, ""
 
 
300
 
301
  send_btn.click(
302
  on_send,