Spaces:
Runtime error
Runtime error
| import asyncio | |
| import sys | |
| import os | |
| sys.path.insert(0, '.') | |
| async def test_specific_query(): | |
| from app.services.vector_db import VectorDB | |
| from app.services.vector_operations import VectorOperations | |
| import numpy as np | |
| vdb = VectorDB() | |
| loaded = vdb.load(22) | |
| print(f"Index loaded: {loaded}") | |
| query = "What programs / degrees does Iqra University offer?" | |
| # The E5 model needs 'query: ' prefix for queries | |
| query_with_prefix = f"query: {query}" | |
| query_emb = await VectorOperations.get_embedding(query) | |
| print("\n--- Testing with default min_score=0.3 ---") | |
| results = vdb.search( | |
| np.array(query_emb, dtype=np.float32), | |
| 22, | |
| k=8, | |
| min_score=0.3, | |
| min_truth_level=None | |
| ) | |
| print(f"Found {len(results)} results with min_score=0.3") | |
| for meta, score in results: | |
| print(f" Score: {score:.4f} | {meta.get('text', '')[:100]}...") | |
| print("\n--- Testing with min_score=0.0 to see raw scores ---") | |
| results_raw = vdb.search( | |
| np.array(query_emb, dtype=np.float32), | |
| 22, | |
| k=8, | |
| min_score=0.0, | |
| min_truth_level=None | |
| ) | |
| print(f"Found {len(results_raw)} results total") | |
| for meta, score in results_raw: | |
| print(f" Score: {score:.4f} | {meta.get('text', '')[:100]}...") | |
| if __name__ == "__main__": | |
| asyncio.run(test_specific_query()) | |