Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -122,15 +122,19 @@ with gr.Blocks() as demo:
|
|
| 122 |
with gr.Column(scale=1):
|
| 123 |
chat_img_input = gr.Image(type="pil", label="Document Attachment")
|
| 124 |
with gr.Column(scale=2):
|
| 125 |
-
#
|
| 126 |
-
chatbot = gr.Chatbot(label="Chat Interface", height=400)
|
| 127 |
with gr.Row():
|
| 128 |
chat_input = gr.Textbox(placeholder="Ask anything...", show_label=False)
|
| 129 |
send_btn = gr.Button("Send")
|
| 130 |
|
| 131 |
-
# REVERTED back to standard list of tuples format
|
| 132 |
def chat_wrapper(image, user_message, chat_history):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
ai_response = run_qwen(image, user_message, max_tokens=200)
|
|
|
|
| 134 |
chat_history.append((user_message, ai_response))
|
| 135 |
return "", chat_history
|
| 136 |
|
|
|
|
| 122 |
with gr.Column(scale=1):
|
| 123 |
chat_img_input = gr.Image(type="pil", label="Document Attachment")
|
| 124 |
with gr.Column(scale=2):
|
| 125 |
+
# ✨ THE FIX: We explicitly define type="tuples" so Gradio accepts our format without crashing
|
| 126 |
+
chatbot = gr.Chatbot(label="Chat Interface", height=400, type="tuples")
|
| 127 |
with gr.Row():
|
| 128 |
chat_input = gr.Textbox(placeholder="Ask anything...", show_label=False)
|
| 129 |
send_btn = gr.Button("Send")
|
| 130 |
|
|
|
|
| 131 |
def chat_wrapper(image, user_message, chat_history):
|
| 132 |
+
# Ensure chat_history is a list
|
| 133 |
+
if chat_history is None:
|
| 134 |
+
chat_history = []
|
| 135 |
+
|
| 136 |
ai_response = run_qwen(image, user_message, max_tokens=200)
|
| 137 |
+
# Appending as a tuple (user_message, ai_response) which matches type="tuples"
|
| 138 |
chat_history.append((user_message, ai_response))
|
| 139 |
return "", chat_history
|
| 140 |
|