pinecone .config .pinecone_config
1from typing import Optional, Dict 2import logging 3import json 4import os 5from .config import ConfigBuilder, Config 6 7logger = logging.getLogger(__name__) 8""" @private """ 9 10DEFAULT_CONTROLLER_HOST = "https://api.pinecone.io" 11 12 13class PineconeConfig: 14 @staticmethod 15 def build( 16 api_key: Optional[str] = None, 17 host: Optional[str] = None, 18 additional_headers: Optional[Dict[str, str]] = {}, 19 **kwargs, 20 ) -> Config: 21 host = ( 22 host 23 or kwargs.get("host") 24 or os.getenv("PINECONE_CONTROLLER_HOST") 25 or DEFAULT_CONTROLLER_HOST 26 ) 27 headers_json = os.getenv("PINECONE_ADDITIONAL_HEADERS") 28 if headers_json: 29 try: 30 headers = json.loads(headers_json) 31 additional_headers = additional_headers or headers 32 except Exception as e: 33 logger.warn(f"Ignoring PINECONE_ADDITIONAL_HEADERS: {e}") 34 35 return ConfigBuilder.build( 36 api_key=api_key, host=host, additional_headers=additional_headers, **kwargs 37 )
DEFAULT_CONTROLLER_HOST =
'https://api.pinecone.io'
class
PineconeConfig:
14class PineconeConfig: 15 @staticmethod 16 def build( 17 api_key: Optional[str] = None, 18 host: Optional[str] = None, 19 additional_headers: Optional[Dict[str, str]] = {}, 20 **kwargs, 21 ) -> Config: 22 host = ( 23 host 24 or kwargs.get("host") 25 or os.getenv("PINECONE_CONTROLLER_HOST") 26 or DEFAULT_CONTROLLER_HOST 27 ) 28 headers_json = os.getenv("PINECONE_ADDITIONAL_HEADERS") 29 if headers_json: 30 try: 31 headers = json.loads(headers_json) 32 additional_headers = additional_headers or headers 33 except Exception as e: 34 logger.warn(f"Ignoring PINECONE_ADDITIONAL_HEADERS: {e}") 35 36 return ConfigBuilder.build( 37 api_key=api_key, host=host, additional_headers=additional_headers, **kwargs 38 )
@staticmethod
def
build( api_key: Optional[str] = None, host: Optional[str] = None, additional_headers: Optional[Dict[str, str]] = {}, **kwargs) -> pinecone.config.config.Config:
15 @staticmethod 16 def build( 17 api_key: Optional[str] = None, 18 host: Optional[str] = None, 19 additional_headers: Optional[Dict[str, str]] = {}, 20 **kwargs, 21 ) -> Config: 22 host = ( 23 host 24 or kwargs.get("host") 25 or os.getenv("PINECONE_CONTROLLER_HOST") 26 or DEFAULT_CONTROLLER_HOST 27 ) 28 headers_json = os.getenv("PINECONE_ADDITIONAL_HEADERS") 29 if headers_json: 30 try: 31 headers = json.loads(headers_json) 32 additional_headers = additional_headers or headers 33 except Exception as e: 34 logger.warn(f"Ignoring PINECONE_ADDITIONAL_HEADERS: {e}") 35 36 return ConfigBuilder.build( 37 api_key=api_key, host=host, additional_headers=additional_headers, **kwargs 38 )