Skip to content

Commit c1688f6

Browse files
authored
Expose new pc.inference.list_models() and pc.inference.get_model() (#488)
## Problem We need to expose a new endpoint for discovering available inference models ## Solution - Regenerate code off the latest spec - Wire the new method up in the sync and async implementations of Inference - `pc.inference.get_model` - `pc.inference.list_models` - Make some adjustments in model_utils to be less fragile if unexpected values appear in enum fields - Implement new tests for these list_models endpoints. ## Usage ```python from pinecone import Pinecone pc = Pinecone() models = pc.inference.list_models() models[0] # { # "model": "llama-text-embed-v2", # "short_description": "A high performance dense embedding model optimized for multilingual and cross-lingual text question-answering retrieval with support for long documents (up to 2048 tokens) and dynamic embedding size (Matryoshka Embeddings).", # "type": "embed", # "supported_parameters": [ # { # "parameter": "input_type", # "type": "one_of", # "value_type": "string", # "required": true, # "allowed_values": [ # "query", # "passage" # ] # }, # { # "parameter": "truncate", # "type": "one_of", # "value_type": "string", # "required": false, # "default": "END", # "allowed_values": [ # "END", # "NONE", # "START" # ] # }, # { # "parameter": "dimension", # "type": "one_of", # "value_type": "integer", # "required": false, # "default": 1024, # "allowed_values": [ # 384, # 512, # 768, # 1024, # 2048 # ] # } # ], # "vector_type": "dense", # "default_dimension": 1024, # "modality": "text", # "max_sequence_length": 2048, # "max_batch_size": 96, # "provider_name": "NVIDIA", # "supported_metrics": [ # "Cosine", # "DotProduct" # ], # "supported_dimensions": [ # 384, # 512, # 768, # 1024, # 2048 # ] # } ``` And async ```python import asyncio from pinecone import PineconeAsyncio async def main(): with PineconeAsyncio() as pc: await pc.inference.list_models() asyncio.run(main()) ``` ## Type of Change - [x] New feature (non-breaking change which adds functionality)
1 parent 6a12a63 commit c1688f6

File tree

119 files changed

+1389
-584
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+1389
-584
lines changed

pinecone/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
_inference_lazy_imports = {
1919
"RerankModel": ("pinecone.inference", "RerankModel"),
2020
"EmbedModel": ("pinecone.inference", "EmbedModel"),
21+
"ModelInfo": ("pinecone.inference.models", "ModelInfo"),
22+
"ModelInfoList": ("pinecone.inference.models", "ModelInfoList"),
23+
"EmbeddingsList": ("pinecone.inference.models", "EmbeddingsList"),
24+
"RerankResult": ("pinecone.inference.models", "RerankResult"),
2125
}
2226

2327
_db_data_lazy_imports = {

pinecone/__init__.pyi

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
from pinecone.config import Config
22
from pinecone.config import ConfigBuilder
33
from pinecone.config import PineconeConfig
4-
from pinecone.inference import RerankModel
5-
from pinecone.inference import EmbedModel
4+
from pinecone.inference import (
5+
RerankModel,
6+
EmbedModel,
7+
ModelInfo,
8+
ModelInfoList,
9+
EmbeddingsList,
10+
RerankResult,
11+
)
612
from pinecone.db_data.dataclasses import (
713
Vector,
814
SparseValues,
@@ -69,6 +75,10 @@ __all__ = [
6975
# Inference classes
7076
"RerankModel",
7177
"EmbedModel",
78+
"ModelInfo",
79+
"ModelInfoList",
80+
"EmbeddingsList",
81+
"RerankResult",
7282
# Data classes
7383
"Vector",
7484
"SparseValues",

pinecone/core/openapi/db_control/model/backup_list.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
151151
pagination (PaginationResponse): [optional] # noqa: E501
152152
"""
153153

154+
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", False)
154155
_check_type = kwargs.pop("_check_type", True)
155156
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
156157
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -168,6 +169,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
168169
)
169170

170171
self._data_store = {}
172+
self._enforce_allowed_values = _enforce_allowed_values
171173
self._check_type = _check_type
172174
self._spec_property_naming = _spec_property_naming
173175
self._path_to_item = _path_to_item
@@ -188,6 +190,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
188190

189191
required_properties = set(
190192
[
193+
"_enforce_allowed_values",
191194
"_data_store",
192195
"_check_type",
193196
"_spec_property_naming",
@@ -236,6 +239,7 @@ def __init__(self, *args, **kwargs) -> None: # noqa: E501
236239
pagination (PaginationResponse): [optional] # noqa: E501
237240
"""
238241

242+
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", True)
239243
_check_type = kwargs.pop("_check_type", True)
240244
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
241245
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -251,6 +255,7 @@ def __init__(self, *args, **kwargs) -> None: # noqa: E501
251255
)
252256

253257
self._data_store = {}
258+
self._enforce_allowed_values = _enforce_allowed_values
254259
self._check_type = _check_type
255260
self._spec_property_naming = _spec_property_naming
256261
self._path_to_item = _path_to_item

pinecone/core/openapi/db_control/model/backup_model.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ def _from_openapi_data(
204204
created_at (str): Timestamp when the backup was created. [optional] # noqa: E501
205205
"""
206206

207+
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", False)
207208
_check_type = kwargs.pop("_check_type", True)
208209
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
209210
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -221,6 +222,7 @@ def _from_openapi_data(
221222
)
222223

223224
self._data_store = {}
225+
self._enforce_allowed_values = _enforce_allowed_values
224226
self._check_type = _check_type
225227
self._spec_property_naming = _spec_property_naming
226228
self._path_to_item = _path_to_item
@@ -247,6 +249,7 @@ def _from_openapi_data(
247249

248250
required_properties = set(
249251
[
252+
"_enforce_allowed_values",
250253
"_data_store",
251254
"_check_type",
252255
"_spec_property_naming",
@@ -312,6 +315,7 @@ def __init__(
312315
created_at (str): Timestamp when the backup was created. [optional] # noqa: E501
313316
"""
314317

318+
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", True)
315319
_check_type = kwargs.pop("_check_type", True)
316320
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
317321
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -327,6 +331,7 @@ def __init__(
327331
)
328332

329333
self._data_store = {}
334+
self._enforce_allowed_values = _enforce_allowed_values
330335
self._check_type = _check_type
331336
self._spec_property_naming = _spec_property_naming
332337
self._path_to_item = _path_to_item

pinecone/core/openapi/db_control/model/byoc_spec.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ def _from_openapi_data(cls: Type[T], environment, *args, **kwargs) -> T: # noqa
140140
_visited_composed_classes = (Animal,)
141141
"""
142142

143+
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", False)
143144
_check_type = kwargs.pop("_check_type", True)
144145
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
145146
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -157,6 +158,7 @@ def _from_openapi_data(cls: Type[T], environment, *args, **kwargs) -> T: # noqa
157158
)
158159

159160
self._data_store = {}
161+
self._enforce_allowed_values = _enforce_allowed_values
160162
self._check_type = _check_type
161163
self._spec_property_naming = _spec_property_naming
162164
self._path_to_item = _path_to_item
@@ -178,6 +180,7 @@ def _from_openapi_data(cls: Type[T], environment, *args, **kwargs) -> T: # noqa
178180

179181
required_properties = set(
180182
[
183+
"_enforce_allowed_values",
181184
"_data_store",
182185
"_check_type",
183186
"_spec_property_naming",
@@ -227,6 +230,7 @@ def __init__(self, environment, *args, **kwargs) -> None: # noqa: E501
227230
_visited_composed_classes = (Animal,)
228231
"""
229232

233+
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", True)
230234
_check_type = kwargs.pop("_check_type", True)
231235
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
232236
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -242,6 +246,7 @@ def __init__(self, environment, *args, **kwargs) -> None: # noqa: E501
242246
)
243247

244248
self._data_store = {}
249+
self._enforce_allowed_values = _enforce_allowed_values
245250
self._check_type = _check_type
246251
self._spec_property_naming = _spec_property_naming
247252
self._path_to_item = _path_to_item

pinecone/core/openapi/db_control/model/collection_list.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
146146
collections ([CollectionModel]): [optional] # noqa: E501
147147
"""
148148

149+
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", False)
149150
_check_type = kwargs.pop("_check_type", True)
150151
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
151152
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -163,6 +164,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
163164
)
164165

165166
self._data_store = {}
167+
self._enforce_allowed_values = _enforce_allowed_values
166168
self._check_type = _check_type
167169
self._spec_property_naming = _spec_property_naming
168170
self._path_to_item = _path_to_item
@@ -183,6 +185,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
183185

184186
required_properties = set(
185187
[
188+
"_enforce_allowed_values",
186189
"_data_store",
187190
"_check_type",
188191
"_spec_property_naming",
@@ -230,6 +233,7 @@ def __init__(self, *args, **kwargs) -> None: # noqa: E501
230233
collections ([CollectionModel]): [optional] # noqa: E501
231234
"""
232235

236+
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", True)
233237
_check_type = kwargs.pop("_check_type", True)
234238
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
235239
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -245,6 +249,7 @@ def __init__(self, *args, **kwargs) -> None: # noqa: E501
245249
)
246250

247251
self._data_store = {}
252+
self._enforce_allowed_values = _enforce_allowed_values
248253
self._check_type = _check_type
249254
self._spec_property_naming = _spec_property_naming
250255
self._path_to_item = _path_to_item

pinecone/core/openapi/db_control/model/collection_model.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ def _from_openapi_data(cls: Type[T], name, status, environment, *args, **kwargs)
163163
vector_count (int): The number of records stored in the collection. [optional] # noqa: E501
164164
"""
165165

166+
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", False)
166167
_check_type = kwargs.pop("_check_type", True)
167168
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
168169
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -180,6 +181,7 @@ def _from_openapi_data(cls: Type[T], name, status, environment, *args, **kwargs)
180181
)
181182

182183
self._data_store = {}
184+
self._enforce_allowed_values = _enforce_allowed_values
183185
self._check_type = _check_type
184186
self._spec_property_naming = _spec_property_naming
185187
self._path_to_item = _path_to_item
@@ -203,6 +205,7 @@ def _from_openapi_data(cls: Type[T], name, status, environment, *args, **kwargs)
203205

204206
required_properties = set(
205207
[
208+
"_enforce_allowed_values",
206209
"_data_store",
207210
"_check_type",
208211
"_spec_property_naming",
@@ -257,6 +260,7 @@ def __init__(self, name, status, environment, *args, **kwargs) -> None: # noqa:
257260
vector_count (int): The number of records stored in the collection. [optional] # noqa: E501
258261
"""
259262

263+
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", True)
260264
_check_type = kwargs.pop("_check_type", True)
261265
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
262266
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -272,6 +276,7 @@ def __init__(self, name, status, environment, *args, **kwargs) -> None: # noqa:
272276
)
273277

274278
self._data_store = {}
279+
self._enforce_allowed_values = _enforce_allowed_values
275280
self._check_type = _check_type
276281
self._spec_property_naming = _spec_property_naming
277282
self._path_to_item = _path_to_item

pinecone/core/openapi/db_control/model/configure_index_request.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
165165
embed (ConfigureIndexRequestEmbed): [optional] # noqa: E501
166166
"""
167167

168+
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", False)
168169
_check_type = kwargs.pop("_check_type", True)
169170
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
170171
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -182,6 +183,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
182183
)
183184

184185
self._data_store = {}
186+
self._enforce_allowed_values = _enforce_allowed_values
185187
self._check_type = _check_type
186188
self._spec_property_naming = _spec_property_naming
187189
self._path_to_item = _path_to_item
@@ -202,6 +204,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
202204

203205
required_properties = set(
204206
[
207+
"_enforce_allowed_values",
205208
"_data_store",
206209
"_check_type",
207210
"_spec_property_naming",
@@ -252,6 +255,7 @@ def __init__(self, *args, **kwargs) -> None: # noqa: E501
252255
embed (ConfigureIndexRequestEmbed): [optional] # noqa: E501
253256
"""
254257

258+
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", True)
255259
_check_type = kwargs.pop("_check_type", True)
256260
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
257261
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -267,6 +271,7 @@ def __init__(self, *args, **kwargs) -> None: # noqa: E501
267271
)
268272

269273
self._data_store = {}
274+
self._enforce_allowed_values = _enforce_allowed_values
270275
self._check_type = _check_type
271276
self._spec_property_naming = _spec_property_naming
272277
self._path_to_item = _path_to_item

pinecone/core/openapi/db_control/model/configure_index_request_embed.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
147147
write_parameters ({str: (bool, dict, float, int, list, str, none_type)}): The write parameters for the embedding model. [optional] # noqa: E501
148148
"""
149149

150+
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", False)
150151
_check_type = kwargs.pop("_check_type", True)
151152
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
152153
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -164,6 +165,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
164165
)
165166

166167
self._data_store = {}
168+
self._enforce_allowed_values = _enforce_allowed_values
167169
self._check_type = _check_type
168170
self._spec_property_naming = _spec_property_naming
169171
self._path_to_item = _path_to_item
@@ -184,6 +186,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
184186

185187
required_properties = set(
186188
[
189+
"_enforce_allowed_values",
187190
"_data_store",
188191
"_check_type",
189192
"_spec_property_naming",
@@ -234,6 +237,7 @@ def __init__(self, *args, **kwargs) -> None: # noqa: E501
234237
write_parameters ({str: (bool, dict, float, int, list, str, none_type)}): The write parameters for the embedding model. [optional] # noqa: E501
235238
"""
236239

240+
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", True)
237241
_check_type = kwargs.pop("_check_type", True)
238242
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
239243
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -249,6 +253,7 @@ def __init__(self, *args, **kwargs) -> None: # noqa: E501
249253
)
250254

251255
self._data_store = {}
256+
self._enforce_allowed_values = _enforce_allowed_values
252257
self._check_type = _check_type
253258
self._spec_property_naming = _spec_property_naming
254259
self._path_to_item = _path_to_item

pinecone/core/openapi/db_control/model/configure_index_request_spec.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ def _from_openapi_data(cls: Type[T], pod, *args, **kwargs) -> T: # noqa: E501
150150
_visited_composed_classes = (Animal,)
151151
"""
152152

153+
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", False)
153154
_check_type = kwargs.pop("_check_type", True)
154155
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
155156
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -167,6 +168,7 @@ def _from_openapi_data(cls: Type[T], pod, *args, **kwargs) -> T: # noqa: E501
167168
)
168169

169170
self._data_store = {}
171+
self._enforce_allowed_values = _enforce_allowed_values
170172
self._check_type = _check_type
171173
self._spec_property_naming = _spec_property_naming
172174
self._path_to_item = _path_to_item
@@ -188,6 +190,7 @@ def _from_openapi_data(cls: Type[T], pod, *args, **kwargs) -> T: # noqa: E501
188190

189191
required_properties = set(
190192
[
193+
"_enforce_allowed_values",
191194
"_data_store",
192195
"_check_type",
193196
"_spec_property_naming",
@@ -237,6 +240,7 @@ def __init__(self, pod, *args, **kwargs) -> None: # noqa: E501
237240
_visited_composed_classes = (Animal,)
238241
"""
239242

243+
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", True)
240244
_check_type = kwargs.pop("_check_type", True)
241245
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
242246
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -252,6 +256,7 @@ def __init__(self, pod, *args, **kwargs) -> None: # noqa: E501
252256
)
253257

254258
self._data_store = {}
259+
self._enforce_allowed_values = _enforce_allowed_values
255260
self._check_type = _check_type
256261
self._spec_property_naming = _spec_property_naming
257262
self._path_to_item = _path_to_item

pinecone/core/openapi/db_control/model/configure_index_request_spec_pod.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
143143
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
144144
"""
145145

146+
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", False)
146147
_check_type = kwargs.pop("_check_type", True)
147148
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
148149
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -160,6 +161,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
160161
)
161162

162163
self._data_store = {}
164+
self._enforce_allowed_values = _enforce_allowed_values
163165
self._check_type = _check_type
164166
self._spec_property_naming = _spec_property_naming
165167
self._path_to_item = _path_to_item
@@ -180,6 +182,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
180182

181183
required_properties = set(
182184
[
185+
"_enforce_allowed_values",
183186
"_data_store",
184187
"_check_type",
185188
"_spec_property_naming",
@@ -228,6 +231,7 @@ def __init__(self, *args, **kwargs) -> None: # noqa: E501
228231
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
229232
"""
230233

234+
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", True)
231235
_check_type = kwargs.pop("_check_type", True)
232236
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
233237
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -243,6 +247,7 @@ def __init__(self, *args, **kwargs) -> None: # noqa: E501
243247
)
244248

245249
self._data_store = {}
250+
self._enforce_allowed_values = _enforce_allowed_values
246251
self._check_type = _check_type
247252
self._spec_property_naming = _spec_property_naming
248253
self._path_to_item = _path_to_item

0 commit comments

Comments
 (0)