Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -305,8 +305,11 @@ When citing search results, mention the source, and ensure your answer reflects
|
|
305 |
if chunk_count <= 5:
|
306 |
print(f"Chunk {chunk_count}: {repr(chunk_content[:50])}")
|
307 |
|
308 |
-
# Yield
|
309 |
-
yield
|
|
|
|
|
|
|
310 |
|
311 |
except json.JSONDecodeError as e:
|
312 |
print(f"JSON decode error: {e}")
|
@@ -320,6 +323,7 @@ When citing search results, mention the source, and ensure your answer reflects
|
|
320 |
new_history[-1] = (message, full_response)
|
321 |
|
322 |
print(f"Final response length: {len(full_response)}")
|
|
|
323 |
yield new_history, ""
|
324 |
|
325 |
except requests.exceptions.RequestException as e:
|
@@ -338,7 +342,12 @@ When citing search results, mention the source, and ensure your answer reflects
|
|
338 |
new_history[-1] = (message, search_info + error_msg)
|
339 |
yield new_history, error_msg
|
340 |
|
341 |
-
#
|
|
|
|
|
|
|
|
|
|
|
342 |
with gr.Blocks(theme="soft", fill_height=True) as demo:
|
343 |
# Header section
|
344 |
gr.Markdown(
|
@@ -395,6 +404,7 @@ When citing search results, mention the source, and ensure your answer reflects
|
|
395 |
# Clear conversation button
|
396 |
with gr.Row():
|
397 |
clear = gr.ClearButton([msg, chatbot], value="🧹 Clear Conversation")
|
|
|
398 |
|
399 |
# Example queries
|
400 |
gr.Examples(
|
@@ -410,6 +420,13 @@ When citing search results, mention the source, and ensure your answer reflects
|
|
410 |
error_box = gr.Markdown("")
|
411 |
|
412 |
# Connect buttons to functions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
413 |
submit.click(
|
414 |
query_deepseek_streaming,
|
415 |
inputs=[msg, chatbot, use_deep_research],
|
@@ -438,5 +455,12 @@ When citing search results, mention the source, and ensure your answer reflects
|
|
438 |
# Run interface
|
439 |
if __name__ == "__main__":
|
440 |
demo = create_deepseek_interface()
|
441 |
-
demo.queue() #
|
442 |
-
demo.launch(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
if chunk_count <= 5:
|
306 |
print(f"Chunk {chunk_count}: {repr(chunk_content[:50])}")
|
307 |
|
308 |
+
# Yield less frequently to avoid overwhelming Gradio
|
309 |
+
# Only yield every 10 chunks or if it's a significant chunk
|
310 |
+
if chunk_count % 10 == 0 or len(chunk_content) > 50:
|
311 |
+
yield new_history, ""
|
312 |
+
time.sleep(0.01) # Small delay to prevent connection errors
|
313 |
|
314 |
except json.JSONDecodeError as e:
|
315 |
print(f"JSON decode error: {e}")
|
|
|
323 |
new_history[-1] = (message, full_response)
|
324 |
|
325 |
print(f"Final response length: {len(full_response)}")
|
326 |
+
# Always yield the final state
|
327 |
yield new_history, ""
|
328 |
|
329 |
except requests.exceptions.RequestException as e:
|
|
|
342 |
new_history[-1] = (message, search_info + error_msg)
|
343 |
yield new_history, error_msg
|
344 |
|
345 |
+
# Test function without streaming
|
346 |
+
def test_simple_response(message, history):
|
347 |
+
"""Simple test function to verify UI is working"""
|
348 |
+
print(f"Test function called with message: {message}")
|
349 |
+
new_history = history + [(message, f"Echo: {message}")]
|
350 |
+
return new_history, ""
|
351 |
with gr.Blocks(theme="soft", fill_height=True) as demo:
|
352 |
# Header section
|
353 |
gr.Markdown(
|
|
|
404 |
# Clear conversation button
|
405 |
with gr.Row():
|
406 |
clear = gr.ClearButton([msg, chatbot], value="🧹 Clear Conversation")
|
407 |
+
test_btn = gr.Button("🧪 Test Echo", variant="secondary")
|
408 |
|
409 |
# Example queries
|
410 |
gr.Examples(
|
|
|
420 |
error_box = gr.Markdown("")
|
421 |
|
422 |
# Connect buttons to functions
|
423 |
+
# Test button for debugging
|
424 |
+
test_btn.click(
|
425 |
+
test_simple_response,
|
426 |
+
inputs=[msg, chatbot],
|
427 |
+
outputs=[chatbot, error_box]
|
428 |
+
)
|
429 |
+
|
430 |
submit.click(
|
431 |
query_deepseek_streaming,
|
432 |
inputs=[msg, chatbot, use_deep_research],
|
|
|
455 |
# Run interface
|
456 |
if __name__ == "__main__":
|
457 |
demo = create_deepseek_interface()
|
458 |
+
demo.queue(max_size=10, concurrency_count=1) # Configure queue with limits
|
459 |
+
demo.launch(
|
460 |
+
debug=True,
|
461 |
+
share=False,
|
462 |
+
server_name="0.0.0.0",
|
463 |
+
server_port=7860,
|
464 |
+
ssr_mode=False,
|
465 |
+
show_error=True # Show detailed errors
|
466 |
+
)
|