import numpy as np import faiss import logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) def test_faiss(): try: # Create a small test index dimension = 64 nb = 100 # Generate random data xb = np.random.random((nb, dimension)).astype('float32') # Create index index = faiss.IndexFlatL2(dimension) # Add vectors index.add(xb) # Test search k = 5 xq = np.random.random((1, dimension)).astype('float32') D, I = index.search(xq, k) logger.info("FAISS test successful!") logger.info(f"Found {k} nearest neighbors") return True except Exception as e: logger.error(f"FAISS test failed: {str(e)}") return False import torch def test_torch(): try: x = torch.rand(5, 3) print("PyTorch is working correctly. Tensor:", x) except Exception as e: print("Error with PyTorch:", e) if __name__ == "__main__": test_faiss() test_torch()