Spaces:
Runtime error
Runtime error
| import asyncio | |
| import os | |
| import sys | |
| import numpy as np | |
| # Add server directory to path | |
| sys.path.append('/Users/mac/Projects/customerAgent/server') | |
| from app.services.vector_db import VectorDB | |
| from app.services.vector_operations import VectorOperations | |
| async def debug_search(): | |
| vdb = VectorDB() | |
| website_id = 19 | |
| query = "what Healthcare Services do you provide" | |
| print(f"π Debugging search for website {website_id}") | |
| print(f"π Query: \"{query}\"") | |
| if not vdb.load(website_id): | |
| print(f"β Failed to load index for website {website_id}") | |
| return | |
| embedding = await VectorOperations.get_embedding(query, is_query=True) | |
| query_vector = np.array(embedding, dtype=np.float32) | |
| # Search WITHOUT thresholds | |
| results = vdb.search(query_vector, website_id, k=8, min_score=0.0) | |
| print(f"\nπ Raw Results (min_score=0.0):") | |
| if not results: | |
| print(" No results found even with 0.0 threshold!") | |
| else: | |
| for i, (meta, score) in enumerate(results): | |
| text_preview = meta.get('text', '')[:60].replace('\n', ' ') | |
| print(f" [{i}] Score: {score:.4f} | Truth: {meta.get('truth_level')} | Priority: {meta.get('priority')} | Text: {text_preview}...") | |
| if __name__ == "__main__": | |
| asyncio.run(debug_search()) | |