Spaces:
Running
Running
File size: 921 Bytes
e15840d |
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 |
#!/usr/bin/env python3
"""
Test script to verify model loading works correctly
"""
import os
import sys
# Set up cache directory
cache_dir = os.path.join(os.getcwd(), ".cache")
os.makedirs(cache_dir, exist_ok=True)
os.environ['HF_HOME'] = cache_dir
os.environ['TRANSFORMERS_CACHE'] = cache_dir
print(f"Cache directory: {cache_dir}")
print(f"Current working directory: {os.getcwd()}")
try:
from embedder import get_model, build_faiss_index
print("Testing model loading...")
model = get_model()
print("✓ Model loaded successfully!")
# Test with some sample text
test_chunks = ["This is a test document.", "Another test sentence."]
print("Testing FAISS index building...")
index, texts = build_faiss_index(test_chunks)
print("✓ FAISS index built successfully!")
print("All tests passed!")
except Exception as e:
print(f"✗ Error: {e}")
sys.exit(1) |