Features: - Vector search with Pinecone + Vertex AI embeddings - Document relationships (link, unlink, related, graph) - Auto-link with LLM analysis - Intelligent merge with Gemini Modular structure: - clients/: Pinecone, Vertex AI - tools/: core, relations, stats - utils/: validation, logging Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
28 lines
686 B
Python
28 lines
686 B
Python
"""Pinecone client singleton."""
|
|
from pinecone import Pinecone
|
|
from config import PINECONE_API_KEY, PINECONE_INDEX_NAME
|
|
from utils.logging import get_logger
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
# Pinecone singleton
|
|
_pc_client = None
|
|
_index = None
|
|
|
|
def get_index():
|
|
"""
|
|
Get Pinecone index instance (singleton pattern).
|
|
|
|
Returns:
|
|
Pinecone index instance
|
|
"""
|
|
global _pc_client, _index
|
|
|
|
if _index is None:
|
|
logger.info("Initializing Pinecone client")
|
|
_pc_client = Pinecone(api_key=PINECONE_API_KEY)
|
|
_index = _pc_client.Index(PINECONE_INDEX_NAME)
|
|
logger.info(f"Connected to Pinecone index: {PINECONE_INDEX_NAME}")
|
|
|
|
return _index
|