diff --git a/pinecone/control/index_host_store.py b/pinecone/control/index_host_store.py index 7a5622e6..cf2e1df4 100644 --- a/pinecone/control/index_host_store.py +++ b/pinecone/control/index_host_store.py @@ -1,6 +1,6 @@ from typing import Dict from pinecone.config import Config -from pinecone.core.client.api.manage_pod_indexes_api import ManagePodIndexesApi as IndexOperationsApi +from pinecone.core.client.api.manage_indexes_api import ManageIndexesApi as IndexOperationsApi from pinecone.core.client.exceptions import PineconeException from pinecone.utils import normalize_host diff --git a/pinecone/control/pinecone.py b/pinecone/control/pinecone.py index 00070960..2099bbef 100644 --- a/pinecone/control/pinecone.py +++ b/pinecone/control/pinecone.py @@ -5,7 +5,7 @@ from pinecone.config import PineconeConfig, Config -from pinecone.core.client.api.manage_pod_indexes_api import ManagePodIndexesApi as IndexOperationsApi +from pinecone.core.client.api.manage_indexes_api import ManageIndexesApi as IndexOperationsApi from pinecone.core.client.api_client import ApiClient from pinecone.utils import get_user_agent from pinecone.core.client.models import ( diff --git a/pinecone/core/client/api/__init__.py b/pinecone/core/client/api/__init__.py index a4e950c7..97879a3a 100644 --- a/pinecone/core/client/api/__init__.py +++ b/pinecone/core/client/api/__init__.py @@ -1,3 +1,3 @@ # do not import all apis into this module because that uses a lot of memory and stack frames # if you need the ability to import all apis from one package, import them with -# from pinecone.core.client.apis import ManagePodIndexesApi +# from pinecone.core.client.apis import ManageIndexesApi diff --git a/pinecone/core/client/api/manage_pod_indexes_api.py b/pinecone/core/client/api/manage_indexes_api.py similarity index 99% rename from pinecone/core/client/api/manage_pod_indexes_api.py rename to pinecone/core/client/api/manage_indexes_api.py index 53bd9743..d74f1124 100644 --- a/pinecone/core/client/api/manage_pod_indexes_api.py +++ b/pinecone/core/client/api/manage_indexes_api.py @@ -31,7 +31,7 @@ from pinecone.core.client.model.index_model import IndexModel -class ManagePodIndexesApi(object): +class ManageIndexesApi(object): """NOTE: This class is auto generated by OpenAPI Generator Ref: https://openapi-generator.tech diff --git a/pinecone/core/client/api/manage_serverless_indexes_api.py b/pinecone/core/client/api/manage_serverless_indexes_api.py deleted file mode 100644 index 33eefee7..00000000 --- a/pinecone/core/client/api/manage_serverless_indexes_api.py +++ /dev/null @@ -1,525 +0,0 @@ -""" - Pineonce.io Public API - - Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. # noqa: E501 - - The version of the OpenAPI document: 1.0 - Generated by: https://openapi-generator.tech -""" - - -import re # noqa: F401 -import sys # noqa: F401 - -from pinecone.core.client.api_client import ApiClient, Endpoint as _Endpoint -from pinecone.core.client.model_utils import ( # noqa: F401 - check_allowed_values, - check_validations, - date, - datetime, - file_type, - none_type, - validate_and_convert_types -) -from pinecone.core.client.model.create_index_request import CreateIndexRequest -from pinecone.core.client.model.error_response import ErrorResponse -from pinecone.core.client.model.index_list import IndexList -from pinecone.core.client.model.index_model import IndexModel - - -class ManageServerlessIndexesApi(object): - """NOTE: This class is auto generated by OpenAPI Generator - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - def __init__(self, api_client=None): - if api_client is None: - api_client = ApiClient() - self.api_client = api_client - - def __create_index( - self, - create_index_request, - **kwargs - ): - """create_index # noqa: E501 - - This operation deploys a Pinecone index. This is where you specify the measure of similarity, the dimension of vectors to be stored in the index, which cloud provider you would like to deploy with, and more. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.create_index(create_index_request, async_req=True) - >>> result = thread.get() - - Args: - create_index_request (CreateIndexRequest): The desired configuration for the index. - - Keyword Args: - _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 - will be returned without reading/decoding response data. - Default is True. - _request_timeout (int/float/tuple): timeout setting for this request. If - one number provided, it will be total request timeout. It can also - be a pair (tuple) of (connection, read) timeouts. - Default is None. - _check_input_type (bool): specifies if type checking - should be done one the data sent to the server. - Default is True. - _check_return_type (bool): specifies if type checking - should be done one the data received from the server. - Default is True. - _host_index (int/None): specifies the index of the server - that we want to use. - Default is read from the configuration. - async_req (bool): execute request asynchronously - - Returns: - IndexModel - If the method is called asynchronously, returns the request - thread. - """ - kwargs['async_req'] = kwargs.get( - 'async_req', False - ) - kwargs['_return_http_data_only'] = kwargs.get( - '_return_http_data_only', True - ) - kwargs['_preload_content'] = kwargs.get( - '_preload_content', True - ) - kwargs['_request_timeout'] = kwargs.get( - '_request_timeout', None - ) - kwargs['_check_input_type'] = kwargs.get( - '_check_input_type', True - ) - kwargs['_check_return_type'] = kwargs.get( - '_check_return_type', True - ) - kwargs['_host_index'] = kwargs.get('_host_index') - kwargs['create_index_request'] = \ - create_index_request - return self.call_with_http_info(**kwargs) - - self.create_index = _Endpoint( - settings={ - 'response_type': (IndexModel,), - 'auth': [ - 'ApiKeyAuth' - ], - 'endpoint_path': '/indexes', - 'operation_id': 'create_index', - 'http_method': 'POST', - 'servers': [ - { - 'url': "https://api.pinecone.io", - 'description': "No description provided", - }, - ] - }, - params_map={ - 'all': [ - 'create_index_request', - ], - 'required': [ - 'create_index_request', - ], - 'nullable': [ - ], - 'enum': [ - ], - 'validation': [ - ] - }, - root_map={ - 'validations': { - }, - 'allowed_values': { - }, - 'openapi_types': { - 'create_index_request': - (CreateIndexRequest,), - }, - 'attribute_map': { - }, - 'location_map': { - 'create_index_request': 'body', - }, - 'collection_format_map': { - } - }, - headers_map={ - 'accept': [ - 'application/json' - ], - 'content_type': [ - 'application/json' - ] - }, - api_client=api_client, - callable=__create_index - ) - - def __delete_index( - self, - index_name, - **kwargs - ): - """delete_index # noqa: E501 - - This operation deletes an existing index. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.delete_index(index_name, async_req=True) - >>> result = thread.get() - - Args: - index_name (str): The name of the index to delete - - Keyword Args: - _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 - will be returned without reading/decoding response data. - Default is True. - _request_timeout (int/float/tuple): timeout setting for this request. If - one number provided, it will be total request timeout. It can also - be a pair (tuple) of (connection, read) timeouts. - Default is None. - _check_input_type (bool): specifies if type checking - should be done one the data sent to the server. - Default is True. - _check_return_type (bool): specifies if type checking - should be done one the data received from the server. - Default is True. - _host_index (int/None): specifies the index of the server - that we want to use. - Default is read from the configuration. - async_req (bool): execute request asynchronously - - Returns: - None - If the method is called asynchronously, returns the request - thread. - """ - kwargs['async_req'] = kwargs.get( - 'async_req', False - ) - kwargs['_return_http_data_only'] = kwargs.get( - '_return_http_data_only', True - ) - kwargs['_preload_content'] = kwargs.get( - '_preload_content', True - ) - kwargs['_request_timeout'] = kwargs.get( - '_request_timeout', None - ) - kwargs['_check_input_type'] = kwargs.get( - '_check_input_type', True - ) - kwargs['_check_return_type'] = kwargs.get( - '_check_return_type', True - ) - kwargs['_host_index'] = kwargs.get('_host_index') - kwargs['index_name'] = \ - index_name - return self.call_with_http_info(**kwargs) - - self.delete_index = _Endpoint( - settings={ - 'response_type': None, - 'auth': [ - 'ApiKeyAuth' - ], - 'endpoint_path': '/indexes/{index_name}', - 'operation_id': 'delete_index', - 'http_method': 'DELETE', - 'servers': [ - { - 'url': "https://api.pinecone.io", - 'description': "No description provided", - }, - ] - }, - params_map={ - 'all': [ - 'index_name', - ], - 'required': [ - 'index_name', - ], - 'nullable': [ - ], - 'enum': [ - ], - 'validation': [ - ] - }, - root_map={ - 'validations': { - }, - 'allowed_values': { - }, - 'openapi_types': { - 'index_name': - (str,), - }, - 'attribute_map': { - 'index_name': 'index_name', - }, - 'location_map': { - 'index_name': 'path', - }, - 'collection_format_map': { - } - }, - headers_map={ - 'accept': [ - 'application/json' - ], - 'content_type': [], - }, - api_client=api_client, - callable=__delete_index - ) - - def __describe_index( - self, - index_name, - **kwargs - ): - """describe_index # noqa: E501 - - Get a description of an index. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.describe_index(index_name, async_req=True) - >>> result = thread.get() - - Args: - index_name (str): The name of the index to be described - - Keyword Args: - _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 - will be returned without reading/decoding response data. - Default is True. - _request_timeout (int/float/tuple): timeout setting for this request. If - one number provided, it will be total request timeout. It can also - be a pair (tuple) of (connection, read) timeouts. - Default is None. - _check_input_type (bool): specifies if type checking - should be done one the data sent to the server. - Default is True. - _check_return_type (bool): specifies if type checking - should be done one the data received from the server. - Default is True. - _host_index (int/None): specifies the index of the server - that we want to use. - Default is read from the configuration. - async_req (bool): execute request asynchronously - - Returns: - IndexModel - If the method is called asynchronously, returns the request - thread. - """ - kwargs['async_req'] = kwargs.get( - 'async_req', False - ) - kwargs['_return_http_data_only'] = kwargs.get( - '_return_http_data_only', True - ) - kwargs['_preload_content'] = kwargs.get( - '_preload_content', True - ) - kwargs['_request_timeout'] = kwargs.get( - '_request_timeout', None - ) - kwargs['_check_input_type'] = kwargs.get( - '_check_input_type', True - ) - kwargs['_check_return_type'] = kwargs.get( - '_check_return_type', True - ) - kwargs['_host_index'] = kwargs.get('_host_index') - kwargs['index_name'] = \ - index_name - return self.call_with_http_info(**kwargs) - - self.describe_index = _Endpoint( - settings={ - 'response_type': (IndexModel,), - 'auth': [ - 'ApiKeyAuth' - ], - 'endpoint_path': '/indexes/{index_name}', - 'operation_id': 'describe_index', - 'http_method': 'GET', - 'servers': [ - { - 'url': "https://api.pinecone.io", - 'description': "No description provided", - }, - ] - }, - params_map={ - 'all': [ - 'index_name', - ], - 'required': [ - 'index_name', - ], - 'nullable': [ - ], - 'enum': [ - ], - 'validation': [ - ] - }, - root_map={ - 'validations': { - }, - 'allowed_values': { - }, - 'openapi_types': { - 'index_name': - (str,), - }, - 'attribute_map': { - 'index_name': 'index_name', - }, - 'location_map': { - 'index_name': 'path', - }, - 'collection_format_map': { - } - }, - headers_map={ - 'accept': [ - 'application/json' - ], - 'content_type': [], - }, - api_client=api_client, - callable=__describe_index - ) - - def __list_indexes( - self, - **kwargs - ): - """list_indexes # noqa: E501 - - This operation returns a list of your Pinecone indexes. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.list_indexes(async_req=True) - >>> result = thread.get() - - - Keyword Args: - _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 - will be returned without reading/decoding response data. - Default is True. - _request_timeout (int/float/tuple): timeout setting for this request. If - one number provided, it will be total request timeout. It can also - be a pair (tuple) of (connection, read) timeouts. - Default is None. - _check_input_type (bool): specifies if type checking - should be done one the data sent to the server. - Default is True. - _check_return_type (bool): specifies if type checking - should be done one the data received from the server. - Default is True. - _host_index (int/None): specifies the index of the server - that we want to use. - Default is read from the configuration. - async_req (bool): execute request asynchronously - - Returns: - IndexList - If the method is called asynchronously, returns the request - thread. - """ - kwargs['async_req'] = kwargs.get( - 'async_req', False - ) - kwargs['_return_http_data_only'] = kwargs.get( - '_return_http_data_only', True - ) - kwargs['_preload_content'] = kwargs.get( - '_preload_content', True - ) - kwargs['_request_timeout'] = kwargs.get( - '_request_timeout', None - ) - kwargs['_check_input_type'] = kwargs.get( - '_check_input_type', True - ) - kwargs['_check_return_type'] = kwargs.get( - '_check_return_type', True - ) - kwargs['_host_index'] = kwargs.get('_host_index') - return self.call_with_http_info(**kwargs) - - self.list_indexes = _Endpoint( - settings={ - 'response_type': (IndexList,), - 'auth': [ - 'ApiKeyAuth' - ], - 'endpoint_path': '/indexes', - 'operation_id': 'list_indexes', - 'http_method': 'GET', - 'servers': [ - { - 'url': "https://api.pinecone.io", - 'description': "No description provided", - }, - ] - }, - params_map={ - 'all': [ - ], - 'required': [], - 'nullable': [ - ], - 'enum': [ - ], - 'validation': [ - ] - }, - root_map={ - 'validations': { - }, - 'allowed_values': { - }, - 'openapi_types': { - }, - 'attribute_map': { - }, - 'location_map': { - }, - 'collection_format_map': { - } - }, - headers_map={ - 'accept': [ - 'application/json' - ], - 'content_type': [], - }, - api_client=api_client, - callable=__list_indexes - ) diff --git a/pinecone/core/client/api_client.py b/pinecone/core/client/api_client.py index e7e2feae..de64b8ae 100644 --- a/pinecone/core/client/api_client.py +++ b/pinecone/core/client/api_client.py @@ -761,7 +761,7 @@ def __call__(self, *args, **kwargs): """ This method is invoked when endpoints are called Example: - api_instance = ManagePodIndexesApi() + api_instance = ManageIndexesApi() api_instance.configure_index # this is an instance of the class Endpoint api_instance.configure_index() # this invokes api_instance.configure_index.__call__() which then invokes the callable functions stored in that endpoint at diff --git a/pinecone/core/client/apis/__init__.py b/pinecone/core/client/apis/__init__.py index bc39a4d4..11b2ed34 100644 --- a/pinecone/core/client/apis/__init__.py +++ b/pinecone/core/client/apis/__init__.py @@ -6,7 +6,7 @@ # raise a `RecursionError`. # In order to avoid this, import only the API that you directly need like: # -# from .api.manage_pod_indexes_api import ManagePodIndexesApi +# from .api.manage_indexes_api import ManageIndexesApi # # or import this package, but before doing it, use: # @@ -14,6 +14,5 @@ # sys.setrecursionlimit(n) # Import APIs into API package: -from pinecone.core.client.api.manage_pod_indexes_api import ManagePodIndexesApi -from pinecone.core.client.api.manage_serverless_indexes_api import ManageServerlessIndexesApi +from pinecone.core.client.api.manage_indexes_api import ManageIndexesApi from pinecone.core.client.api.vector_operations_api import VectorOperationsApi diff --git a/pinecone/core/client/model/fetch_response.py b/pinecone/core/client/model/fetch_response.py index a142ed42..632596a9 100644 --- a/pinecone/core/client/model/fetch_response.py +++ b/pinecone/core/client/model/fetch_response.py @@ -30,7 +30,9 @@ def lazy_import(): + from pinecone.core.client.model.usage import Usage from pinecone.core.client.model.vector import Vector + globals()['Usage'] = Usage globals()['Vector'] = Vector @@ -89,6 +91,7 @@ def openapi_types(): return { 'vectors': ({str: (Vector,)},), # noqa: E501 'namespace': (str,), # noqa: E501 + 'usage': (Usage,), # noqa: E501 } @cached_property @@ -99,6 +102,7 @@ def discriminator(): attribute_map = { 'vectors': 'vectors', # noqa: E501 'namespace': 'namespace', # noqa: E501 + 'usage': 'usage', # noqa: E501 } read_only_vars = { @@ -144,6 +148,7 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 _visited_composed_classes = (Animal,) vectors ({str: (Vector,)}): [optional] # noqa: E501 namespace (str): The namespace of the vectors.. [optional] # noqa: E501 + usage (Usage): [optional] # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) @@ -227,6 +232,7 @@ def __init__(self, *args, **kwargs): # noqa: E501 _visited_composed_classes = (Animal,) vectors ({str: (Vector,)}): [optional] # noqa: E501 namespace (str): The namespace of the vectors.. [optional] # noqa: E501 + usage (Usage): [optional] # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) diff --git a/pinecone/core/client/model/query_response.py b/pinecone/core/client/model/query_response.py index 5f932cc4..a81724e1 100644 --- a/pinecone/core/client/model/query_response.py +++ b/pinecone/core/client/model/query_response.py @@ -32,8 +32,10 @@ def lazy_import(): from pinecone.core.client.model.scored_vector import ScoredVector from pinecone.core.client.model.single_query_results import SingleQueryResults + from pinecone.core.client.model.usage import Usage globals()['ScoredVector'] = ScoredVector globals()['SingleQueryResults'] = SingleQueryResults + globals()['Usage'] = Usage class QueryResponse(ModelNormal): @@ -92,6 +94,7 @@ def openapi_types(): 'results': ([SingleQueryResults],), # noqa: E501 'matches': ([ScoredVector],), # noqa: E501 'namespace': (str,), # noqa: E501 + 'usage': (Usage,), # noqa: E501 } @cached_property @@ -103,6 +106,7 @@ def discriminator(): 'results': 'results', # noqa: E501 'matches': 'matches', # noqa: E501 'namespace': 'namespace', # noqa: E501 + 'usage': 'usage', # noqa: E501 } read_only_vars = { @@ -149,6 +153,7 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 results ([SingleQueryResults]): DEPRECATED. The results of each query. The order is the same as `QueryRequest.queries`.. [optional] # noqa: E501 matches ([ScoredVector]): The matches for the vectors.. [optional] # noqa: E501 namespace (str): The namespace for the vectors.. [optional] # noqa: E501 + usage (Usage): [optional] # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) @@ -233,6 +238,7 @@ def __init__(self, *args, **kwargs): # noqa: E501 results ([SingleQueryResults]): DEPRECATED. The results of each query. The order is the same as `QueryRequest.queries`.. [optional] # noqa: E501 matches ([ScoredVector]): The matches for the vectors.. [optional] # noqa: E501 namespace (str): The namespace for the vectors.. [optional] # noqa: E501 + usage (Usage): [optional] # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) diff --git a/pinecone/core/client/model/usage.py b/pinecone/core/client/model/usage.py new file mode 100644 index 00000000..c38b88d2 --- /dev/null +++ b/pinecone/core/client/model/usage.py @@ -0,0 +1,255 @@ +""" + Pineonce.io Public API + + Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. # noqa: E501 + + The version of the OpenAPI document: 1.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from pinecone.core.client.model_utils import ( # noqa: F401 + PineconeApiTypeError, + 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 PineconeApiAttributeError + + + +class Usage(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 = { + } + + @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 { + 'read_units': (int,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'read_units': 'readUnits', # noqa: E501 + } + + read_only_vars = { + } + + _composed_schemas = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """Usage - a model defined in OpenAPI + + 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,) + read_units (int): The number of read units consumed by this operation.. [optional] # noqa: E501 + """ + + _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 PineconeApiTypeError( + "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__,) + + 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, *args, **kwargs): # noqa: E501 + """Usage - a model defined in OpenAPI + + 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,) + read_units (int): The number of read units consumed by this operation.. [optional] # noqa: E501 + """ + + _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 PineconeApiTypeError( + "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__,) + + 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 PineconeApiAttributeError(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/models/__init__.py b/pinecone/core/client/models/__init__.py index 11efdc9d..d15a24e8 100644 --- a/pinecone/core/client/models/__init__.py +++ b/pinecone/core/client/models/__init__.py @@ -44,4 +44,5 @@ 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 +from pinecone.core.client.model.usage import Usage from pinecone.core.client.model.vector import Vector diff --git a/pinecone/core/grpc/protos/vector_service_pb2.py b/pinecone/core/grpc/protos/vector_service_pb2.py index 665ead6c..2bd90fad 100644 --- a/pinecone/core/grpc/protos/vector_service_pb2.py +++ b/pinecone/core/grpc/protos/vector_service_pb2.py @@ -23,7 +23,7 @@ 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\"~\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' + 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\"\"\xe1\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\"\x12\x32\n\x05usage\x18\x03 \x01(\x0b\x32\x06.UsageB\x16\x92\x41\x13J\x11{\"read_units\": 5}H\x00\x88\x01\x01\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\x42\x08\n\x06_usage\"\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\"\"\xaa\x01\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\x12\x32\n\x05usage\x18\x04 \x01(\x0b\x32\x06.UsageB\x16\x92\x41\x13J\x11{\"read_units\": 5}H\x00\x88\x01\x01\x42\x08\n\x06_usage\"G\n\x05Usage\x12/\n\nread_units\x18\x01 \x01(\rB\x16\x92\x41\x13J\x11{\"read_units\": 5}H\x00\x88\x01\x01\x42\r\n\x0b_read_units\"\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,]) @@ -404,8 +404,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1398, - serialized_end=1453, + serialized_start=1450, + serialized_end=1505, ) _FETCHRESPONSE = _descriptor.Descriptor( @@ -430,6 +430,13 @@ 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='usage', full_name='FetchResponse.usage', index=2, + 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\023J\021{\"read_units\": 5}', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), ], extensions=[ ], @@ -441,9 +448,14 @@ syntax='proto3', extension_ranges=[], oneofs=[ + _descriptor.OneofDescriptor( + name='_usage', full_name='FetchResponse._usage', + index=0, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), ], serialized_start=1290, - serialized_end=1453, + serialized_end=1515, ) @@ -502,8 +514,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1456, - serialized_end=1792, + serialized_start=1518, + serialized_end=1854, ) @@ -590,8 +602,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1795, - serialized_end=2301, + serialized_start=1857, + serialized_end=2363, ) @@ -629,8 +641,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2303, - serialized_end=2400, + serialized_start=2365, + serialized_end=2462, ) @@ -663,6 +675,13 @@ 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='usage', full_name='QueryResponse.usage', index=3, + 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=b'\222A\023J\021{\"read_units\": 5}', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), ], extensions=[ ], @@ -674,9 +693,51 @@ syntax='proto3', extension_ranges=[], oneofs=[ + _descriptor.OneofDescriptor( + name='_usage', full_name='QueryResponse._usage', + index=0, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), + ], + serialized_start=2465, + serialized_end=2635, +) + + +_USAGE = _descriptor.Descriptor( + name='Usage', + full_name='Usage', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='read_units', full_name='Usage.read_units', index=0, + number=1, 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\023J\021{\"read_units\": 5}', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ ], - serialized_start=2402, - serialized_end=2510, + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='_read_units', full_name='Usage._read_units', + index=0, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), + ], + serialized_start=2637, + serialized_end=2708, ) @@ -735,8 +796,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2513, - serialized_end=2819, + serialized_start=2711, + serialized_end=3017, ) @@ -760,8 +821,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2821, - serialized_end=2837, + serialized_start=3019, + serialized_end=3035, ) @@ -792,8 +853,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2839, - serialized_end=2907, + serialized_start=3037, + serialized_end=3105, ) @@ -824,8 +885,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2909, - serialized_end=2961, + serialized_start=3107, + serialized_end=3159, ) @@ -863,8 +924,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=3163, - serialized_end=3231, + serialized_start=3361, + serialized_end=3429, ) _DESCRIBEINDEXSTATSRESPONSE = _descriptor.Descriptor( @@ -915,8 +976,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2964, - serialized_end=3374, + serialized_start=3162, + serialized_end=3572, ) _VECTOR.fields_by_name['sparse_values'].message_type = _SPARSEVALUES @@ -928,6 +989,10 @@ _FETCHRESPONSE_VECTORSENTRY.fields_by_name['value'].message_type = _VECTOR _FETCHRESPONSE_VECTORSENTRY.containing_type = _FETCHRESPONSE _FETCHRESPONSE.fields_by_name['vectors'].message_type = _FETCHRESPONSE_VECTORSENTRY +_FETCHRESPONSE.fields_by_name['usage'].message_type = _USAGE +_FETCHRESPONSE.oneofs_by_name['_usage'].fields.append( + _FETCHRESPONSE.fields_by_name['usage']) +_FETCHRESPONSE.fields_by_name['usage'].containing_oneof = _FETCHRESPONSE.oneofs_by_name['_usage'] _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 @@ -936,6 +1001,13 @@ _SINGLEQUERYRESULTS.fields_by_name['matches'].message_type = _SCOREDVECTOR _QUERYRESPONSE.fields_by_name['results'].message_type = _SINGLEQUERYRESULTS _QUERYRESPONSE.fields_by_name['matches'].message_type = _SCOREDVECTOR +_QUERYRESPONSE.fields_by_name['usage'].message_type = _USAGE +_QUERYRESPONSE.oneofs_by_name['_usage'].fields.append( + _QUERYRESPONSE.fields_by_name['usage']) +_QUERYRESPONSE.fields_by_name['usage'].containing_oneof = _QUERYRESPONSE.oneofs_by_name['_usage'] +_USAGE.oneofs_by_name['_read_units'].fields.append( + _USAGE.fields_by_name['read_units']) +_USAGE.fields_by_name['read_units'].containing_oneof = _USAGE.oneofs_by_name['_read_units'] _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 @@ -955,6 +1027,7 @@ DESCRIPTOR.message_types_by_name['QueryRequest'] = _QUERYREQUEST DESCRIPTOR.message_types_by_name['SingleQueryResults'] = _SINGLEQUERYRESULTS DESCRIPTOR.message_types_by_name['QueryResponse'] = _QUERYRESPONSE +DESCRIPTOR.message_types_by_name['Usage'] = _USAGE DESCRIPTOR.message_types_by_name['UpdateRequest'] = _UPDATEREQUEST DESCRIPTOR.message_types_by_name['UpdateResponse'] = _UPDATERESPONSE DESCRIPTOR.message_types_by_name['DescribeIndexStatsRequest'] = _DESCRIBEINDEXSTATSREQUEST @@ -1061,6 +1134,13 @@ }) _sym_db.RegisterMessage(QueryResponse) +Usage = _reflection.GeneratedProtocolMessageType('Usage', (_message.Message,), { + 'DESCRIPTOR' : _USAGE, + '__module__' : 'vector_service_pb2' + # @@protoc_insertion_point(class_scope:Usage) + }) +_sym_db.RegisterMessage(Usage) + UpdateRequest = _reflection.GeneratedProtocolMessageType('UpdateRequest', (_message.Message,), { 'DESCRIPTOR' : _UPDATEREQUEST, '__module__' : 'vector_service_pb2' @@ -1125,6 +1205,7 @@ _FETCHREQUEST.fields_by_name['namespace']._options = None _FETCHRESPONSE_VECTORSENTRY._options = None _FETCHRESPONSE.fields_by_name['namespace']._options = None +_FETCHRESPONSE.fields_by_name['usage']._options = None _QUERYVECTOR.fields_by_name['values']._options = None _QUERYVECTOR.fields_by_name['top_k']._options = None _QUERYVECTOR.fields_by_name['namespace']._options = None @@ -1139,6 +1220,8 @@ _QUERYREQUEST.fields_by_name['id']._options = None _SINGLEQUERYRESULTS.fields_by_name['namespace']._options = None _QUERYRESPONSE.fields_by_name['results']._options = None +_QUERYRESPONSE.fields_by_name['usage']._options = None +_USAGE.fields_by_name['read_units']._options = None _UPDATEREQUEST.fields_by_name['id']._options = None _UPDATEREQUEST.fields_by_name['values']._options = None _UPDATEREQUEST.fields_by_name['set_metadata']._options = None @@ -1157,8 +1240,8 @@ index=0, serialized_options=None, create_key=_descriptor._internal_create_key, - serialized_start=3377, - serialized_end=4078, + serialized_start=3575, + serialized_end=4276, 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 0c2c73f6..bbbae21e 100644 --- a/pinecone/core/grpc/protos/vector_service_pb2.pyi +++ b/pinecone/core/grpc/protos/vector_service_pb2.pyi @@ -1,11 +1,14 @@ -# @generated by generate_proto_mypy_stubs.py. Do not edit! -import sys +""" +@generated by mypy-protobuf. Do not edit manually! +isort:skip_file +""" from google.protobuf.descriptor import ( Descriptor as google___protobuf___descriptor___Descriptor, FileDescriptor as google___protobuf___descriptor___FileDescriptor, ) from google.protobuf.internal.containers import ( + MessageMap as google___protobuf___internal___containers___MessageMap, RepeatedCompositeFieldContainer as google___protobuf___internal___containers___RepeatedCompositeFieldContainer, RepeatedScalarFieldContainer as google___protobuf___internal___containers___RepeatedScalarFieldContainer, ) @@ -21,7 +24,6 @@ from google.protobuf.struct_pb2 import ( from typing import ( Iterable as typing___Iterable, Mapping as typing___Mapping, - MutableMapping as typing___MutableMapping, Optional as typing___Optional, Text as typing___Text, ) @@ -185,14 +187,20 @@ class FetchResponse(google___protobuf___message___Message): namespace: typing___Text = ... @property - def vectors(self) -> typing___MutableMapping[typing___Text, type___Vector]: ... + def vectors(self) -> google___protobuf___internal___containers___MessageMap[typing___Text, type___Vector]: ... + + @property + def usage(self) -> type___Usage: ... def __init__(self, *, vectors : typing___Optional[typing___Mapping[typing___Text, type___Vector]] = None, namespace : typing___Optional[typing___Text] = None, + usage : typing___Optional[type___Usage] = None, ) -> None: ... - def ClearField(self, field_name: typing_extensions___Literal[u"namespace",b"namespace",u"vectors",b"vectors"]) -> None: ... + def HasField(self, field_name: typing_extensions___Literal[u"_usage",b"_usage",u"usage",b"usage"]) -> builtin___bool: ... + def ClearField(self, field_name: typing_extensions___Literal[u"_usage",b"_usage",u"namespace",b"namespace",u"usage",b"usage",u"vectors",b"vectors"]) -> None: ... + def WhichOneof(self, oneof_group: typing_extensions___Literal[u"_usage",b"_usage"]) -> typing_extensions___Literal["usage"]: ... type___FetchResponse = FetchResponse class QueryVector(google___protobuf___message___Message): @@ -278,15 +286,34 @@ class QueryResponse(google___protobuf___message___Message): @property def matches(self) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[type___ScoredVector]: ... + @property + def usage(self) -> type___Usage: ... + def __init__(self, *, results : typing___Optional[typing___Iterable[type___SingleQueryResults]] = None, matches : typing___Optional[typing___Iterable[type___ScoredVector]] = None, namespace : typing___Optional[typing___Text] = None, + usage : typing___Optional[type___Usage] = None, ) -> None: ... - def ClearField(self, field_name: typing_extensions___Literal[u"matches",b"matches",u"namespace",b"namespace",u"results",b"results"]) -> None: ... + def HasField(self, field_name: typing_extensions___Literal[u"_usage",b"_usage",u"usage",b"usage"]) -> builtin___bool: ... + def ClearField(self, field_name: typing_extensions___Literal[u"_usage",b"_usage",u"matches",b"matches",u"namespace",b"namespace",u"results",b"results",u"usage",b"usage"]) -> None: ... + def WhichOneof(self, oneof_group: typing_extensions___Literal[u"_usage",b"_usage"]) -> typing_extensions___Literal["usage"]: ... type___QueryResponse = QueryResponse +class Usage(google___protobuf___message___Message): + DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... + read_units: builtin___int = ... + + def __init__(self, + *, + read_units : typing___Optional[builtin___int] = None, + ) -> None: ... + def HasField(self, field_name: typing_extensions___Literal[u"_read_units",b"_read_units",u"read_units",b"read_units"]) -> builtin___bool: ... + def ClearField(self, field_name: typing_extensions___Literal[u"_read_units",b"_read_units",u"read_units",b"read_units"]) -> None: ... + def WhichOneof(self, oneof_group: typing_extensions___Literal[u"_read_units",b"_read_units"]) -> typing_extensions___Literal["read_units"]: ... +type___Usage = Usage + class UpdateRequest(google___protobuf___message___Message): DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... id: typing___Text = ... @@ -366,7 +393,7 @@ class DescribeIndexStatsResponse(google___protobuf___message___Message): total_vector_count: builtin___int = ... @property - def namespaces(self) -> typing___MutableMapping[typing___Text, type___NamespaceSummary]: ... + def namespaces(self) -> google___protobuf___internal___containers___MessageMap[typing___Text, type___NamespaceSummary]: ... def __init__(self, *, diff --git a/pinecone/grpc/utils.py b/pinecone/grpc/utils.py index 6ca64f3d..f23d70fc 100644 --- a/pinecone/grpc/utils.py +++ b/pinecone/grpc/utils.py @@ -4,6 +4,7 @@ from pinecone.core.client.models import ( Vector as _Vector, + Usage, ScoredVector, SparseValues, FetchResponse, @@ -20,6 +21,7 @@ class QueryResponseKwargs(NamedTuple): namespace: Optional[str] matches: Optional[list] results: Optional[list] + usage: Usage def _generate_request_id() -> str: return str(uuid.uuid4()) @@ -52,13 +54,19 @@ def parse_fetch_response(response: dict): metadata=vec.get("metadata", None), _check_type=False, ) + + usage = parse_usage(response) return FetchResponse( vectors=vd, namespace=namespace, + usage=usage, _check_type=False ) +def parse_usage(response): + u = response.get("usage", {}) + return Usage(read_units=int(u.get("readUnits", 0))) def parse_query_response(response: dict, unary_query: bool, _check_type: bool = False): @@ -101,7 +109,10 @@ def parse_query_response(response: dict, unary_query: bool, _check_type: bool = matches = [] results = res - kw = QueryResponseKwargs(_check_type, namespace, matches, results) + usage = parse_usage(response) + + + kw = QueryResponseKwargs(_check_type, namespace, matches, results, usage) kw_dict = kw._asdict() kw_dict["_check_type"] = kw.check_type return QueryResponse(**kw._asdict()) diff --git a/tests/integration/data/test_fetch.py b/tests/integration/data/test_fetch.py index feef6b5f..7151be55 100644 --- a/tests/integration/data/test_fetch.py +++ b/tests/integration/data/test_fetch.py @@ -16,6 +16,11 @@ def test_fetch_multiple_by_id( results = idx.fetch(ids=['1', '2', '4'], namespace=target_namespace) assert isinstance(results, FetchResponse) == True + + assert results.usage != None + assert results.usage['read_units'] != None + assert results.usage['read_units'] > 0 + assert results.namespace == target_namespace assert len(results.vectors) == 3 assert results.vectors['1'].id == '1' diff --git a/tests/integration/data/test_query.py b/tests/integration/data/test_query.py index 45a83a69..e1c7ba88 100644 --- a/tests/integration/data/test_query.py +++ b/tests/integration/data/test_query.py @@ -18,8 +18,9 @@ def test_query_by_id(self, idx, namespace, use_nondefault_namespace): assert isinstance(results, QueryResponse) == True assert results.namespace == target_namespace - # TODO fix usage - # assert results.usage != None + assert results.usage != None + assert results.usage['read_units'] != None + assert results.usage['read_units'] > 0 # By default, does not include values or metadata record_with_metadata = find_by_id(results.matches, '4')