Spaces:
Sleeping
A newer version of the Gradio SDK is available:
6.8.0
Debug to Production Guide
This document lists all debugging features added and how to remove them for production deployment.
Debug Features Added
1. Vectorization Query Logging (embeddings.py)
Location: backend/embeddings.py line 52
Debug Code:
logger.info(f"🔍 VECTORIZING QUERY STRING: '{query}'")
Purpose: Shows the exact string being vectorized for debugging vector search issues. To Remove: Delete line 52
2. Vector Search Results Display (chatbot_backend.py)
Location: Multiple locations in backend/chatbot_backend.py
a. Debug Method _format_vector_search_display (lines 80-117)
Purpose: Formats vector search results for display similar to initial RAG query To Remove: Delete the entire method
b. Debug Method _execute_tool_calls_with_display (lines 419-471)
Purpose: Executes tool calls and yields display content for vector search To Remove: Delete the entire method
c. Tool Execution Logic (lines 321-335)
Debug Code:
tool_results = []
for result in self._execute_tool_calls_with_display(tool_calls):
if result.get("display"):
# Yield display content
yield {
"type": "content",
"content": result["display"],
"done": False
}
else:
# Collect tool result
tool_results.append(result)
To Remove: Replace entire block with:
tool_results = self._execute_tool_calls(tool_calls)
d. Enhanced Status Message for vector_search (lines 264-267)
Debug Code:
if tool_name == "vector_search":
versions = tool_args.get('versions', [])
query = tool_args.get('query', '')
status_msg = f"\n🔍 Vector searching {', '.join(versions)} for: '{query}'...\n"
Purpose: Shows more detailed status including the query string To Remove: Can keep this as it's useful UX, or simplify to:
if tool_name == "vector_search":
status_msg = f"\n🔍 Using vector search tool...\n"
Production Deployment Steps
Remove debug logging in embeddings.py:
- Delete line 52 that logs the vectorization query string
Clean up chatbot_backend.py:
- Delete
_format_vector_search_displaymethod (lines 80-117) - Delete
_execute_tool_calls_with_displaymethod (lines 419-471) - Replace the debug tool execution block (lines 321-335) with:
tool_results = self._execute_tool_calls(tool_calls)
- Delete
Optional - Simplify status messages:
- Optionally simplify the vector_search status message
Remove test file:
- Delete
test_debug_output.py
- Delete
Summary
The debug features add visibility into:
- The exact query string being vectorized (useful for debugging search quality)
- The retrieved chunks from vector_search tool (similar to initial RAG display)
These features are helpful during development but add extra output that may not be desired in production. The core functionality remains unchanged - only the display/logging is affected.