Spaces:
Running
Running
| """Test script to verify the vectorstore connection and retrieval""" | |
| from dotenv import load_dotenv | |
| from src.vectorstore import create_vectorstore | |
| # Load environment variables | |
| load_dotenv() | |
| print("Initializing vectorstore...") | |
| try: | |
| vectorstore = create_vectorstore() | |
| print("β Vectorstore created successfully") | |
| # Test with default threshold (should now get good matches with Jina-CLIP-v2) | |
| print("\nTesting similarity search with Jina-CLIP-v2 embeddings...") | |
| query = "data visualization storytelling narrative" | |
| results = vectorstore.similarity_search(query, k=5) | |
| print(f"\nβ Found {len(results)} documents") | |
| print("\nSample results:") | |
| for i, doc in enumerate(results[:3], 1): | |
| print(f"\n--- Document {i} ---") | |
| print(f"Source: {doc.metadata.get('source_id', 'Unknown')}") | |
| print(f"Type: {doc.metadata.get('source_type', 'N/A')}") | |
| print(f"Page: {doc.metadata.get('page_number', 'N/A')}") | |
| print(f"Content preview: {doc.page_content[:150]}...") | |
| print(f"Similarity: {doc.metadata.get('similarity', 'N/A')}") | |
| print("\nβ All tests passed!") | |
| except Exception as e: | |
| print(f"β Error: {e}") | |
| import traceback | |
| traceback.print_exc() | |