File size: 1,168 Bytes
1728e81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
35
36
37
38
39
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()