Spaces:
Running
Running
#!/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) |