diff --git a/pinecone/core/client/api/index_operations_api.py b/pinecone/core/client/api/index_operations_api.py index 2ee2c2546..0b2f9a9fe 100644 --- a/pinecone/core/client/api/index_operations_api.py +++ b/pinecone/core/client/api/index_operations_api.py @@ -52,7 +52,7 @@ def __configure_index( ): """configure_index # noqa: E501 - Configure index to change pod type and number of replicas. # noqa: E501 + This operation specifies the pod type and number of replicas for an index. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True @@ -63,7 +63,7 @@ def __configure_index( index_name (str): The name of the index Keyword Args: - patch_request (PatchRequest): The desired configuration changes for the index.. [optional] + patch_request (PatchRequest): The desired pod type and replica configuration for the index.. [optional] _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object diff --git a/pinecone/core/client/api/vector_operations_api.py b/pinecone/core/client/api/vector_operations_api.py index 846b83388..70f8bb98a 100644 --- a/pinecone/core/client/api/vector_operations_api.py +++ b/pinecone/core/client/api/vector_operations_api.py @@ -303,7 +303,7 @@ def __describe_index_stats( ): """DescribeIndexStats # noqa: E501 - The `DescribeIndexStats` operation returns statistics about the index's contents. For example: The vector count per namespace and the number of dimensions. # noqa: E501 + The `DescribeIndexStats` operation returns statistics about the index's contents, including the vector count per namespace, the number of dimensions, and the index fullness. The index fullness result may be inaccurate during pod resizing; to get the status of a pod resizing process, use [`describe_index`](https://www.pinecone.io/docs/api/operation/describe_index/). # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True @@ -422,7 +422,7 @@ def __describe_index_stats1( ): """DescribeIndexStats # noqa: E501 - The `DescribeIndexStats` operation returns statistics about the index's contents. For example: The vector count per namespace and the number of dimensions. # noqa: E501 + The `DescribeIndexStats` operation returns statistics about the index's contents, including the vector count per namespace, the number of dimensions, and the index fullness. The index fullness result may be inaccurate during pod resizing; to get the status of a pod resizing process, use [`describe_index`](https://www.pinecone.io/docs/api/operation/describe_index/). # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True diff --git a/pinecone/core/client/model/create_request.py b/pinecone/core/client/model/create_request.py index 58b388d38..eb51b0693 100644 --- a/pinecone/core/client/model/create_request.py +++ b/pinecone/core/client/model/create_request.py @@ -168,7 +168,7 @@ def _from_openapi_data(cls, name, dimension, *args, **kwargs): # noqa: E501 pods (int): The number of pods for the index to use,including replicas.. [optional] if omitted the server will use the default value of 1 # noqa: E501 replicas (int): The number of replicas. Replicas duplicate your index. They provide higher availability and throughput.. [optional] if omitted the server will use the default value of 1 # noqa: E501 shards (int): The number of shards to be used in the index.. [optional] if omitted the server will use the default value of 1 # noqa: E501 - pod_type (str): The type of pod to use. One of 's1' or 'p1'.. [optional] if omitted the server will use the default value of "p1" # noqa: E501 + pod_type (str): The type of pod to use. One of `s1`, `p1`, or `p2` appended with `.` and one of `x1`, `x2`, `x4`, or `x8`.. [optional] if omitted the server will use the default value of "p1.x1" # noqa: E501 index_config (dict): [optional] # noqa: E501 metadata_config ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type): Configuration for the behavior of Pinecone's internal metadata index. By default, all metadata is indexed; when `metadata_config` is present, only specified metadata fields are indexed. To specify metadata fields to index, provide a JSON object of the following form: ``` {\"indexed\": [\"example_metadata_field\"]} ``` . [optional] # noqa: E501 source_collection (str): The name of the collection to create an index from. [optional] # noqa: E501 @@ -264,7 +264,7 @@ def __init__(self, name, dimension, *args, **kwargs): # noqa: E501 pods (int): The number of pods for the index to use,including replicas.. [optional] if omitted the server will use the default value of 1 # noqa: E501 replicas (int): The number of replicas. Replicas duplicate your index. They provide higher availability and throughput.. [optional] if omitted the server will use the default value of 1 # noqa: E501 shards (int): The number of shards to be used in the index.. [optional] if omitted the server will use the default value of 1 # noqa: E501 - pod_type (str): The type of pod to use. One of 's1' or 'p1'.. [optional] if omitted the server will use the default value of "p1" # noqa: E501 + pod_type (str): The type of pod to use. One of `s1`, `p1`, or `p2` appended with `.` and one of `x1`, `x2`, `x4`, or `x8`.. [optional] if omitted the server will use the default value of "p1.x1" # noqa: E501 index_config (dict): [optional] # noqa: E501 metadata_config ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type): Configuration for the behavior of Pinecone's internal metadata index. By default, all metadata is indexed; when `metadata_config` is present, only specified metadata fields are indexed. To specify metadata fields to index, provide a JSON object of the following form: ``` {\"indexed\": [\"example_metadata_field\"]} ``` . [optional] # noqa: E501 source_collection (str): The name of the collection to create an index from. [optional] # noqa: E501 diff --git a/pinecone/core/client/model/index_meta_database.py b/pinecone/core/client/model/index_meta_database.py index 4baf55557..d2fe4d398 100644 --- a/pinecone/core/client/model/index_meta_database.py +++ b/pinecone/core/client/model/index_meta_database.py @@ -101,6 +101,7 @@ def openapi_types(): 'shards': (int,), # noqa: E501 'pod_type': (str,), # noqa: E501 'index_config': (dict,), # noqa: E501 + 'metadata_config': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 'status': (IndexMetaDatabaseStatus,), # noqa: E501 } @@ -119,6 +120,7 @@ def discriminator(): 'shards': 'shards', # noqa: E501 'pod_type': 'pod_type', # noqa: E501 'index_config': 'index_config', # noqa: E501 + 'metadata_config': 'metadata_config', # noqa: E501 'status': 'status', # noqa: E501 } @@ -172,6 +174,7 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 shards (int): [optional] # noqa: E501 pod_type (str): [optional] # noqa: E501 index_config (dict): [optional] # noqa: E501 + metadata_config ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): [optional] # noqa: E501 status (IndexMetaDatabaseStatus): [optional] # noqa: E501 """ @@ -263,6 +266,7 @@ def __init__(self, *args, **kwargs): # noqa: E501 shards (int): [optional] # noqa: E501 pod_type (str): [optional] # noqa: E501 index_config (dict): [optional] # noqa: E501 + metadata_config ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): [optional] # noqa: E501 status (IndexMetaDatabaseStatus): [optional] # noqa: E501 """ diff --git a/pinecone/core/client/model/patch_request.py b/pinecone/core/client/model/patch_request.py index 45a5135b0..85b66d121 100644 --- a/pinecone/core/client/model/patch_request.py +++ b/pinecone/core/client/model/patch_request.py @@ -142,7 +142,7 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 through its discriminator because we passed in _visited_composed_classes = (Animal,) replicas (int): The desired number of replicas for the index.. [optional] # noqa: E501 - pod_type (str): The new pod type for the index.. [optional] # noqa: E501 + pod_type (str): The new pod type for the index. One of `s1`, `p1`, or `p2` appended with `.` and one of `x1`, `x2`, `x4`, or `x8`.. [optional] # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) @@ -225,7 +225,7 @@ def __init__(self, *args, **kwargs): # noqa: E501 through its discriminator because we passed in _visited_composed_classes = (Animal,) replicas (int): The desired number of replicas for the index.. [optional] # noqa: E501 - pod_type (str): The new pod type for the index.. [optional] # noqa: E501 + pod_type (str): The new pod type for the index. One of `s1`, `p1`, or `p2` appended with `.` and one of `x1`, `x2`, `x4`, or `x8`.. [optional] # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) diff --git a/pinecone/core/client/model/query_request.py b/pinecone/core/client/model/query_request.py index dee6245f8..8cff6795d 100644 --- a/pinecone/core/client/model/query_request.py +++ b/pinecone/core/client/model/query_request.py @@ -36,7 +36,9 @@ def lazy_import(): from pinecone.core.client.model.query_vector import QueryVector + from pinecone.core.client.model.sparse_values import SparseValues globals()['QueryVector'] = QueryVector + globals()['SparseValues'] = SparseValues class QueryRequest(ModelNormal): @@ -110,6 +112,7 @@ def openapi_types(): 'include_metadata': (bool,), # noqa: E501 'queries': ([QueryVector],), # noqa: E501 'vector': ([float],), # noqa: E501 + 'sparse_vector': (SparseValues,), # noqa: E501 'id': (str,), # noqa: E501 } @@ -126,6 +129,7 @@ def discriminator(): 'include_metadata': 'includeMetadata', # noqa: E501 'queries': 'queries', # noqa: E501 'vector': 'vector', # noqa: E501 + 'sparse_vector': 'sparseVector', # noqa: E501 'id': 'id', # noqa: E501 } @@ -179,6 +183,7 @@ def _from_openapi_data(cls, top_k, *args, **kwargs): # noqa: E501 include_metadata (bool): Indicates whether metadata is included in the response as well as the ids.. [optional] if omitted the server will use the default value of False # noqa: E501 queries ([QueryVector]): DEPRECATED. The query vectors. Each `query()` request can contain only one of the parameters `queries`, `vector`, or `id`.. [optional] # noqa: E501 vector ([float]): The query vector. This should be the same length as the dimension of the index being queried. Each `query()` request can contain only one of the parameters `id` or `vector`.. [optional] # noqa: E501 + sparse_vector (SparseValues): [optional] # noqa: E501 id (str): The unique ID of the vector to be used as a query vector. Each `query()` request can contain only one of the parameters `queries`, `vector`, or `id`.. [optional] # noqa: E501 """ @@ -271,6 +276,7 @@ def __init__(self, top_k, *args, **kwargs): # noqa: E501 include_metadata (bool): Indicates whether metadata is included in the response as well as the ids.. [optional] if omitted the server will use the default value of False # noqa: E501 queries ([QueryVector]): DEPRECATED. The query vectors. Each `query()` request can contain only one of the parameters `queries`, `vector`, or `id`.. [optional] # noqa: E501 vector ([float]): The query vector. This should be the same length as the dimension of the index being queried. Each `query()` request can contain only one of the parameters `id` or `vector`.. [optional] # noqa: E501 + sparse_vector (SparseValues): The sparse values of the query vector [optional] # noqa: E501 id (str): The unique ID of the vector to be used as a query vector. Each `query()` request can contain only one of the parameters `queries`, `vector`, or `id`.. [optional] # noqa: E501 """ @@ -308,4 +314,4 @@ def __init__(self, top_k, *args, **kwargs): # noqa: E501 setattr(self, var_name, var_value) if var_name in self.read_only_vars: raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes.") + f"class with read only attributes.") diff --git a/pinecone/core/client/model/query_vector.py b/pinecone/core/client/model/query_vector.py index 46976f561..72e799b86 100644 --- a/pinecone/core/client/model/query_vector.py +++ b/pinecone/core/client/model/query_vector.py @@ -34,6 +34,10 @@ from pinecone.core.client.exceptions import ApiAttributeError +def lazy_import(): + from pinecone.core.client.model.sparse_values import SparseValues + globals()['SparseValues'] = SparseValues + class QueryVector(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. @@ -77,6 +81,7 @@ def additional_properties_type(): This must be a method because a model may have properties that are of type self, this must run after the class is loaded """ + lazy_import() return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -91,8 +96,10 @@ def openapi_types(): openapi_types (dict): The key is attribute name and the value is attribute type. """ + lazy_import() return { 'values': ([float],), # noqa: E501 + 'sparse_values': (SparseValues,), # noqa: E501 'top_k': (int,), # noqa: E501 'namespace': (str,), # noqa: E501 'filter': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 @@ -105,6 +112,7 @@ def discriminator(): attribute_map = { 'values': 'values', # noqa: E501 + 'sparse_values': 'sparseValues', # noqa: E501 'top_k': 'topK', # noqa: E501 'namespace': 'namespace', # noqa: E501 'filter': 'filter', # noqa: E501 @@ -154,6 +162,7 @@ def _from_openapi_data(cls, values, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) + sparse_values (SparseValues): The sparse data of the query vector [optional] # noqa: E501 top_k (int): An override for the number of results to return for this query vector.. [optional] # noqa: E501 namespace (str): An override the namespace to search.. [optional] # noqa: E501 filter ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): An override for the metadata filter to apply. This replaces the request-level filter.. [optional] # noqa: E501 @@ -242,6 +251,7 @@ def __init__(self, values, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) + sparse_values (SparseValues): This is the sparse data of the vector [optional] # noqa: E501 top_k (int): An override for the number of results to return for this query vector.. [optional] # noqa: E501 namespace (str): An override the namespace to search.. [optional] # noqa: E501 filter ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): An override for the metadata filter to apply. This replaces the request-level filter.. [optional] # noqa: E501 diff --git a/pinecone/core/client/model/scored_vector.py b/pinecone/core/client/model/scored_vector.py index 5d2a05f84..6e358fa7c 100644 --- a/pinecone/core/client/model/scored_vector.py +++ b/pinecone/core/client/model/scored_vector.py @@ -34,6 +34,10 @@ from pinecone.core.client.exceptions import ApiAttributeError +def lazy_import(): + from pinecone.core.client.model.sparse_values import SparseValues + globals()['SparseValues'] = SparseValues + class ScoredVector(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. @@ -75,6 +79,7 @@ def additional_properties_type(): This must be a method because a model may have properties that are of type self, this must run after the class is loaded """ + lazy_import() return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -89,11 +94,13 @@ def openapi_types(): openapi_types (dict): The key is attribute name and the value is attribute type. """ + lazy_import() return { 'id': (str,), # noqa: E501 'score': (float,), # noqa: E501 'values': ([float],), # noqa: E501 - 'metadata': ({str: (bool, date, dict, float, int, list, str, none_type)},), # noqa: E501 + 'sparse_values': (SparseValues,), # noqa: E501 + 'metadata': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 } @cached_property @@ -105,6 +112,7 @@ def discriminator(): 'id': 'id', # noqa: E501 'score': 'score', # noqa: E501 'values': 'values', # noqa: E501 + 'sparse_values': 'sparseValues', # noqa: E501 'metadata': 'metadata', # noqa: E501 } @@ -154,6 +162,7 @@ def _from_openapi_data(cls, id, *args, **kwargs): # noqa: E501 _visited_composed_classes = (Animal,) score (float): This is a measure of similarity between this vector and the query vector. The higher the score, the more they are similar.. [optional] # noqa: E501 values ([float]): This is the vector data, if it is requested.. [optional] # noqa: E501 + sparse_values (SparseValues): the sparse data of the vector [optional] # noqa: E501 metadata ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): This is the metadata, if it is requested.. [optional] # noqa: E501 """ @@ -242,6 +251,7 @@ def __init__(self, id, *args, **kwargs): # noqa: E501 _visited_composed_classes = (Animal,) score (float): This is a measure of similarity between this vector and the query vector. The higher the score, the more they are similar.. [optional] # noqa: E501 values ([float]): This is the vector data, if it is requested.. [optional] # noqa: E501 + sparse_values (SparseValues): This is the sparse data of the vector [optional] # noqa: E501 metadata ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): This is the metadata, if it is requested.. [optional] # noqa: E501 """ diff --git a/pinecone/core/client/model/sparse_values.py b/pinecone/core/client/model/sparse_values.py new file mode 100644 index 000000000..0517e8f83 --- /dev/null +++ b/pinecone/core/client/model/sparse_values.py @@ -0,0 +1,276 @@ +# +# Copyright (c) 2020-2021 Pinecone Systems Inc. All right reserved. +# + +""" + Pinecone API + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: version not set + Contact: support@pinecone.io + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from pinecone.core.client.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) +from ..model_utils import OpenApiModel +from pinecone.core.client.exceptions import ApiAttributeError + + + +class SparseValues(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + ('indices',): { + }, + ('values',): { + }, + } + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'indices': ([int],), # noqa: E501 + 'values': ([float],), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'indices': 'indices', # noqa: E501 + 'values': 'values', # noqa: E501 + } + + read_only_vars = { + } + + _composed_schemas = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, indices, values, *args, **kwargs): # noqa: E501 + """SparseValues - a model defined in OpenAPI + + Args: + indices ([int]): + values ([float]): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.indices = indices + self.values = values + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) + return self + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, indices, values, *args, **kwargs): # noqa: E501 + """SparseValues - a model defined in OpenAPI + + Args: + indices ([int]): + values ([float]): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.indices = indices + self.values = values + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/update_request.py b/pinecone/core/client/model/update_request.py index cbcab0343..06744e78e 100644 --- a/pinecone/core/client/model/update_request.py +++ b/pinecone/core/client/model/update_request.py @@ -34,6 +34,10 @@ from pinecone.core.client.exceptions import ApiAttributeError +def lazy_import(): + from pinecone.core.client.model.sparse_values import SparseValues + globals()['SparseValues'] = SparseValues + class UpdateRequest(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. @@ -77,6 +81,7 @@ def additional_properties_type(): This must be a method because a model may have properties that are of type self, this must run after the class is loaded """ + lazy_import() return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -91,9 +96,11 @@ def openapi_types(): openapi_types (dict): The key is attribute name and the value is attribute type. """ + lazy_import() return { 'id': (str,), # noqa: E501 'values': ([float],), # noqa: E501 + 'sparse_values': (SparseValues,), # noqa: E501 'set_metadata': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 'namespace': (str,), # noqa: E501 } @@ -106,6 +113,7 @@ def discriminator(): attribute_map = { 'id': 'id', # noqa: E501 'values': 'values', # noqa: E501 + 'sparse_values': 'sparseValues', # noqa: E501 'set_metadata': 'setMetadata', # noqa: E501 'namespace': 'namespace', # noqa: E501 } @@ -155,6 +163,7 @@ def _from_openapi_data(cls, id, *args, **kwargs): # noqa: E501 through its discriminator because we passed in _visited_composed_classes = (Animal,) values ([float]): Vector data.. [optional] # noqa: E501 + sparse_values (SparseValues): This is the sparse data of the vector to update [optional] # noqa: E501 set_metadata ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): Metadata to *set* for the vector.. [optional] # noqa: E501 namespace (str): Namespace name where to update the vector.. [optional] # noqa: E501 """ @@ -243,6 +252,7 @@ def __init__(self, id, *args, **kwargs): # noqa: E501 through its discriminator because we passed in _visited_composed_classes = (Animal,) values ([float]): Vector data.. [optional] # noqa: E501 + sparse_values (SparseValues): This is the sparse data of the vector to update [optional] # noqa: E501 set_metadata ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): Metadata to *set* for the vector.. [optional] # noqa: E501 namespace (str): Namespace name where to update the vector.. [optional] # noqa: E501 """ diff --git a/pinecone/core/client/model/upsert_request.py b/pinecone/core/client/model/upsert_request.py index aa9ffbaf6..ce3fc0a60 100644 --- a/pinecone/core/client/model/upsert_request.py +++ b/pinecone/core/client/model/upsert_request.py @@ -119,7 +119,7 @@ def _from_openapi_data(cls, vectors, *args, **kwargs): # noqa: E501 """UpsertRequest - a model defined in OpenAPI Args: - vectors ([Vector]): This is the actual array data. + vectors ([Vector]): An array containing the vectors to upsert. Recommended batch limit is 100 vectors. Keyword Args: _check_type (bool): if True, values for parameters in openapi_types @@ -205,7 +205,7 @@ def __init__(self, vectors, *args, **kwargs): # noqa: E501 """UpsertRequest - a model defined in OpenAPI Args: - vectors ([Vector]): This is the actual array data. + vectors ([Vector]): An array containing the vectors to upsert. Recommended batch limit is 100 vectors. Keyword Args: _check_type (bool): if True, values for parameters in openapi_types diff --git a/pinecone/core/client/model/vector.py b/pinecone/core/client/model/vector.py index 78326070b..cd2195f3d 100644 --- a/pinecone/core/client/model/vector.py +++ b/pinecone/core/client/model/vector.py @@ -34,6 +34,10 @@ from pinecone.core.client.exceptions import ApiAttributeError +def lazy_import(): + from pinecone.core.client.model.sparse_values import SparseValues + globals()['SparseValues'] = SparseValues + class Vector(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. @@ -77,6 +81,7 @@ def additional_properties_type(): This must be a method because a model may have properties that are of type self, this must run after the class is loaded """ + lazy_import() return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -91,10 +96,12 @@ def openapi_types(): openapi_types (dict): The key is attribute name and the value is attribute type. """ + lazy_import() return { 'id': (str,), # noqa: E501 'values': ([float],), # noqa: E501 - 'metadata': ({str: (bool, date, dict, float, int, list, str, none_type)},), # noqa: E501 + 'sparse_values': (SparseValues,), # noqa: E501 + 'metadata': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 } @cached_property @@ -105,6 +112,7 @@ def discriminator(): attribute_map = { 'id': 'id', # noqa: E501 'values': 'values', # noqa: E501 + 'sparse_values': 'sparseValues', # noqa: E501 'metadata': 'metadata', # noqa: E501 } @@ -153,6 +161,7 @@ def _from_openapi_data(cls, id, values, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) + sparse_values (SparseValues): the sparse data of the returned vector [optional] # noqa: E501 metadata ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): This is the metadata included in the request.. [optional] # noqa: E501 """ @@ -241,6 +250,7 @@ def __init__(self, id, values, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) + sparse_values (SparseValues): This is the sparse data of the vector to update [optional] # noqa: E501 metadata ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): This is the metadata included in the request.. [optional] # noqa: E501 """ diff --git a/pinecone/core/client/models/__init__.py b/pinecone/core/client/models/__init__.py index aea1559da..eab3f6184 100644 --- a/pinecone/core/client/models/__init__.py +++ b/pinecone/core/client/models/__init__.py @@ -35,6 +35,7 @@ from pinecone.core.client.model.rpc_status import RpcStatus from pinecone.core.client.model.scored_vector import ScoredVector from pinecone.core.client.model.single_query_results import SingleQueryResults +from pinecone.core.client.model.sparse_values import SparseValues from pinecone.core.client.model.update_request import UpdateRequest from pinecone.core.client.model.upsert_request import UpsertRequest from pinecone.core.client.model.upsert_response import UpsertResponse diff --git a/pinecone/core/grpc/index_grpc.py b/pinecone/core/grpc/index_grpc.py index 7136d131e..540c3baa5 100644 --- a/pinecone/core/grpc/index_grpc.py +++ b/pinecone/core/grpc/index_grpc.py @@ -18,14 +18,16 @@ from pinecone.core.client.model.vector import Vector as _Vector from pinecone.core.grpc.protos.vector_service_pb2 import Vector as GRPCVector, \ QueryVector as GRPCQueryVector, UpsertRequest, UpsertResponse, DeleteRequest, QueryRequest, \ - FetchRequest, UpdateRequest, DescribeIndexStatsRequest, DeleteResponse, UpdateResponse + FetchRequest, UpdateRequest, DescribeIndexStatsRequest, DeleteResponse, UpdateResponse, \ + SparseValues as GRPCSparseValues +from pinecone.core.client.model.sparse_values import SparseValues from pinecone.core.grpc.protos.vector_service_pb2_grpc import VectorServiceStub from pinecone.core.grpc.retry import RetryOnRpcErrorClientInterceptor, RetryConfig from pinecone.core.utils import _generate_request_id, dict_to_proto_struct, fix_tuple_length from pinecone.core.utils.constants import MAX_MSG_SIZE, REQUEST_ID, CLIENT_VERSION from pinecone.exceptions import PineconeException -__all__ = ["GRPCIndex", "GRPCVector", "GRPCQueryVector"] +__all__ = ["GRPCIndex", "GRPCVector", "GRPCQueryVector", "GRPCSparseValues"] _logger = logging.getLogger(__name__) @@ -160,13 +162,18 @@ def __exit__(self, exc_type, exc_value, traceback): self.close() +def parse_sparse_values(sparse_values: dict): + return SparseValues(indices=sparse_values['indices'], values=sparse_values['values']) if sparse_values else SparseValues(indices=[], values=[]) + + def parse_fetch_response(response: dict): vd = {} vectors = response.get('vectors') if not vectors: return None for id, vec in vectors.items(): - v_obj = _Vector(id=vec['id'], values=vec['values'], metadata=vec.get('metadata', None), _check_type=False) + v_obj = _Vector(id=vec['id'], values=vec['values'], sparse_values=parse_sparse_values(vec.get('sparseValues')), + metadata=vec.get('metadata', None), _check_type=False) vd[id] = v_obj namespace = response.get('namespace', '') return FetchResponse(vectors=vd, namespace=namespace, _check_type=False) @@ -182,14 +189,15 @@ def parse_query_response(response: dict, unary_query: bool, _check_type: bool = if 'matches' in match: for item in match['matches']: sc = ScoredVector(id=item['id'], score=item.get('score', 0.0), values=item.get('values', []), - metadata=item.get('metadata', {})) + sparse_values=parse_sparse_values(item.get('sparseValues')), metadata=item.get('metadata', {})) m.append(sc) res.append(SingleQueryResults(matches=m, namespace=namespace)) m = [] for item in response.get('matches', []): sc = ScoredVector(id=item['id'], score=item.get('score', 0.0), values=item.get('values', []), - metadata=item.get('metadata', {}), _check_type=_check_type) + sparse_values=parse_sparse_values(item.get('sparseValues')), metadata=item.get('metadata', {}), + _check_type=_check_type) m.append(sc) kwargs = {'_check_type': _check_type} @@ -266,9 +274,13 @@ def upsert(self, If a new value is upserted for an existing vector id, it will overwrite the previous value. Examples: - >>> index.upsert([('id1', [1.0, 2.0, 3.0], {'key': 'value'}), ('id2', [1.0, 2.0, 3.0])], namespace='ns1') + >>> index.upsert([('id1', [1.0, 2.0, 3.0], {'key': 'value'}), ('id2', [1.0, 2.0, 3.0])], + >>> namespace='ns1', async_req=True) >>> index.upsert([GRPCVector(id='id1', values=[1.0, 2.0, 3.0], metadata={'key': 'value'}), - >>> GRPCVector(id='id2', values=[1.0, 2.0, 3.0])], async_req=True) + >>> GRPCVector(id='id2', values=[1.0, 2.0, 3.0]), + >>> GRPCVector(id='id3', + >>> values=[1.0, 2.0, 3.0], + >>> sparse_values=GRPCSparseValues(indices=[1, 2], values=[0.2, 0.4]))]) Args: vectors (Union[List[Vector], List[Tuple]]): A list of vectors to upsert. @@ -282,7 +294,10 @@ def upsert(self, GRPCVector(id, values, metadata), where metadata is an optional argument of type Dict[str, Union[str, float, int, bool, List[int], List[float], List[str]]] Examples: GRPCVector(id='id1', values=[1.0, 2.0, 3.0], metadata={'key': 'value'}), - GRPCVector(id='id2', values=[1.0, 2.0, 3.0]) + GRPCVector(id='id2', values=[1.0, 2.0, 3.0]), + GRPCVector(id='id3', + values=[1.0, 2.0, 3.0], + sparse_values=GRPCSparseValues(indices=[1, 2], values=[0.2, 0.4])) Note: the dimension of each vector must match the dimension of the index. async_req (bool): If True, the upsert operation will be performed asynchronously. @@ -436,6 +451,7 @@ def query(self, filter: Optional[Dict[str, Union[str, float, int, bool, List, dict]]] = None, include_values: Optional[bool] = None, include_metadata: Optional[bool] = None, + sparse_vector: Optional[Union[GRPCSparseValues, Dict[str, Union[List[float], List[int]]]]] = None, **kwargs) -> QueryResponse: """ The Query operation searches a namespace, using a query vector. @@ -446,6 +462,10 @@ def query(self, >>> index.query(id='id1', top_k=10, namespace='my_namespace') >>> index.query(vector=[1, 2, 3], top_k=10, namespace='my_namespace', filter={'key': 'value'}) >>> index.query(id='id1', top_k=10, namespace='my_namespace', include_metadata=True, include_values=True) + >>> index.query(vector=[1, 2, 3], sparse_vector={'indices': [1, 2], 'values': [0.2, 0.4]}, + >>> top_k=10, namespace='my_namespace') + >>> index.query(vector=[1, 2, 3], sparse_vector=GRPCSparseValues([1, 2], [0.2, 0.4]), + >>> top_k=10, namespace='my_namespace') Args: vector (List[float]): The query vector. This should be the same length as the dimension of the index @@ -467,6 +487,9 @@ def query(self, If omitted the server will use the default value of False [optional] include_metadata (bool): Indicates whether metadata is included in the response as well as the ids. If omitted the server will use the default value of False [optional] + sparse_vector: (Union[SparseValues, Dict[str, Union[List[float], List[int]]]]): sparse values of the query vector. + Expected to be either a GRPCSparseValues object or a dict of the form: + {'indices': List[int], 'values': List[float]}, where the lists each have the same length. Returns: QueryResponse object which contains the list of the closest vectors as ScoredVector objects, and namespace name. @@ -487,6 +510,7 @@ def _query_transform(item): if filter is not None: filter = dict_to_proto_struct(filter) + sparse_vector = self._parse_sparse_values_arg(sparse_vector) args_dict = self._parse_non_empty_args([('vector', vector), ('id', id), ('queries', queries), @@ -494,7 +518,8 @@ def _query_transform(item): ('top_k', top_k), ('filter', filter), ('include_values', include_values), - ('include_metadata', include_metadata)]) + ('include_metadata', include_metadata), + ('sparse_vector', sparse_vector)]) request = QueryRequest(**args_dict) @@ -510,6 +535,7 @@ def update(self, set_metadata: Optional[Dict[str, Union[str, float, int, bool, List[int], List[float], List[str]]]] = None, namespace: Optional[str] = None, + sparse_values: Optional[Union[GRPCSparseValues, Dict[str, Union[List[float], List[int]]]]] = None, **kwargs) -> Union[UpdateResponse, PineconeGrpcFuture]: """ The Update operation updates vector in a namespace. @@ -520,6 +546,10 @@ def update(self, Examples: >>> index.update(id='id1', values=[1, 2, 3], namespace='my_namespace') >>> index.update(id='id1', set_metadata={'key': 'value'}, namespace='my_namespace', async_req=True) + >>> index.update(id='id1', values=[1, 2, 3], sparse_values={'indices': [1, 2], 'values': [0.2, 0.4]}, + >>> namespace='my_namespace') + >>> index.update(id='id1', values=[1, 2, 3], sparse_values=GRPCSparseValues(indices=[1, 2], values=[0.2, 0.4]), + >>> namespace='my_namespace') Args: id (str): Vector's unique id. @@ -529,6 +559,10 @@ def update(self, set_metadata (Dict[str, Union[str, float, int, bool, List[int], List[float], List[str]]]]): metadata to set for vector. [optional] namespace (str): Namespace name where to update the vector.. [optional] + sparse_values: (Dict[str, Union[List[float], List[int]]]): sparse values to update for the vector. + Expected to be either a GRPCSparseValues object or a dict of the form: + {'indices': List[int], 'values': List[float]} where the lists each have the same length. + Returns: UpdateResponse (contains no data) or a PineconeGrpcFuture object if async_req is True. """ @@ -536,9 +570,11 @@ def update(self, set_metadata = dict_to_proto_struct(set_metadata) timeout = kwargs.pop('timeout', None) + sparse_values = self._parse_sparse_values_arg(sparse_values) args_dict = self._parse_non_empty_args([('values', values), ('set_metadata', set_metadata), - ('namespace', namespace)]) + ('namespace', namespace), + ('sparse_values', sparse_values)]) request = UpdateRequest(id=id, **args_dict) if async_req: @@ -578,3 +614,20 @@ def describe_index_stats(self, @staticmethod def _parse_non_empty_args(args: List[Tuple[str, Any]]) -> Dict[str, Any]: return {arg_name: val for arg_name, val in args if val is not None} + + @staticmethod + def _parse_sparse_values_arg( + sparse_values: Optional[Union[GRPCSparseValues, + Dict[str, Union[List[float], List[int]]]]]) -> Optional[GRPCSparseValues]: + if sparse_values is None: + return None + + if isinstance(sparse_values, GRPCSparseValues): + return sparse_values + + if not isinstance(sparse_values, dict) or "indices" not in sparse_values or "values" not in sparse_values: + raise ValueError( + "Invalid sparse values argument. Expected a dict of: {'indices': List[int], 'values': List[float]}." + f"Received: {sparse_values}") + + return GRPCSparseValues(indices=sparse_values["indices"], values=sparse_values["values"]) diff --git a/pinecone/core/grpc/protos/vector_service_pb2.py b/pinecone/core/grpc/protos/vector_service_pb2.py index ec1857e64..8acbcd3ea 100644 --- a/pinecone/core/grpc/protos/vector_service_pb2.py +++ b/pinecone/core/grpc/protos/vector_service_pb2.py @@ -27,13 +27,52 @@ syntax='proto3', serialized_options=b'\n\021io.pinecone.protoP\001Z/github.com/pinecone-io/new-go-pinecone/pinecone\222A\366\002\022K\n\014Pinecone API\";\n\017Pinecone.io Ops\022\023https://pinecone.io\032\023support@pinecone.io\0329{index_name}-{project_name}.svc.{environment}.pinecone.io*\001\0022\020application/json:\020application/jsonZx\nv\n\nApiKeyAuth\022h\010\002\022YAn API Key is required to call Pinecone APIs. Get yours at https://www.pinecone.io/start/\032\007Api-Key \002b\020\n\016\n\nApiKeyAuth\022\000r9\n\031More Pinecone.io API docs\022\034https://www.pinecone.io/docs', create_key=_descriptor._internal_create_key, - serialized_pb=b'\n\x14vector_service.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1cgoogle/api/annotations.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a.protoc-gen-openapiv2/options/annotations.proto\"\xd7\x01\n\x06Vector\x12,\n\x02id\x18\x01 \x01(\tB \x92\x41\x1aJ\x12\"example-vector-1\"x\x80\x04\x80\x01\x01\xe0\x41\x02\x12G\n\x06values\x18\x02 \x03(\x02\x42\x37\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01\xe0\x41\x02\x12V\n\x08metadata\x18\x03 \x01(\x0b\x32\x17.google.protobuf.StructB+\x92\x41(J&{\"genre\": \"documentary\", \"year\": 2019}\"\xed\x01\n\x0cScoredVector\x12,\n\x02id\x18\x01 \x01(\tB \x92\x41\x1aJ\x12\"example-vector-1\"x\x80\x04\x80\x01\x01\xe0\x41\x02\x12\x18\n\x05score\x18\x02 \x01(\x02\x42\t\x92\x41\x06J\x04\x30.08\x12=\n\x06values\x18\x03 \x03(\x02\x42-\x92\x41*J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]\x12V\n\x08metadata\x18\x04 \x01(\x0b\x32\x17.google.protobuf.StructB+\x92\x41(J&{\"genre\": \"documentary\", \"year\": 2019}\"d\n\rUpsertRequest\x12&\n\x07vectors\x18\x01 \x03(\x0b\x32\x07.VectorB\x0c\x92\x41\x06x\xe8\x07\x80\x01\x01\xe0\x41\x02\x12+\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\"1\n\x0eUpsertResponse\x12\x1f\n\x0eupserted_count\x18\x01 \x01(\rB\x07\x92\x41\x04J\x02\x31\x30\"\xb6\x01\n\rDeleteRequest\x12(\n\x03ids\x18\x01 \x03(\tB\x1b\x92\x41\x18J\x10[\"id-0\", \"id-1\"]x\xe8\x07\x80\x01\x01\x12%\n\ndelete_all\x18\x02 \x01(\x08\x42\x11\x92\x41\x0e:\x05\x66\x61lseJ\x05\x66\x61lse\x12+\n\tnamespace\x18\x03 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\x12\'\n\x06\x66ilter\x18\x04 \x01(\x0b\x32\x17.google.protobuf.Struct\"\x10\n\x0e\x44\x65leteResponse\"h\n\x0c\x46\x65tchRequest\x12+\n\x03ids\x18\x01 \x03(\tB\x1e\x92\x41\x18J\x10[\"id-0\", \"id-1\"]x\xe8\x07\x80\x01\x01\xe0\x41\x02\x12+\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\"\xa3\x01\n\rFetchResponse\x12,\n\x07vectors\x18\x01 \x03(\x0b\x32\x1b.FetchResponse.VectorsEntry\x12+\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\x1a\x37\n\x0cVectorsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x16\n\x05value\x18\x02 \x01(\x0b\x32\x07.Vector:\x02\x38\x01\"\xaa\x02\n\x0bQueryVector\x12G\n\x06values\x18\x01 \x03(\x02\x42\x37\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01\xe0\x41\x02\x12(\n\x05top_k\x18\x02 \x01(\rB\x19\x92\x41\x16J\x02\x31\x30Y\x00\x00\x00\x00\x00\x88\xc3@i\x00\x00\x00\x00\x00\x00\xf0?\x12+\n\tnamespace\x18\x03 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\x12{\n\x06\x66ilter\x18\x04 \x01(\x0b\x32\x17.google.protobuf.StructBR\x92\x41OJM{\"genre\": {\"$in\": [\"comedy\", \"documentary\", \"drama\"]}, \"year\": {\"$eq\": 2019}}\"\xd4\x03\n\x0cQueryRequest\x12+\n\tnamespace\x18\x01 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\x12+\n\x05top_k\x18\x02 \x01(\rB\x1c\x92\x41\x16J\x02\x31\x30Y\x00\x00\x00\x00\x00\x88\xc3@i\x00\x00\x00\x00\x00\x00\xf0?\xe0\x41\x02\x12{\n\x06\x66ilter\x18\x03 \x01(\x0b\x32\x17.google.protobuf.StructBR\x92\x41OJM{\"genre\": {\"$in\": [\"comedy\", \"documentary\", \"drama\"]}, \"year\": {\"$eq\": 2019}}\x12(\n\x0einclude_values\x18\x04 \x01(\x08\x42\x10\x92\x41\r:\x05\x66\x61lseJ\x04true\x12*\n\x10include_metadata\x18\x05 \x01(\x08\x42\x10\x92\x41\r:\x05\x66\x61lseJ\x04true\x12)\n\x07queries\x18\x06 \x03(\x0b\x32\x0c.QueryVectorB\n\x18\x01\x92\x41\x05x\n\x80\x01\x01\x12\x44\n\x06vector\x18\x07 \x03(\x02\x42\x34\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01\x12&\n\x02id\x18\x08 \x01(\tB\x1a\x92\x41\x17J\x12\"example-vector-1\"x\x80\x04\"a\n\x12SingleQueryResults\x12\x1e\n\x07matches\x18\x01 \x03(\x0b\x32\r.ScoredVector\x12+\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\"l\n\rQueryResponse\x12(\n\x07results\x18\x01 \x03(\x0b\x32\x13.SingleQueryResultsB\x02\x18\x01\x12\x1e\n\x07matches\x18\x02 \x03(\x0b\x32\r.ScoredVector\x12\x11\n\tnamespace\x18\x03 \x01(\t\"\x8c\x02\n\rUpdateRequest\x12,\n\x02id\x18\x01 \x01(\tB \x92\x41\x1aJ\x12\"example-vector-1\"x\x80\x04\x80\x01\x01\xe0\x41\x02\x12\x44\n\x06values\x18\x02 \x03(\x02\x42\x34\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01\x12Z\n\x0cset_metadata\x18\x03 \x01(\x0b\x32\x17.google.protobuf.StructB+\x92\x41(J&{\"genre\": \"documentary\", \"year\": 2019}\x12+\n\tnamespace\x18\x04 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\"\x10\n\x0eUpdateResponse\"D\n\x19\x44\x65scribeIndexStatsRequest\x12\'\n\x06\x66ilter\x18\x01 \x01(\x0b\x32\x17.google.protobuf.Struct\"4\n\x10NamespaceSummary\x12 \n\x0cvector_count\x18\x01 \x01(\rB\n\x92\x41\x07J\x05\x35\x30\x30\x30\x30\"\x9a\x03\n\x1a\x44\x65scribeIndexStatsResponse\x12?\n\nnamespaces\x18\x01 \x03(\x0b\x32+.DescribeIndexStatsResponse.NamespacesEntry\x12\x1c\n\tdimension\x18\x02 \x01(\rB\t\x92\x41\x06J\x04\x31\x30\x32\x34\x12 \n\x0eindex_fullness\x18\x03 \x01(\x02\x42\x08\x92\x41\x05J\x03\x30.4\x12&\n\x12total_vector_count\x18\x04 \x01(\rB\n\x92\x41\x07J\x05\x38\x30\x30\x30\x30\x1a\x44\n\x0fNamespacesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12 \n\x05value\x18\x02 \x01(\x0b\x32\x11.NamespaceSummary:\x02\x38\x01:\x8c\x01\x92\x41\x88\x01\x32\x85\x01{\"namespaces\": {\"\": {\"vectorCount\": 50000}, \"example-namespace-2\": {\"vectorCount\": 30000}}, \"dimension\": 1024, \"index_fullness\": 0.4}2\xbd\x05\n\rVectorService\x12\x63\n\x06Upsert\x12\x0e.UpsertRequest\x1a\x0f.UpsertResponse\"8\x82\xd3\xe4\x93\x02\x14\"\x0f/vectors/upsert:\x01*\x92\x41\x1b\n\x11Vector Operations*\x06upsert\x12v\n\x06\x44\x65lete\x12\x0e.DeleteRequest\x1a\x0f.DeleteResponse\"K\x82\xd3\xe4\x93\x02\'\"\x0f/vectors/delete:\x01*Z\x11*\x0f/vectors/delete\x92\x41\x1b\n\x11Vector Operations*\x06\x64\x65lete\x12[\n\x05\x46\x65tch\x12\r.FetchRequest\x1a\x0e.FetchResponse\"3\x82\xd3\xe4\x93\x02\x10\x12\x0e/vectors/fetch\x92\x41\x1a\n\x11Vector Operations*\x05\x66\x65tch\x12V\n\x05Query\x12\r.QueryRequest\x1a\x0e.QueryResponse\".\x82\xd3\xe4\x93\x02\x0b\"\x06/query:\x01*\x92\x41\x1a\n\x11Vector Operations*\x05query\x12\x63\n\x06Update\x12\x0e.UpdateRequest\x1a\x0f.UpdateResponse\"8\x82\xd3\xe4\x93\x02\x14\"\x0f/vectors/update:\x01*\x92\x41\x1b\n\x11Vector Operations*\x06update\x12\xb4\x01\n\x12\x44\x65scribeIndexStats\x12\x1a.DescribeIndexStatsRequest\x1a\x1b.DescribeIndexStatsResponse\"e\x82\xd3\xe4\x93\x02\x33\"\x15/describe_index_stats:\x01*Z\x17\x12\x15/describe_index_stats\x92\x41)\n\x11Vector Operations*\x14\x64\x65scribe_index_statsB\xc0\x03\n\x11io.pinecone.protoP\x01Z/github.com/pinecone-io/new-go-pinecone/pinecone\x92\x41\xf6\x02\x12K\n\x0cPinecone API\";\n\x0fPinecone.io Ops\x12\x13https://pinecone.io\x1a\x13support@pinecone.io\x1a\x39{index_name}-{project_name}.svc.{environment}.pinecone.io*\x01\x02\x32\x10\x61pplication/json:\x10\x61pplication/jsonZx\nv\n\nApiKeyAuth\x12h\x08\x02\x12YAn API Key is required to call Pinecone APIs. Get yours at https://www.pinecone.io/start/\x1a\x07\x41pi-Key \x02\x62\x10\n\x0e\n\nApiKeyAuth\x12\x00r9\n\x19More Pinecone.io API docs\x12\x1chttps://www.pinecone.io/docsb\x06proto3' + serialized_pb=b'\n\x14vector_service.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1cgoogle/api/annotations.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a.protoc-gen-openapiv2/options/annotations.proto\"~\n\x0cSparseValues\x12\x35\n\x07indices\x18\x01 \x03(\rB$\x92\x41\x1eJ\x16[1, 312, 822, 14, 980]x\xe8\x07\x80\x01\x01\xe0\x41\x02\x12\x37\n\x06values\x18\x02 \x03(\x02\x42\'\x92\x41!J\x19[0.1, 0.2, 0.3, 0.4, 0.5]x\xe8\x07\x80\x01\x01\xe0\x41\x02\"\xfd\x01\n\x06Vector\x12,\n\x02id\x18\x01 \x01(\tB \x92\x41\x1aJ\x12\"example-vector-1\"x\x80\x04\x80\x01\x01\xe0\x41\x02\x12G\n\x06values\x18\x02 \x03(\x02\x42\x37\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01\xe0\x41\x02\x12$\n\rsparse_values\x18\x04 \x01(\x0b\x32\r.SparseValues\x12V\n\x08metadata\x18\x03 \x01(\x0b\x32\x17.google.protobuf.StructB+\x92\x41(J&{\"genre\": \"documentary\", \"year\": 2019}\"\x93\x02\n\x0cScoredVector\x12,\n\x02id\x18\x01 \x01(\tB \x92\x41\x1aJ\x12\"example-vector-1\"x\x80\x04\x80\x01\x01\xe0\x41\x02\x12\x18\n\x05score\x18\x02 \x01(\x02\x42\t\x92\x41\x06J\x04\x30.08\x12=\n\x06values\x18\x03 \x03(\x02\x42-\x92\x41*J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]\x12$\n\rsparse_values\x18\x05 \x01(\x0b\x32\r.SparseValues\x12V\n\x08metadata\x18\x04 \x01(\x0b\x32\x17.google.protobuf.StructB+\x92\x41(J&{\"genre\": \"documentary\", \"year\": 2019}\"d\n\rUpsertRequest\x12&\n\x07vectors\x18\x01 \x03(\x0b\x32\x07.VectorB\x0c\x92\x41\x06x\xe8\x07\x80\x01\x01\xe0\x41\x02\x12+\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\"1\n\x0eUpsertResponse\x12\x1f\n\x0eupserted_count\x18\x01 \x01(\rB\x07\x92\x41\x04J\x02\x31\x30\"\xb6\x01\n\rDeleteRequest\x12(\n\x03ids\x18\x01 \x03(\tB\x1b\x92\x41\x18J\x10[\"id-0\", \"id-1\"]x\xe8\x07\x80\x01\x01\x12%\n\ndelete_all\x18\x02 \x01(\x08\x42\x11\x92\x41\x0e:\x05\x66\x61lseJ\x05\x66\x61lse\x12+\n\tnamespace\x18\x03 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\x12\'\n\x06\x66ilter\x18\x04 \x01(\x0b\x32\x17.google.protobuf.Struct\"\x10\n\x0e\x44\x65leteResponse\"h\n\x0c\x46\x65tchRequest\x12+\n\x03ids\x18\x01 \x03(\tB\x1e\x92\x41\x18J\x10[\"id-0\", \"id-1\"]x\xe8\x07\x80\x01\x01\xe0\x41\x02\x12+\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\"\xa3\x01\n\rFetchResponse\x12,\n\x07vectors\x18\x01 \x03(\x0b\x32\x1b.FetchResponse.VectorsEntry\x12+\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\x1a\x37\n\x0cVectorsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x16\n\x05value\x18\x02 \x01(\x0b\x32\x07.Vector:\x02\x38\x01\"\xd0\x02\n\x0bQueryVector\x12G\n\x06values\x18\x01 \x03(\x02\x42\x37\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01\xe0\x41\x02\x12$\n\rsparse_values\x18\x05 \x01(\x0b\x32\r.SparseValues\x12(\n\x05top_k\x18\x02 \x01(\rB\x19\x92\x41\x16J\x02\x31\x30Y\x00\x00\x00\x00\x00\x88\xc3@i\x00\x00\x00\x00\x00\x00\xf0?\x12+\n\tnamespace\x18\x03 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\x12{\n\x06\x66ilter\x18\x04 \x01(\x0b\x32\x17.google.protobuf.StructBR\x92\x41OJM{\"genre\": {\"$in\": [\"comedy\", \"documentary\", \"drama\"]}, \"year\": {\"$eq\": 2019}}\"\xfa\x03\n\x0cQueryRequest\x12+\n\tnamespace\x18\x01 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\x12+\n\x05top_k\x18\x02 \x01(\rB\x1c\x92\x41\x16J\x02\x31\x30Y\x00\x00\x00\x00\x00\x88\xc3@i\x00\x00\x00\x00\x00\x00\xf0?\xe0\x41\x02\x12{\n\x06\x66ilter\x18\x03 \x01(\x0b\x32\x17.google.protobuf.StructBR\x92\x41OJM{\"genre\": {\"$in\": [\"comedy\", \"documentary\", \"drama\"]}, \"year\": {\"$eq\": 2019}}\x12(\n\x0einclude_values\x18\x04 \x01(\x08\x42\x10\x92\x41\r:\x05\x66\x61lseJ\x04true\x12*\n\x10include_metadata\x18\x05 \x01(\x08\x42\x10\x92\x41\r:\x05\x66\x61lseJ\x04true\x12)\n\x07queries\x18\x06 \x03(\x0b\x32\x0c.QueryVectorB\n\x18\x01\x92\x41\x05x\n\x80\x01\x01\x12\x44\n\x06vector\x18\x07 \x03(\x02\x42\x34\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01\x12$\n\rsparse_vector\x18\t \x01(\x0b\x32\r.SparseValues\x12&\n\x02id\x18\x08 \x01(\tB\x1a\x92\x41\x17J\x12\"example-vector-1\"x\x80\x04\"a\n\x12SingleQueryResults\x12\x1e\n\x07matches\x18\x01 \x03(\x0b\x32\r.ScoredVector\x12+\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\"l\n\rQueryResponse\x12(\n\x07results\x18\x01 \x03(\x0b\x32\x13.SingleQueryResultsB\x02\x18\x01\x12\x1e\n\x07matches\x18\x02 \x03(\x0b\x32\r.ScoredVector\x12\x11\n\tnamespace\x18\x03 \x01(\t\"\xb2\x02\n\rUpdateRequest\x12,\n\x02id\x18\x01 \x01(\tB \x92\x41\x1aJ\x12\"example-vector-1\"x\x80\x04\x80\x01\x01\xe0\x41\x02\x12\x44\n\x06values\x18\x02 \x03(\x02\x42\x34\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01\x12$\n\rsparse_values\x18\x05 \x01(\x0b\x32\r.SparseValues\x12Z\n\x0cset_metadata\x18\x03 \x01(\x0b\x32\x17.google.protobuf.StructB+\x92\x41(J&{\"genre\": \"documentary\", \"year\": 2019}\x12+\n\tnamespace\x18\x04 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\"\x10\n\x0eUpdateResponse\"D\n\x19\x44\x65scribeIndexStatsRequest\x12\'\n\x06\x66ilter\x18\x01 \x01(\x0b\x32\x17.google.protobuf.Struct\"4\n\x10NamespaceSummary\x12 \n\x0cvector_count\x18\x01 \x01(\rB\n\x92\x41\x07J\x05\x35\x30\x30\x30\x30\"\x9a\x03\n\x1a\x44\x65scribeIndexStatsResponse\x12?\n\nnamespaces\x18\x01 \x03(\x0b\x32+.DescribeIndexStatsResponse.NamespacesEntry\x12\x1c\n\tdimension\x18\x02 \x01(\rB\t\x92\x41\x06J\x04\x31\x30\x32\x34\x12 \n\x0eindex_fullness\x18\x03 \x01(\x02\x42\x08\x92\x41\x05J\x03\x30.4\x12&\n\x12total_vector_count\x18\x04 \x01(\rB\n\x92\x41\x07J\x05\x38\x30\x30\x30\x30\x1a\x44\n\x0fNamespacesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12 \n\x05value\x18\x02 \x01(\x0b\x32\x11.NamespaceSummary:\x02\x38\x01:\x8c\x01\x92\x41\x88\x01\x32\x85\x01{\"namespaces\": {\"\": {\"vectorCount\": 50000}, \"example-namespace-2\": {\"vectorCount\": 30000}}, \"dimension\": 1024, \"index_fullness\": 0.4}2\xbd\x05\n\rVectorService\x12\x63\n\x06Upsert\x12\x0e.UpsertRequest\x1a\x0f.UpsertResponse\"8\x82\xd3\xe4\x93\x02\x14\"\x0f/vectors/upsert:\x01*\x92\x41\x1b\n\x11Vector Operations*\x06upsert\x12v\n\x06\x44\x65lete\x12\x0e.DeleteRequest\x1a\x0f.DeleteResponse\"K\x82\xd3\xe4\x93\x02\'\"\x0f/vectors/delete:\x01*Z\x11*\x0f/vectors/delete\x92\x41\x1b\n\x11Vector Operations*\x06\x64\x65lete\x12[\n\x05\x46\x65tch\x12\r.FetchRequest\x1a\x0e.FetchResponse\"3\x82\xd3\xe4\x93\x02\x10\x12\x0e/vectors/fetch\x92\x41\x1a\n\x11Vector Operations*\x05\x66\x65tch\x12V\n\x05Query\x12\r.QueryRequest\x1a\x0e.QueryResponse\".\x82\xd3\xe4\x93\x02\x0b\"\x06/query:\x01*\x92\x41\x1a\n\x11Vector Operations*\x05query\x12\x63\n\x06Update\x12\x0e.UpdateRequest\x1a\x0f.UpdateResponse\"8\x82\xd3\xe4\x93\x02\x14\"\x0f/vectors/update:\x01*\x92\x41\x1b\n\x11Vector Operations*\x06update\x12\xb4\x01\n\x12\x44\x65scribeIndexStats\x12\x1a.DescribeIndexStatsRequest\x1a\x1b.DescribeIndexStatsResponse\"e\x82\xd3\xe4\x93\x02\x33\"\x15/describe_index_stats:\x01*Z\x17\x12\x15/describe_index_stats\x92\x41)\n\x11Vector Operations*\x14\x64\x65scribe_index_statsB\xc0\x03\n\x11io.pinecone.protoP\x01Z/github.com/pinecone-io/new-go-pinecone/pinecone\x92\x41\xf6\x02\x12K\n\x0cPinecone API\";\n\x0fPinecone.io Ops\x12\x13https://pinecone.io\x1a\x13support@pinecone.io\x1a\x39{index_name}-{project_name}.svc.{environment}.pinecone.io*\x01\x02\x32\x10\x61pplication/json:\x10\x61pplication/jsonZx\nv\n\nApiKeyAuth\x12h\x08\x02\x12YAn API Key is required to call Pinecone APIs. Get yours at https://www.pinecone.io/start/\x1a\x07\x41pi-Key \x02\x62\x10\n\x0e\n\nApiKeyAuth\x12\x00r9\n\x19More Pinecone.io API docs\x12\x1chttps://www.pinecone.io/docsb\x06proto3' , dependencies=[google_dot_protobuf_dot_struct__pb2.DESCRIPTOR,google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_api_dot_field__behavior__pb2.DESCRIPTOR,protoc__gen__openapiv2_dot_options_dot_annotations__pb2.DESCRIPTOR,]) +_SPARSEVALUES = _descriptor.Descriptor( + name='SparseValues', + full_name='SparseValues', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='indices', full_name='SparseValues.indices', index=0, + number=1, type=13, cpp_type=3, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\036J\026[1, 312, 822, 14, 980]x\350\007\200\001\001\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='values', full_name='SparseValues.values', index=1, + number=2, type=2, cpp_type=6, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A!J\031[0.1, 0.2, 0.3, 0.4, 0.5]x\350\007\200\001\001\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=165, + serialized_end=291, +) + + _VECTOR = _descriptor.Descriptor( name='Vector', full_name='Vector', @@ -57,7 +96,14 @@ is_extension=False, extension_scope=None, serialized_options=b'\222A1J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\240\234\001\200\001\001\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), _descriptor.FieldDescriptor( - name='metadata', full_name='Vector.metadata', index=2, + name='sparse_values', full_name='Vector.sparse_values', index=2, + number=4, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='metadata', full_name='Vector.metadata', index=3, number=3, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, @@ -75,8 +121,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=166, - serialized_end=381, + serialized_start=294, + serialized_end=547, ) @@ -110,7 +156,14 @@ is_extension=False, extension_scope=None, serialized_options=b'\222A*J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), _descriptor.FieldDescriptor( - name='metadata', full_name='ScoredVector.metadata', index=3, + name='sparse_values', full_name='ScoredVector.sparse_values', index=3, + number=5, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='metadata', full_name='ScoredVector.metadata', index=4, number=4, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, @@ -128,8 +181,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=384, - serialized_end=621, + serialized_start=550, + serialized_end=825, ) @@ -167,8 +220,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=623, - serialized_end=723, + serialized_start=827, + serialized_end=927, ) @@ -199,8 +252,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=725, - serialized_end=774, + serialized_start=929, + serialized_end=978, ) @@ -252,8 +305,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=777, - serialized_end=959, + serialized_start=981, + serialized_end=1163, ) @@ -277,8 +330,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=961, - serialized_end=977, + serialized_start=1165, + serialized_end=1181, ) @@ -316,8 +369,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=979, - serialized_end=1083, + serialized_start=1183, + serialized_end=1287, ) @@ -355,8 +408,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1194, - serialized_end=1249, + serialized_start=1398, + serialized_end=1453, ) _FETCHRESPONSE = _descriptor.Descriptor( @@ -393,8 +446,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1086, - serialized_end=1249, + serialized_start=1290, + serialized_end=1453, ) @@ -414,21 +467,28 @@ is_extension=False, extension_scope=None, serialized_options=b'\222A1J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\240\234\001\200\001\001\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), _descriptor.FieldDescriptor( - name='top_k', full_name='QueryVector.top_k', index=1, + name='sparse_values', full_name='QueryVector.sparse_values', index=1, + number=5, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='top_k', full_name='QueryVector.top_k', index=2, number=2, type=13, cpp_type=3, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, serialized_options=b'\222A\026J\00210Y\000\000\000\000\000\210\303@i\000\000\000\000\000\000\360?', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), _descriptor.FieldDescriptor( - name='namespace', full_name='QueryVector.namespace', index=2, + name='namespace', full_name='QueryVector.namespace', index=3, number=3, type=9, cpp_type=9, label=1, has_default_value=False, default_value=b"".decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, serialized_options=b'\222A\025J\023\"example-namespace\"', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), _descriptor.FieldDescriptor( - name='filter', full_name='QueryVector.filter', index=3, + name='filter', full_name='QueryVector.filter', index=4, number=4, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, @@ -446,8 +506,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1252, - serialized_end=1550, + serialized_start=1456, + serialized_end=1792, ) @@ -509,7 +569,14 @@ is_extension=False, extension_scope=None, serialized_options=b'\222A1J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\240\234\001\200\001\001', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), _descriptor.FieldDescriptor( - name='id', full_name='QueryRequest.id', index=7, + name='sparse_vector', full_name='QueryRequest.sparse_vector', index=7, + number=9, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='id', full_name='QueryRequest.id', index=8, number=8, type=9, cpp_type=9, label=1, has_default_value=False, default_value=b"".decode('utf-8'), message_type=None, enum_type=None, containing_type=None, @@ -527,8 +594,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1553, - serialized_end=2021, + serialized_start=1795, + serialized_end=2301, ) @@ -566,8 +633,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2023, - serialized_end=2120, + serialized_start=2303, + serialized_end=2400, ) @@ -612,8 +679,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2122, - serialized_end=2230, + serialized_start=2402, + serialized_end=2510, ) @@ -640,14 +707,21 @@ is_extension=False, extension_scope=None, serialized_options=b'\222A1J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\240\234\001\200\001\001', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), _descriptor.FieldDescriptor( - name='set_metadata', full_name='UpdateRequest.set_metadata', index=2, + name='sparse_values', full_name='UpdateRequest.sparse_values', index=2, + number=5, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='set_metadata', full_name='UpdateRequest.set_metadata', index=3, number=3, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, serialized_options=b'\222A(J&{\"genre\": \"documentary\", \"year\": 2019}', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), _descriptor.FieldDescriptor( - name='namespace', full_name='UpdateRequest.namespace', index=3, + name='namespace', full_name='UpdateRequest.namespace', index=4, number=4, type=9, cpp_type=9, label=1, has_default_value=False, default_value=b"".decode('utf-8'), message_type=None, enum_type=None, containing_type=None, @@ -665,8 +739,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2233, - serialized_end=2501, + serialized_start=2513, + serialized_end=2819, ) @@ -690,8 +764,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2503, - serialized_end=2519, + serialized_start=2821, + serialized_end=2837, ) @@ -722,8 +796,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2521, - serialized_end=2589, + serialized_start=2839, + serialized_end=2907, ) @@ -754,8 +828,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2591, - serialized_end=2643, + serialized_start=2909, + serialized_end=2961, ) @@ -793,8 +867,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2845, - serialized_end=2913, + serialized_start=3163, + serialized_end=3231, ) _DESCRIBEINDEXSTATSRESPONSE = _descriptor.Descriptor( @@ -845,28 +919,34 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2646, - serialized_end=3056, + serialized_start=2964, + serialized_end=3374, ) +_VECTOR.fields_by_name['sparse_values'].message_type = _SPARSEVALUES _VECTOR.fields_by_name['metadata'].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT +_SCOREDVECTOR.fields_by_name['sparse_values'].message_type = _SPARSEVALUES _SCOREDVECTOR.fields_by_name['metadata'].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT _UPSERTREQUEST.fields_by_name['vectors'].message_type = _VECTOR _DELETEREQUEST.fields_by_name['filter'].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT _FETCHRESPONSE_VECTORSENTRY.fields_by_name['value'].message_type = _VECTOR _FETCHRESPONSE_VECTORSENTRY.containing_type = _FETCHRESPONSE _FETCHRESPONSE.fields_by_name['vectors'].message_type = _FETCHRESPONSE_VECTORSENTRY +_QUERYVECTOR.fields_by_name['sparse_values'].message_type = _SPARSEVALUES _QUERYVECTOR.fields_by_name['filter'].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT _QUERYREQUEST.fields_by_name['filter'].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT _QUERYREQUEST.fields_by_name['queries'].message_type = _QUERYVECTOR +_QUERYREQUEST.fields_by_name['sparse_vector'].message_type = _SPARSEVALUES _SINGLEQUERYRESULTS.fields_by_name['matches'].message_type = _SCOREDVECTOR _QUERYRESPONSE.fields_by_name['results'].message_type = _SINGLEQUERYRESULTS _QUERYRESPONSE.fields_by_name['matches'].message_type = _SCOREDVECTOR +_UPDATEREQUEST.fields_by_name['sparse_values'].message_type = _SPARSEVALUES _UPDATEREQUEST.fields_by_name['set_metadata'].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT _DESCRIBEINDEXSTATSREQUEST.fields_by_name['filter'].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT _DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY.fields_by_name['value'].message_type = _NAMESPACESUMMARY _DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY.containing_type = _DESCRIBEINDEXSTATSRESPONSE _DESCRIBEINDEXSTATSRESPONSE.fields_by_name['namespaces'].message_type = _DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY +DESCRIPTOR.message_types_by_name['SparseValues'] = _SPARSEVALUES DESCRIPTOR.message_types_by_name['Vector'] = _VECTOR DESCRIPTOR.message_types_by_name['ScoredVector'] = _SCOREDVECTOR DESCRIPTOR.message_types_by_name['UpsertRequest'] = _UPSERTREQUEST @@ -886,6 +966,13 @@ DESCRIPTOR.message_types_by_name['DescribeIndexStatsResponse'] = _DESCRIBEINDEXSTATSRESPONSE _sym_db.RegisterFileDescriptor(DESCRIPTOR) +SparseValues = _reflection.GeneratedProtocolMessageType('SparseValues', (_message.Message,), { + 'DESCRIPTOR' : _SPARSEVALUES, + '__module__' : 'vector_service_pb2' + # @@protoc_insertion_point(class_scope:SparseValues) + }) +_sym_db.RegisterMessage(SparseValues) + Vector = _reflection.GeneratedProtocolMessageType('Vector', (_message.Message,), { 'DESCRIPTOR' : _VECTOR, '__module__' : 'vector_service_pb2' @@ -1023,6 +1110,8 @@ DESCRIPTOR._options = None +_SPARSEVALUES.fields_by_name['indices']._options = None +_SPARSEVALUES.fields_by_name['values']._options = None _VECTOR.fields_by_name['id']._options = None _VECTOR.fields_by_name['values']._options = None _VECTOR.fields_by_name['metadata']._options = None @@ -1072,8 +1161,8 @@ index=0, serialized_options=None, create_key=_descriptor._internal_create_key, - serialized_start=3059, - serialized_end=3760, + serialized_start=3377, + serialized_end=4078, methods=[ _descriptor.MethodDescriptor( name='Upsert', diff --git a/pinecone/core/grpc/protos/vector_service_pb2.pyi b/pinecone/core/grpc/protos/vector_service_pb2.pyi index c1486c1ff..0c2c73f62 100644 --- a/pinecone/core/grpc/protos/vector_service_pb2.pyi +++ b/pinecone/core/grpc/protos/vector_service_pb2.pyi @@ -39,11 +39,27 @@ builtin___int = int DESCRIPTOR: google___protobuf___descriptor___FileDescriptor = ... +class SparseValues(google___protobuf___message___Message): + DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... + indices: google___protobuf___internal___containers___RepeatedScalarFieldContainer[builtin___int] = ... + values: google___protobuf___internal___containers___RepeatedScalarFieldContainer[builtin___float] = ... + + def __init__(self, + *, + indices : typing___Optional[typing___Iterable[builtin___int]] = None, + values : typing___Optional[typing___Iterable[builtin___float]] = None, + ) -> None: ... + def ClearField(self, field_name: typing_extensions___Literal[u"indices",b"indices",u"values",b"values"]) -> None: ... +type___SparseValues = SparseValues + class Vector(google___protobuf___message___Message): DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... id: typing___Text = ... values: google___protobuf___internal___containers___RepeatedScalarFieldContainer[builtin___float] = ... + @property + def sparse_values(self) -> type___SparseValues: ... + @property def metadata(self) -> google___protobuf___struct_pb2___Struct: ... @@ -51,10 +67,11 @@ class Vector(google___protobuf___message___Message): *, id : typing___Optional[typing___Text] = None, values : typing___Optional[typing___Iterable[builtin___float]] = None, + sparse_values : typing___Optional[type___SparseValues] = None, metadata : typing___Optional[google___protobuf___struct_pb2___Struct] = None, ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal[u"metadata",b"metadata"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal[u"id",b"id",u"metadata",b"metadata",u"values",b"values"]) -> None: ... + def HasField(self, field_name: typing_extensions___Literal[u"metadata",b"metadata",u"sparse_values",b"sparse_values"]) -> builtin___bool: ... + def ClearField(self, field_name: typing_extensions___Literal[u"id",b"id",u"metadata",b"metadata",u"sparse_values",b"sparse_values",u"values",b"values"]) -> None: ... type___Vector = Vector class ScoredVector(google___protobuf___message___Message): @@ -63,6 +80,9 @@ class ScoredVector(google___protobuf___message___Message): score: builtin___float = ... values: google___protobuf___internal___containers___RepeatedScalarFieldContainer[builtin___float] = ... + @property + def sparse_values(self) -> type___SparseValues: ... + @property def metadata(self) -> google___protobuf___struct_pb2___Struct: ... @@ -71,10 +91,11 @@ class ScoredVector(google___protobuf___message___Message): id : typing___Optional[typing___Text] = None, score : typing___Optional[builtin___float] = None, values : typing___Optional[typing___Iterable[builtin___float]] = None, + sparse_values : typing___Optional[type___SparseValues] = None, metadata : typing___Optional[google___protobuf___struct_pb2___Struct] = None, ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal[u"metadata",b"metadata"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal[u"id",b"id",u"metadata",b"metadata",u"score",b"score",u"values",b"values"]) -> None: ... + def HasField(self, field_name: typing_extensions___Literal[u"metadata",b"metadata",u"sparse_values",b"sparse_values"]) -> builtin___bool: ... + def ClearField(self, field_name: typing_extensions___Literal[u"id",b"id",u"metadata",b"metadata",u"score",b"score",u"sparse_values",b"sparse_values",u"values",b"values"]) -> None: ... type___ScoredVector = ScoredVector class UpsertRequest(google___protobuf___message___Message): @@ -180,18 +201,22 @@ class QueryVector(google___protobuf___message___Message): top_k: builtin___int = ... namespace: typing___Text = ... + @property + def sparse_values(self) -> type___SparseValues: ... + @property def filter(self) -> google___protobuf___struct_pb2___Struct: ... def __init__(self, *, values : typing___Optional[typing___Iterable[builtin___float]] = None, + sparse_values : typing___Optional[type___SparseValues] = None, top_k : typing___Optional[builtin___int] = None, namespace : typing___Optional[typing___Text] = None, filter : typing___Optional[google___protobuf___struct_pb2___Struct] = None, ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal[u"filter",b"filter"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal[u"filter",b"filter",u"namespace",b"namespace",u"top_k",b"top_k",u"values",b"values"]) -> None: ... + def HasField(self, field_name: typing_extensions___Literal[u"filter",b"filter",u"sparse_values",b"sparse_values"]) -> builtin___bool: ... + def ClearField(self, field_name: typing_extensions___Literal[u"filter",b"filter",u"namespace",b"namespace",u"sparse_values",b"sparse_values",u"top_k",b"top_k",u"values",b"values"]) -> None: ... type___QueryVector = QueryVector class QueryRequest(google___protobuf___message___Message): @@ -209,6 +234,9 @@ class QueryRequest(google___protobuf___message___Message): @property def queries(self) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[type___QueryVector]: ... + @property + def sparse_vector(self) -> type___SparseValues: ... + def __init__(self, *, namespace : typing___Optional[typing___Text] = None, @@ -218,10 +246,11 @@ class QueryRequest(google___protobuf___message___Message): include_metadata : typing___Optional[builtin___bool] = None, queries : typing___Optional[typing___Iterable[type___QueryVector]] = None, vector : typing___Optional[typing___Iterable[builtin___float]] = None, + sparse_vector : typing___Optional[type___SparseValues] = None, id : typing___Optional[typing___Text] = None, ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal[u"filter",b"filter"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal[u"filter",b"filter",u"id",b"id",u"include_metadata",b"include_metadata",u"include_values",b"include_values",u"namespace",b"namespace",u"queries",b"queries",u"top_k",b"top_k",u"vector",b"vector"]) -> None: ... + def HasField(self, field_name: typing_extensions___Literal[u"filter",b"filter",u"sparse_vector",b"sparse_vector"]) -> builtin___bool: ... + def ClearField(self, field_name: typing_extensions___Literal[u"filter",b"filter",u"id",b"id",u"include_metadata",b"include_metadata",u"include_values",b"include_values",u"namespace",b"namespace",u"queries",b"queries",u"sparse_vector",b"sparse_vector",u"top_k",b"top_k",u"vector",b"vector"]) -> None: ... type___QueryRequest = QueryRequest class SingleQueryResults(google___protobuf___message___Message): @@ -264,6 +293,9 @@ class UpdateRequest(google___protobuf___message___Message): values: google___protobuf___internal___containers___RepeatedScalarFieldContainer[builtin___float] = ... namespace: typing___Text = ... + @property + def sparse_values(self) -> type___SparseValues: ... + @property def set_metadata(self) -> google___protobuf___struct_pb2___Struct: ... @@ -271,11 +303,12 @@ class UpdateRequest(google___protobuf___message___Message): *, id : typing___Optional[typing___Text] = None, values : typing___Optional[typing___Iterable[builtin___float]] = None, + sparse_values : typing___Optional[type___SparseValues] = None, set_metadata : typing___Optional[google___protobuf___struct_pb2___Struct] = None, namespace : typing___Optional[typing___Text] = None, ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal[u"set_metadata",b"set_metadata"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal[u"id",b"id",u"namespace",b"namespace",u"set_metadata",b"set_metadata",u"values",b"values"]) -> None: ... + def HasField(self, field_name: typing_extensions___Literal[u"set_metadata",b"set_metadata",u"sparse_values",b"sparse_values"]) -> builtin___bool: ... + def ClearField(self, field_name: typing_extensions___Literal[u"id",b"id",u"namespace",b"namespace",u"set_metadata",b"set_metadata",u"sparse_values",b"sparse_values",u"values",b"values"]) -> None: ... type___UpdateRequest = UpdateRequest class UpdateResponse(google___protobuf___message___Message): diff --git a/pinecone/core/grpc/protos/vector_service_pb2_grpc.py b/pinecone/core/grpc/protos/vector_service_pb2_grpc.py index 69643f98f..281027742 100644 --- a/pinecone/core/grpc/protos/vector_service_pb2_grpc.py +++ b/pinecone/core/grpc/protos/vector_service_pb2_grpc.py @@ -110,8 +110,12 @@ def Update(self, request, context): def DescribeIndexStats(self, request, context): """DescribeIndexStats - The `DescribeIndexStats` operation returns statistics about the index's contents. - For example: The vector count per namespace and the number of dimensions. + The `DescribeIndexStats` operation returns statistics about the index's + contents, including the vector count per namespace, the number of + dimensions, and the index fullness. The index fullness result may be + inaccurate during pod resizing; to get the status of a pod resizing + process, use + [`describe_index`](https://www.pinecone.io/docs/api/operation/describe_index/). """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') diff --git a/pinecone/index.py b/pinecone/index.py index b14b39e71..724ae6164 100644 --- a/pinecone/index.py +++ b/pinecone/index.py @@ -5,6 +5,7 @@ from collections.abc import Iterable from typing import Union, List, Tuple, Optional, Dict, Any +from .core.client.model.sparse_values import SparseValues from pinecone import Config from pinecone.core.client import ApiClient from .core.client.models import FetchResponse, ProtobufAny, QueryRequest, QueryResponse, QueryVector, RpcStatus, \ @@ -17,7 +18,7 @@ __all__ = [ "Index", "FetchResponse", "ProtobufAny", "QueryRequest", "QueryResponse", "QueryVector", "RpcStatus", "ScoredVector", "SingleQueryResults", "DescribeIndexStatsResponse", "UpsertRequest", "UpsertResponse", - "UpdateRequest", "Vector", "DeleteRequest", "UpdateRequest", "DescribeIndexStatsRequest" + "UpdateRequest", "Vector", "DeleteRequest", "UpdateRequest", "DescribeIndexStatsRequest", "SparseValues" ] from .core.utils.error_handling import validate_and_convert_errors @@ -77,22 +78,35 @@ def upsert(self, Examples: >>> index.upsert([('id1', [1.0, 2.0, 3.0], {'key': 'value'}), ('id2', [1.0, 2.0, 3.0])]) - >>> index.upsert([Vector(id='id1', values=[1.0, 2.0, 3.0], metadata={'key': 'value'}), - >>> Vector(id='id2', values=[1.0, 2.0, 3.0])]) + >>> index.upsert([Vector(id='id1', + >>> values=[1.0, 2.0, 3.0], + >>> metadata={'key': 'value'}), + >>> Vector(id='id2', + >>> values=[1.0, 2.0, 3.0], + >>> sparse_values=SparseValues(indices=[1, 2], values=[0.2, 0.4]))]) Args: vectors (Union[List[Vector], List[Tuple]]): A list of vectors to upsert. A vector can be represented by a 1) Vector object or a 2) tuple. - 1) if a tuple is used, it must be of the form (id, values, metadata) or (id, values). - where id is a string, vector is a list of floats, and metadata is a dict. - Examples: ('id1', [1.0, 2.0, 3.0], {'key': 'value'}), ('id2', [1.0, 2.0, 3.0]) - - 2) if a Vector object is used, a Vector object must be of the form Vector(id, values, metadata), - where metadata is an optional argument of the type - Dict[str, Union[str, float, int, bool, List[int], List[float], List[str]]]. - Examples: Vector(id='id1', values=[1.0, 2.0, 3.0], metadata={'key': 'value'}), - Vector(id='id2', values=[1.0, 2.0, 3.0]) + 1) if a tuple is used, it must be of the form (id, values, meatadaa) or (id, values). + where id is a string, vector is a list of floats, metadata is a dict, + and sparse_values is a dict of the form {'indices': List[int], 'values': List[float]}. + Examples: ('id1', [1.0, 2.0, 3.0], {'key': 'value'}, {'indices': [1, 2], 'values': [0.2, 0.4]}), + ('id1', [1.0, 2.0, 3.0], None, {'indices': [1, 2], 'values': [0.2, 0.4]}) + ('id1', [1.0, 2.0, 3.0], {'key': 'value'}), ('id2', [1.0, 2.0, 3.0]), + + 2) if a Vector object is used, a Vector object must be of the form + Vector(id, values, metadata, sparse_values), + where metadata and sparse_values aree optional arguments + Examples: Vector(id='id1', + values=[1.0, 2.0, 3.0], + metadata={'key': 'value'}) + Vector(id='id2', + values=[1.0, 2.0, 3.0]) + Vector(id='id3', + values=[1.0, 2.0, 3.0], + sparse_values=SparseValues(indices=[1, 2], values=[0.2, 0.4])) Note: the dimension of each vector must match the dimension of the index. @@ -250,6 +264,7 @@ def query(self, filter: Optional[Dict[str, Union[str, float, int, bool, List, dict]]] = None, include_values: Optional[bool] = None, include_metadata: Optional[bool] = None, + sparse_vector: Optional[Union[SparseValues, Dict[str, Union[List[float], List[int]]]]] = None, **kwargs) -> QueryResponse: """ The Query operation searches a namespace, using a query vector. @@ -262,6 +277,10 @@ def query(self, >>> index.query(id='id1', top_k=10, namespace='my_namespace') >>> index.query(vector=[1, 2, 3], top_k=10, namespace='my_namespace', filter={'key': 'value'}) >>> index.query(id='id1', top_k=10, namespace='my_namespace', include_metadata=True, include_values=True) + >>> index.query(vector=[1, 2, 3], sparse_vector={'indices': [1, 2], 'values': [0.2, 0.4]}, + >>> top_k=10, namespace='my_namespace') + >>> index.query(vector=[1, 2, 3], sparse_vector=SparseValues([1, 2], [0.2, 0.4]), + >>> top_k=10, namespace='my_namespace') Args: vector (List[float]): The query vector. This should be the same length as the dimension of the index @@ -283,7 +302,9 @@ def query(self, If omitted the server will use the default value of False [optional] include_metadata (bool): Indicates whether metadata is included in the response as well as the ids. If omitted the server will use the default value of False [optional] - + sparse_vector: (Union[SparseValues, Dict[str, Union[List[float], List[int]]]]): sparse values of the query vector. + Expected to be either a SparseValues object or a dict of the form: + {'indices': List[int], 'values': List[float]}, where the lists each have the same length. Keyword Args: Supports OpenAPI client keyword arguments. See pinecone.core.client.models.QueryRequest for more details. @@ -305,6 +326,8 @@ def _query_transform(item): _check_type = kwargs.pop('_check_type', False) queries = list(map(_query_transform, queries)) if queries is not None else None + + sparse_vector = self._parse_sparse_values_arg(sparse_vector) args_dict = self._parse_non_empty_args([('vector', vector), ('id', id), ('queries', queries), @@ -312,18 +335,8 @@ def _query_transform(item): ('namespace', namespace), ('filter', filter), ('include_values', include_values), - ('include_metadata', include_metadata)]) - - def _query_transform(item): - if isinstance(item, QueryVector): - return item - if isinstance(item, tuple): - values, filter = fix_tuple_length(item, 2) - return QueryVector(values=values, filter=filter, _check_type=_check_type) - if isinstance(item, Iterable): - return QueryVector(values=item, _check_type=_check_type) - raise ValueError(f"Invalid query vector value passed: cannot interpret type {type(item)}") - + ('include_metadata', include_metadata), + ('sparse_vector', sparse_vector)]) response = self._vector_api.query( QueryRequest( **args_dict, @@ -341,6 +354,7 @@ def update(self, set_metadata: Optional[Dict[str, Union[str, float, int, bool, List[int], List[float], List[str]]]] = None, namespace: Optional[str] = None, + sparse_values: Optional[Union[SparseValues, Dict[str, Union[List[float], List[int]]]]] = None, **kwargs) -> Dict[str, Any]: """ The Update operation updates vector in a namespace. @@ -353,6 +367,10 @@ def update(self, Examples: >>> index.update(id='id1', values=[1, 2, 3], namespace='my_namespace') >>> index.update(id='id1', set_metadata={'key': 'value'}, namespace='my_namespace') + >>> index.update(id='id1', values=[1, 2, 3], sparse_values={'indices': [1, 2], 'values': [0.2, 0.4]}, + >>> namespace='my_namespace') + >>> index.update(id='id1', values=[1, 2, 3], sparse_values=SparseValues(indices=[1, 2], values=[0.2, 0.4]), + >>> namespace='my_namespace') Args: id (str): Vector's unique id. @@ -360,6 +378,9 @@ def update(self, set_metadata (Dict[str, Union[str, float, int, bool, List[int], List[float], List[str]]]]): metadata to set for vector. [optional] namespace (str): Namespace name where to update the vector.. [optional] + sparse_values: (Dict[str, Union[List[float], List[int]]]): sparse values to update for the vector. + Expected to be either a SparseValues object or a dict of the form: + {'indices': List[int], 'values': List[float]} where the lists each have the same length. Keyword Args: Supports OpenAPI client keyword arguments. See pinecone.core.client.models.UpdateRequest for more details. @@ -367,9 +388,11 @@ def update(self, Returns: An empty dictionary if the update was successful. """ _check_type = kwargs.pop('_check_type', False) + sparse_values = self._parse_sparse_values_arg(sparse_values) args_dict = self._parse_non_empty_args([('values', values), ('set_metadata', set_metadata), - ('namespace', namespace)]) + ('namespace', namespace), + ('sparse_values', sparse_values)]) return self._vector_api.update(UpdateRequest( id=id, **args_dict, @@ -414,3 +437,20 @@ def describe_index_stats(self, @staticmethod def _parse_non_empty_args(args: List[Tuple[str, Any]]) -> Dict[str, Any]: return {arg_name: val for arg_name, val in args if val is not None} + + @staticmethod + def _parse_sparse_values_arg( + sparse_values: Optional[Union[SparseValues, + Dict[str, Union[List[float], List[int]]]]]) -> Optional[SparseValues]: + if sparse_values is None: + return None + + if isinstance(sparse_values, SparseValues): + return sparse_values + + if not isinstance(sparse_values, dict) or "indices" not in sparse_values or "values" not in sparse_values: + raise ValueError( + "Invalid sparse values argument. Expected a dict of: {'indices': List[int], 'values': List[float]}." + f"Received: {sparse_values}") + + return SparseValues(indices=sparse_values["indices"], values=sparse_values["values"])