Spaces:
Running
Running
File size: 1,231 Bytes
721d500 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
"""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()
|