|
19 | 19 | from pinecone.core.openapi.db_control.model.configure_index_request_spec_pod import ( |
20 | 20 | ConfigureIndexRequestSpecPod, |
21 | 21 | ) |
| 22 | +from pinecone.core.openapi.db_control.model.configure_index_request_embed import ( |
| 23 | + ConfigureIndexRequestEmbed, |
| 24 | +) |
22 | 25 | from pinecone.core.openapi.db_control.model.deletion_protection import ( |
23 | 26 | DeletionProtection as DeletionProtectionModel, |
24 | 27 | ) |
|
45 | 48 | GcpRegion, |
46 | 49 | AzureRegion, |
47 | 50 | ) |
48 | | -from .types import CreateIndexForModelEmbedTypedDict |
| 51 | +from .types import CreateIndexForModelEmbedTypedDict, ConfigureIndexEmbed |
49 | 52 |
|
50 | 53 |
|
51 | 54 | logger = logging.getLogger(__name__) |
@@ -241,6 +244,7 @@ def configure_index_request( |
241 | 244 | pod_type: Optional[Union[PodType, str]] = None, |
242 | 245 | deletion_protection: Optional[Union[DeletionProtection, str]] = None, |
243 | 246 | tags: Optional[Dict[str, str]] = None, |
| 247 | + embed: Optional[Union[ConfigureIndexEmbed, Dict]] = None, |
244 | 248 | ): |
245 | 249 | if deletion_protection is None: |
246 | 250 | dp = DeletionProtectionModel(description.deletion_protection) |
@@ -271,13 +275,24 @@ def configure_index_request( |
271 | 275 | if replicas: |
272 | 276 | pod_config_args.update(replicas=replicas) |
273 | 277 |
|
274 | | - if pod_config_args != {}: |
| 278 | + embed_config = None |
| 279 | + if embed is not None: |
| 280 | + embed_config = ConfigureIndexRequestEmbed(**dict(embed)) |
| 281 | + |
| 282 | + spec = None |
| 283 | + if pod_config_args: |
275 | 284 | spec = ConfigureIndexRequestSpec(pod=ConfigureIndexRequestSpecPod(**pod_config_args)) |
276 | | - req = ConfigureIndexRequest(deletion_protection=dp, spec=spec, tags=IndexTags(**tags)) |
277 | | - else: |
278 | | - req = ConfigureIndexRequest(deletion_protection=dp, tags=IndexTags(**tags)) |
279 | 285 |
|
280 | | - return req |
| 286 | + args_dict = parse_non_empty_args( |
| 287 | + [ |
| 288 | + ("deletion_protection", dp), |
| 289 | + ("tags", IndexTags(**tags)), |
| 290 | + ("spec", spec), |
| 291 | + ("embed", embed_config), |
| 292 | + ] |
| 293 | + ) |
| 294 | + |
| 295 | + return ConfigureIndexRequest(**args_dict) |
281 | 296 |
|
282 | 297 | @staticmethod |
283 | 298 | def create_collection_request(name: str, source: str) -> CreateCollectionRequest: |
|
0 commit comments