import sys import os # Add the project root to the python path sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import logging from services.pinecone_service import PineconeService # Configure logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) def verify_connection(): try: print("="*60) print("Verifying Pinecone Connection...") print("="*60) # Initialize service - this will trigger the connection and index creation/checking logic service = PineconeService() # Get stats to confirm it's working stats = service.get_index_stats() print("\n[SUCCESS] Connected to Pinecone!") print(f"Index Stats: {stats}") print("\nConnection verification completed successfully.") print("="*60) return True except Exception as e: print(f"\n[ERROR] Failed to connect: {str(e)}") print("Please check your .env file and ensure PINECONE_API_KEY and other settings are correct.") print("="*60) return False if __name__ == "__main__": verify_connection()