11from tqdm .autonotebook import tqdm
22
33from collections .abc import Iterable
4- from typing import Union , List , Tuple , Optional , Dict , Any
4+ from typing import Mapping , Union , List , Tuple , Optional , Dict , Any
55
66from pinecone .config import ConfigBuilder
77
@@ -74,12 +74,12 @@ def __init__(
7474 api_key : str ,
7575 host : str ,
7676 pool_threads : Optional [int ] = 1 ,
77- additional_headers : Optional [Dict [str , str ]] = {},
77+ additional_headers : Optional [Mapping [str , str ]] = {},
7878 ** kwargs
7979 ):
8080 self ._config = ConfigBuilder .build (api_key = api_key , host = host , ** kwargs )
81-
82- api_client = ApiClient (configuration = self ._config .openapi_config ,
81+
82+ api_client = ApiClient (configuration = self ._config .openapi_config ,
8383 pool_threads = pool_threads )
8484
8585 # Configure request headers
@@ -90,7 +90,7 @@ def __init__(
9090
9191 self ._api_client = api_client
9292 self ._vector_api = VectorOperationsApi (api_client = api_client )
93-
93+
9494 def __enter__ (self ):
9595 return self
9696
@@ -245,7 +245,7 @@ def delete(
245245 ids : Optional [List [str ]] = None ,
246246 delete_all : Optional [bool ] = None ,
247247 namespace : Optional [str ] = None ,
248- filter : Optional [Dict [str , Union [str , float , int , bool , List , dict ]]] = None ,
248+ filter : Optional [Mapping [str , Union [str , float , int , bool , List , dict ]]] = None ,
249249 ** kwargs ,
250250 ) -> Dict [str , Any ]:
251251 """
@@ -272,7 +272,7 @@ def delete(
272272 Default is False.
273273 namespace (str): The namespace to delete vectors from [optional]
274274 If not specified, the default namespace is used.
275- filter (Dict [str, Union[str, float, int, bool, List, dict]]):
275+ filter (Mapping [str, Union[str, float, int, bool, List, dict]]):
276276 If specified, the metadata filter here will be used to select the vectors to delete.
277277 This is mutually exclusive with specifying ids to delete in the ids param or using delete_all=True.
278278 See https://www.pinecone.io/docs/metadata-filtering/.. [optional]
@@ -330,10 +330,10 @@ def query(
330330 vector : Optional [List [float ]] = None ,
331331 id : Optional [str ] = None ,
332332 namespace : Optional [str ] = None ,
333- filter : Optional [Dict [str , Union [str , float , int , bool , List , dict ]]] = None ,
333+ filter : Optional [Mapping [str , Union [str , float , int , bool , List , dict ]]] = None ,
334334 include_values : Optional [bool ] = None ,
335335 include_metadata : Optional [bool ] = None ,
336- sparse_vector : Optional [Union [SparseValues , Dict [str , Union [List [float ], List [int ]]]]] = None ,
336+ sparse_vector : Optional [Union [SparseValues , Mapping [str , Union [List [float ], List [int ]]]]] = None ,
337337 ** kwargs ,
338338 ) -> QueryResponse :
339339 """
@@ -362,17 +362,17 @@ def query(
362362 top_k (int): The number of results to return for each query. Must be an integer greater than 1.
363363 namespace (str): The namespace to fetch vectors from.
364364 If not specified, the default namespace is used. [optional]
365- filter (Dict [str, Union[str, float, int, bool, List, dict]):
365+ filter (Mapping [str, Union[str, float, int, bool, List, dict]):
366366 The filter to apply. You can use vector metadata to limit your search.
367367 See https://www.pinecone.io/docs/metadata-filtering/.. [optional]
368368 include_values (bool): Indicates whether vector values are included in the response.
369369 If omitted the server will use the default value of False [optional]
370370 include_metadata (bool): Indicates whether metadata is included in the response as well as the ids.
371371 If omitted the server will use the default value of False [optional]
372- sparse_vector: (Union[SparseValues, Dict [str, Union[List[float], List[int]]]]): sparse values of the query vector.
372+ sparse_vector: (Union[SparseValues, Mapping [str, Union[List[float], List[int]]]]): sparse values of the query vector.
373373 Expected to be either a SparseValues object or a dict of the form:
374374 {'indices': List[int], 'values': List[float]}, where the lists each have the same length.
375-
375+
376376 Returns: QueryResponse object which contains the list of the closest vectors as ScoredVector objects,
377377 and namespace name.
378378 """
@@ -414,9 +414,9 @@ def update(
414414 self ,
415415 id : str ,
416416 values : Optional [List [float ]] = None ,
417- set_metadata : Optional [Dict [str , Union [str , float , int , bool , List [int ], List [float ], List [str ]]]] = None ,
417+ set_metadata : Optional [Mapping [str , Union [str , float , int , bool , List [int ], List [float ], List [str ]]]] = None ,
418418 namespace : Optional [str ] = None ,
419- sparse_values : Optional [Union [SparseValues , Dict [str , Union [List [float ], List [int ]]]]] = None ,
419+ sparse_values : Optional [Union [SparseValues , Mapping [str , Union [List [float ], List [int ]]]]] = None ,
420420 ** kwargs ,
421421 ) -> Dict [str , Any ]:
422422 """
@@ -438,10 +438,10 @@ def update(
438438 Args:
439439 id (str): Vector's unique id.
440440 values (List[float]): vector values to set. [optional]
441- set_metadata (Dict [str, Union[str, float, int, bool, List[int], List[float], List[str]]]]):
441+ set_metadata (Mapping [str, Union[str, float, int, bool, List[int], List[float], List[str]]]]):
442442 metadata to set for vector. [optional]
443443 namespace (str): Namespace name where to update the vector.. [optional]
444- sparse_values: (Dict [str, Union[List[float], List[int]]]): sparse values to update for the vector.
444+ sparse_values: (Mapping [str, Union[List[float], List[int]]]): sparse values to update for the vector.
445445 Expected to be either a SparseValues object or a dict of the form:
446446 {'indices': List[int], 'values': List[float]} where the lists each have the same length.
447447
@@ -472,7 +472,7 @@ def update(
472472
473473 @validate_and_convert_errors
474474 def describe_index_stats (
475- self , filter : Optional [Dict [str , Union [str , float , int , bool , List , dict ]]] = None , ** kwargs
475+ self , filter : Optional [Mapping [str , Union [str , float , int , bool , List , dict ]]] = None , ** kwargs
476476 ) -> DescribeIndexStatsResponse :
477477 """
478478 The DescribeIndexStats operation returns statistics about the index's contents.
@@ -485,7 +485,7 @@ def describe_index_stats(
485485 >>> index.describe_index_stats(filter={'key': 'value'})
486486
487487 Args:
488- filter (Dict [str, Union[str, float, int, bool, List, dict]]):
488+ filter (Mapping [str, Union[str, float, int, bool, List, dict]]):
489489 If this parameter is present, the operation only returns statistics for vectors that satisfy the filter.
490490 See https://www.pinecone.io/docs/metadata-filtering/.. [optional]
491491
@@ -509,15 +509,15 @@ def _parse_non_empty_args(args: List[Tuple[str, Any]]) -> Dict[str, Any]:
509509
510510 @staticmethod
511511 def _parse_sparse_values_arg (
512- sparse_values : Optional [Union [SparseValues , Dict [str , Union [List [float ], List [int ]]]]]
512+ sparse_values : Optional [Union [SparseValues , Mapping [str , Union [List [float ], List [int ]]]]]
513513 ) -> Optional [SparseValues ]:
514514 if sparse_values is None :
515515 return None
516516
517517 if isinstance (sparse_values , SparseValues ):
518518 return sparse_values
519519
520- if not isinstance (sparse_values , dict ) or "indices" not in sparse_values or "values" not in sparse_values :
520+ if not isinstance (sparse_values , Mapping ) or "indices" not in sparse_values or "values" not in sparse_values :
521521 raise ValueError (
522522 "Invalid sparse values argument. Expected a dict of: {'indices': List[int], 'values': List[float]}."
523523 f"Received: { sparse_values } "
0 commit comments