Spaces:
Sleeping
Sleeping
| # 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:** | |
| ```python | |
| 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:** | |
| ```python | |
| 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: | |
| ```python | |
| tool_results = self._execute_tool_calls(tool_calls) | |
| ``` | |
| #### d. Enhanced Status Message for vector_search (lines 264-267) | |
| **Debug Code:** | |
| ```python | |
| 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: | |
| ```python | |
| if tool_name == "vector_search": | |
| status_msg = f"\nπ Using vector search tool...\n" | |
| ``` | |
| ## Production Deployment Steps | |
| 1. **Remove debug logging in embeddings.py:** | |
| - Delete line 52 that logs the vectorization query string | |
| 2. **Clean up chatbot_backend.py:** | |
| - Delete `_format_vector_search_display` method (lines 80-117) | |
| - Delete `_execute_tool_calls_with_display` method (lines 419-471) | |
| - Replace the debug tool execution block (lines 321-335) with: | |
| ```python | |
| tool_results = self._execute_tool_calls(tool_calls) | |
| ``` | |
| 3. **Optional - Simplify status messages:** | |
| - Optionally simplify the vector_search status message | |
| 4. **Remove test file:** | |
| - Delete `test_debug_output.py` | |
| ## Summary | |
| The debug features add visibility into: | |
| 1. The exact query string being vectorized (useful for debugging search quality) | |
| 2. 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. |