Spaces:
Running
Running
Abid Ali Awan
commited on
Commit
·
45bd7ce
1
Parent(s):
33bbb87
refactor: Remove debug print statements and temporary textbox from file upload handling in the Gradio application, streamlining the output structure and enhancing clarity in error messaging.
Browse files
app.py
CHANGED
|
@@ -239,9 +239,7 @@ async def chat_send_stream(user_msg, history, file_url):
|
|
| 239 |
messages.append({"role": "assistant", "content": "🤔 Thinking..."})
|
| 240 |
|
| 241 |
# If no file, respond with error
|
| 242 |
-
print(f"DEBUG: chat_send_stream - file_url: {file_url}")
|
| 243 |
if not file_url:
|
| 244 |
-
print("DEBUG: No file URL found, showing error")
|
| 245 |
messages[-1] = {"role": "assistant", "content": "Upload a file first."}
|
| 246 |
yield messages
|
| 247 |
return
|
|
@@ -311,8 +309,6 @@ with gr.Blocks(title="MCP + GPT-5 mini - Streaming Chat") as demo:
|
|
| 311 |
|
| 312 |
# Internal file URL storage (hidden from UI)
|
| 313 |
file_url_state = gr.State(value=None)
|
| 314 |
-
# Temporary textbox for debugging
|
| 315 |
-
debug_file_url = gr.Textbox(label="Debug File URL", interactive=False)
|
| 316 |
|
| 317 |
# Use message format for better streaming support
|
| 318 |
chatbot = gr.Chatbot(
|
|
@@ -330,7 +326,7 @@ with gr.Blocks(title="MCP + GPT-5 mini - Streaming Chat") as demo:
|
|
| 330 |
uploader.change(
|
| 331 |
handle_upload,
|
| 332 |
inputs=[uploader],
|
| 333 |
-
outputs=[file_url_state
|
| 334 |
)
|
| 335 |
|
| 336 |
# Send button (streaming) - update chatbot and clear input
|
|
|
|
| 239 |
messages.append({"role": "assistant", "content": "🤔 Thinking..."})
|
| 240 |
|
| 241 |
# If no file, respond with error
|
|
|
|
| 242 |
if not file_url:
|
|
|
|
| 243 |
messages[-1] = {"role": "assistant", "content": "Upload a file first."}
|
| 244 |
yield messages
|
| 245 |
return
|
|
|
|
| 309 |
|
| 310 |
# Internal file URL storage (hidden from UI)
|
| 311 |
file_url_state = gr.State(value=None)
|
|
|
|
|
|
|
| 312 |
|
| 313 |
# Use message format for better streaming support
|
| 314 |
chatbot = gr.Chatbot(
|
|
|
|
| 326 |
uploader.change(
|
| 327 |
handle_upload,
|
| 328 |
inputs=[uploader],
|
| 329 |
+
outputs=[file_url_state],
|
| 330 |
)
|
| 331 |
|
| 332 |
# Send button (streaming) - update chatbot and clear input
|