| | """ |
| | Check Pinecone index status and statistics |
| | Quick utility to inspect vector database |
| | """ |
| |
|
| | import os |
| | from dotenv import load_dotenv |
| | from pinecone import Pinecone |
| |
|
| | |
| | load_dotenv() |
| |
|
| | def check_pinecone_status(): |
| | """Display Pinecone index information""" |
| |
|
| | try: |
| | |
| | pc = Pinecone(api_key=os.getenv('PINECONE_API_KEY')) |
| | index_name = os.getenv('PINECONE_INDEX_NAME', 'hackathon') |
| | index = pc.Index(index_name) |
| |
|
| | |
| | stats = index.describe_index_stats() |
| |
|
| | print("="*80) |
| | print("PINECONE INDEX STATUS") |
| | print("="*80) |
| |
|
| | print(f"\n📊 Index Information:") |
| | print(f" Name: {index_name}") |
| | print(f" Total Vectors: {stats.get('total_vector_count', 0):,}") |
| | print(f" Dimensions: {stats.get('dimension', 'N/A')}") |
| |
|
| | |
| | if 'namespaces' in stats and stats['namespaces']: |
| | print(f"\n📁 Namespaces:") |
| | for ns_name, ns_stats in stats['namespaces'].items(): |
| | ns_display = ns_name if ns_name else "(default)" |
| | print(f" {ns_display}: {ns_stats.get('vector_count', 0):,} vectors") |
| |
|
| | |
| | print(f"\n⚙️ Configuration:") |
| | print(f" API Key: {os.getenv('PINECONE_API_KEY')[:10]}..." if os.getenv('PINECONE_API_KEY') else " API Key: Not set") |
| |
|
| | |
| | if stats.get('total_vector_count', 0) > 0: |
| | print(f"\n✅ Status: Connected and populated") |
| | else: |
| | print(f"\n⚠️ Status: Connected but empty") |
| |
|
| | except Exception as e: |
| | print("="*80) |
| | print("PINECONE CONNECTION ERROR") |
| | print("="*80) |
| | print(f"\n❌ Error: {e}") |
| | print("\nPlease check:") |
| | print(" 1. PINECONE_API_KEY in .env file") |
| | print(" 2. PINECONE_INDEX_NAME in .env file") |
| | print(" 3. Index exists in your Pinecone account") |
| |
|
| | if __name__ == "__main__": |
| | check_pinecone_status() |
| |
|