Skip to content

Commit 42ed389

Browse files
authored
Support Sparse values in index API (pinecone-io#133)
1 parent f9c7c2c commit 42ed389

18 files changed

+656
-110
lines changed

pinecone/core/client/api/index_operations_api.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __configure_index(
5252
):
5353
"""configure_index # noqa: E501
5454
55-
Configure index to change pod type and number of replicas. # noqa: E501
55+
This operation specifies the pod type and number of replicas for an index. # noqa: E501
5656
This method makes a synchronous HTTP request by default. To make an
5757
asynchronous HTTP request, please pass async_req=True
5858
@@ -63,7 +63,7 @@ def __configure_index(
6363
index_name (str): The name of the index
6464
6565
Keyword Args:
66-
patch_request (PatchRequest): The desired configuration changes for the index.. [optional]
66+
patch_request (PatchRequest): The desired pod type and replica configuration for the index.. [optional]
6767
_return_http_data_only (bool): response data without head status
6868
code and headers. Default is True.
6969
_preload_content (bool): if False, the urllib3.HTTPResponse object

pinecone/core/client/api/vector_operations_api.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def __describe_index_stats(
303303
):
304304
"""DescribeIndexStats # noqa: E501
305305
306-
The `DescribeIndexStats` operation returns statistics about the index's contents. For example: The vector count per namespace and the number of dimensions. # noqa: E501
306+
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
307307
This method makes a synchronous HTTP request by default. To make an
308308
asynchronous HTTP request, please pass async_req=True
309309
@@ -422,7 +422,7 @@ def __describe_index_stats1(
422422
):
423423
"""DescribeIndexStats # noqa: E501
424424
425-
The `DescribeIndexStats` operation returns statistics about the index's contents. For example: The vector count per namespace and the number of dimensions. # noqa: E501
425+
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
426426
This method makes a synchronous HTTP request by default. To make an
427427
asynchronous HTTP request, please pass async_req=True
428428

pinecone/core/client/model/create_request.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def _from_openapi_data(cls, name, dimension, *args, **kwargs): # noqa: E501
168168
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
169169
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
170170
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
171-
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
171+
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
172172
index_config (dict): [optional] # noqa: E501
173173
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
174174
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
264264
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
265265
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
266266
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
267-
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
267+
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
268268
index_config (dict): [optional] # noqa: E501
269269
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
270270
source_collection (str): The name of the collection to create an index from. [optional] # noqa: E501

pinecone/core/client/model/index_meta_database.py

+4
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def openapi_types():
101101
'shards': (int,), # noqa: E501
102102
'pod_type': (str,), # noqa: E501
103103
'index_config': (dict,), # noqa: E501
104+
'metadata_config': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501
104105
'status': (IndexMetaDatabaseStatus,), # noqa: E501
105106
}
106107

@@ -119,6 +120,7 @@ def discriminator():
119120
'shards': 'shards', # noqa: E501
120121
'pod_type': 'pod_type', # noqa: E501
121122
'index_config': 'index_config', # noqa: E501
123+
'metadata_config': 'metadata_config', # noqa: E501
122124
'status': 'status', # noqa: E501
123125
}
124126

@@ -172,6 +174,7 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501
172174
shards (int): [optional] # noqa: E501
173175
pod_type (str): [optional] # noqa: E501
174176
index_config (dict): [optional] # noqa: E501
177+
metadata_config ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): [optional] # noqa: E501
175178
status (IndexMetaDatabaseStatus): [optional] # noqa: E501
176179
"""
177180

@@ -263,6 +266,7 @@ def __init__(self, *args, **kwargs): # noqa: E501
263266
shards (int): [optional] # noqa: E501
264267
pod_type (str): [optional] # noqa: E501
265268
index_config (dict): [optional] # noqa: E501
269+
metadata_config ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): [optional] # noqa: E501
266270
status (IndexMetaDatabaseStatus): [optional] # noqa: E501
267271
"""
268272

pinecone/core/client/model/patch_request.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501
142142
through its discriminator because we passed in
143143
_visited_composed_classes = (Animal,)
144144
replicas (int): The desired number of replicas for the index.. [optional] # noqa: E501
145-
pod_type (str): The new pod type for the index.. [optional] # noqa: E501
145+
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
146146
"""
147147

148148
_check_type = kwargs.pop('_check_type', True)
@@ -225,7 +225,7 @@ def __init__(self, *args, **kwargs): # noqa: E501
225225
through its discriminator because we passed in
226226
_visited_composed_classes = (Animal,)
227227
replicas (int): The desired number of replicas for the index.. [optional] # noqa: E501
228-
pod_type (str): The new pod type for the index.. [optional] # noqa: E501
228+
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
229229
"""
230230

231231
_check_type = kwargs.pop('_check_type', True)

pinecone/core/client/model/query_request.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636

3737
def lazy_import():
3838
from pinecone.core.client.model.query_vector import QueryVector
39+
from pinecone.core.client.model.sparse_values import SparseValues
3940
globals()['QueryVector'] = QueryVector
41+
globals()['SparseValues'] = SparseValues
4042

4143

4244
class QueryRequest(ModelNormal):
@@ -110,6 +112,7 @@ def openapi_types():
110112
'include_metadata': (bool,), # noqa: E501
111113
'queries': ([QueryVector],), # noqa: E501
112114
'vector': ([float],), # noqa: E501
115+
'sparse_vector': (SparseValues,), # noqa: E501
113116
'id': (str,), # noqa: E501
114117
}
115118

@@ -126,6 +129,7 @@ def discriminator():
126129
'include_metadata': 'includeMetadata', # noqa: E501
127130
'queries': 'queries', # noqa: E501
128131
'vector': 'vector', # noqa: E501
132+
'sparse_vector': 'sparseVector', # noqa: E501
129133
'id': 'id', # noqa: E501
130134
}
131135

@@ -179,6 +183,7 @@ def _from_openapi_data(cls, top_k, *args, **kwargs): # noqa: E501
179183
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
180184
queries ([QueryVector]): DEPRECATED. The query vectors. Each `query()` request can contain only one of the parameters `queries`, `vector`, or `id`.. [optional] # noqa: E501
181185
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
186+
sparse_vector (SparseValues): [optional] # noqa: E501
182187
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
183188
"""
184189

@@ -271,6 +276,7 @@ def __init__(self, top_k, *args, **kwargs): # noqa: E501
271276
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
272277
queries ([QueryVector]): DEPRECATED. The query vectors. Each `query()` request can contain only one of the parameters `queries`, `vector`, or `id`.. [optional] # noqa: E501
273278
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
279+
sparse_vector (SparseValues): The sparse values of the query vector [optional] # noqa: E501
274280
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
275281
"""
276282

@@ -308,4 +314,4 @@ def __init__(self, top_k, *args, **kwargs): # noqa: E501
308314
setattr(self, var_name, var_value)
309315
if var_name in self.read_only_vars:
310316
raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate "
311-
f"class with read only attributes.")
317+
f"class with read only attributes.")

pinecone/core/client/model/query_vector.py

+10
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
from pinecone.core.client.exceptions import ApiAttributeError
3535

3636

37+
def lazy_import():
38+
from pinecone.core.client.model.sparse_values import SparseValues
39+
globals()['SparseValues'] = SparseValues
40+
3741

3842
class QueryVector(ModelNormal):
3943
"""NOTE: This class is auto generated by OpenAPI Generator.
@@ -77,6 +81,7 @@ def additional_properties_type():
7781
This must be a method because a model may have properties that are
7882
of type self, this must run after the class is loaded
7983
"""
84+
lazy_import()
8085
return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501
8186

8287
_nullable = False
@@ -91,8 +96,10 @@ def openapi_types():
9196
openapi_types (dict): The key is attribute name
9297
and the value is attribute type.
9398
"""
99+
lazy_import()
94100
return {
95101
'values': ([float],), # noqa: E501
102+
'sparse_values': (SparseValues,), # noqa: E501
96103
'top_k': (int,), # noqa: E501
97104
'namespace': (str,), # noqa: E501
98105
'filter': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501
@@ -105,6 +112,7 @@ def discriminator():
105112

106113
attribute_map = {
107114
'values': 'values', # noqa: E501
115+
'sparse_values': 'sparseValues', # noqa: E501
108116
'top_k': 'topK', # noqa: E501
109117
'namespace': 'namespace', # noqa: E501
110118
'filter': 'filter', # noqa: E501
@@ -154,6 +162,7 @@ def _from_openapi_data(cls, values, *args, **kwargs): # noqa: E501
154162
Animal class but this time we won't travel
155163
through its discriminator because we passed in
156164
_visited_composed_classes = (Animal,)
165+
sparse_values (SparseValues): The sparse data of the query vector [optional] # noqa: E501
157166
top_k (int): An override for the number of results to return for this query vector.. [optional] # noqa: E501
158167
namespace (str): An override the namespace to search.. [optional] # noqa: E501
159168
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
242251
Animal class but this time we won't travel
243252
through its discriminator because we passed in
244253
_visited_composed_classes = (Animal,)
254+
sparse_values (SparseValues): This is the sparse data of the vector [optional] # noqa: E501
245255
top_k (int): An override for the number of results to return for this query vector.. [optional] # noqa: E501
246256
namespace (str): An override the namespace to search.. [optional] # noqa: E501
247257
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

pinecone/core/client/model/scored_vector.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
from pinecone.core.client.exceptions import ApiAttributeError
3535

3636

37+
def lazy_import():
38+
from pinecone.core.client.model.sparse_values import SparseValues
39+
globals()['SparseValues'] = SparseValues
40+
3741

3842
class ScoredVector(ModelNormal):
3943
"""NOTE: This class is auto generated by OpenAPI Generator.
@@ -75,6 +79,7 @@ def additional_properties_type():
7579
This must be a method because a model may have properties that are
7680
of type self, this must run after the class is loaded
7781
"""
82+
lazy_import()
7883
return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501
7984

8085
_nullable = False
@@ -89,11 +94,13 @@ def openapi_types():
8994
openapi_types (dict): The key is attribute name
9095
and the value is attribute type.
9196
"""
97+
lazy_import()
9298
return {
9399
'id': (str,), # noqa: E501
94100
'score': (float,), # noqa: E501
95101
'values': ([float],), # noqa: E501
96-
'metadata': ({str: (bool, date, dict, float, int, list, str, none_type)},), # noqa: E501
102+
'sparse_values': (SparseValues,), # noqa: E501
103+
'metadata': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501
97104
}
98105

99106
@cached_property
@@ -105,6 +112,7 @@ def discriminator():
105112
'id': 'id', # noqa: E501
106113
'score': 'score', # noqa: E501
107114
'values': 'values', # noqa: E501
115+
'sparse_values': 'sparseValues', # noqa: E501
108116
'metadata': 'metadata', # noqa: E501
109117
}
110118

@@ -154,6 +162,7 @@ def _from_openapi_data(cls, id, *args, **kwargs): # noqa: E501
154162
_visited_composed_classes = (Animal,)
155163
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
156164
values ([float]): This is the vector data, if it is requested.. [optional] # noqa: E501
165+
sparse_values (SparseValues): the sparse data of the vector [optional] # noqa: E501
157166
metadata ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): This is the metadata, if it is requested.. [optional] # noqa: E501
158167
"""
159168

@@ -242,6 +251,7 @@ def __init__(self, id, *args, **kwargs): # noqa: E501
242251
_visited_composed_classes = (Animal,)
243252
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
244253
values ([float]): This is the vector data, if it is requested.. [optional] # noqa: E501
254+
sparse_values (SparseValues): This is the sparse data of the vector [optional] # noqa: E501
245255
metadata ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): This is the metadata, if it is requested.. [optional] # noqa: E501
246256
"""
247257

0 commit comments

Comments
 (0)