Issurance_Agent_Rag / test_model_loading.py
Rivalcoder
Add application file
e15840d
raw
history blame
921 Bytes
#!/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)