1
1
from abc import ABC , abstractmethod
2
2
3
- from typing import Optional , Dict , Union
4
-
5
-
6
- from pinecone .models import (
7
- ServerlessSpec ,
8
- PodSpec ,
9
- IndexList ,
10
- CollectionList ,
11
- IndexModel ,
12
- IndexEmbed ,
13
- )
14
- from pinecone .enums import (
15
- Metric ,
16
- VectorType ,
17
- DeletionProtection ,
18
- PodType ,
19
- CloudProvider ,
20
- AwsRegion ,
21
- GcpRegion ,
22
- AzureRegion ,
23
- )
24
- from .types import CreateIndexForModelEmbedTypedDict
25
-
26
-
27
- class PineconeDBControlInterface (ABC ):
3
+ from typing import Optional , Dict , Union , TYPE_CHECKING
4
+
5
+ if TYPE_CHECKING :
6
+ from pinecone .models import (
7
+ ServerlessSpec ,
8
+ PodSpec ,
9
+ IndexList ,
10
+ CollectionList ,
11
+ IndexModel ,
12
+ IndexEmbed ,
13
+ )
14
+ from pinecone .enums import (
15
+ Metric ,
16
+ VectorType ,
17
+ DeletionProtection ,
18
+ PodType ,
19
+ CloudProvider ,
20
+ AwsRegion ,
21
+ GcpRegion ,
22
+ AzureRegion ,
23
+ )
24
+ from .types import CreateIndexForModelEmbedTypedDict
25
+
26
+
27
+ class LegacyPineconeDBControlInterface (ABC ):
28
28
@abstractmethod
29
29
def __init__ (
30
30
self ,
@@ -190,14 +190,16 @@ def __init__(
190
190
def create_index (
191
191
self ,
192
192
name : str ,
193
- spec : Union [Dict , ServerlessSpec , PodSpec ],
193
+ spec : Union [Dict , " ServerlessSpec" , " PodSpec" ],
194
194
dimension : Optional [int ],
195
- metric : Optional [Union [Metric , str ]] = Metric .COSINE ,
195
+ metric : Optional [Union [" Metric" , str ]] = " Metric.COSINE" ,
196
196
timeout : Optional [int ] = None ,
197
- deletion_protection : Optional [Union [DeletionProtection , str ]] = DeletionProtection .DISABLED ,
198
- vector_type : Optional [Union [VectorType , str ]] = VectorType .DENSE ,
197
+ deletion_protection : Optional [
198
+ Union ["DeletionProtection" , str ]
199
+ ] = "DeletionProtection.DISABLED" ,
200
+ vector_type : Optional [Union ["VectorType" , str ]] = "VectorType.DENSE" ,
199
201
tags : Optional [Dict [str , str ]] = None ,
200
- ) -> IndexModel :
202
+ ) -> " IndexModel" :
201
203
"""Creates a Pinecone index.
202
204
203
205
:param name: The name of the index to create. Must be unique within your project and
@@ -299,13 +301,15 @@ def create_index(
299
301
def create_index_for_model (
300
302
self ,
301
303
name : str ,
302
- cloud : Union [CloudProvider , str ],
303
- region : Union [AwsRegion , GcpRegion , AzureRegion , str ],
304
- embed : Union [IndexEmbed , CreateIndexForModelEmbedTypedDict ],
304
+ cloud : Union [" CloudProvider" , str ],
305
+ region : Union [" AwsRegion" , " GcpRegion" , " AzureRegion" , str ],
306
+ embed : Union [" IndexEmbed" , " CreateIndexForModelEmbedTypedDict" ],
305
307
tags : Optional [Dict [str , str ]] = None ,
306
- deletion_protection : Optional [Union [DeletionProtection , str ]] = DeletionProtection .DISABLED ,
308
+ deletion_protection : Optional [
309
+ Union ["DeletionProtection" , str ]
310
+ ] = "DeletionProtection.DISABLED" ,
307
311
timeout : Optional [int ] = None ,
308
- ) -> IndexModel :
312
+ ) -> " IndexModel" :
309
313
"""
310
314
:param name: The name of the index to create. Must be unique within your project and
311
315
cannot be changed once created. Allowed characters are lowercase letters, numbers,
@@ -414,7 +418,7 @@ def delete_index(self, name: str, timeout: Optional[int] = None):
414
418
pass
415
419
416
420
@abstractmethod
417
- def list_indexes (self ) -> IndexList :
421
+ def list_indexes (self ) -> " IndexList" :
418
422
"""
419
423
:return: Returns an `IndexList` object, which is iterable and contains a
420
424
list of `IndexModel` objects. The `IndexList` also has a convenience method `names()`
@@ -447,7 +451,7 @@ def list_indexes(self) -> IndexList:
447
451
pass
448
452
449
453
@abstractmethod
450
- def describe_index (self , name : str ) -> IndexModel :
454
+ def describe_index (self , name : str ) -> " IndexModel" :
451
455
"""
452
456
:param name: the name of the index to describe.
453
457
:return: Returns an `IndexModel` object
@@ -534,8 +538,8 @@ def configure_index(
534
538
self ,
535
539
name : str ,
536
540
replicas : Optional [int ] = None ,
537
- pod_type : Optional [Union [PodType , str ]] = None ,
538
- deletion_protection : Optional [Union [DeletionProtection , str ]] = None ,
541
+ pod_type : Optional [Union [" PodType" , str ]] = None ,
542
+ deletion_protection : Optional [Union [" DeletionProtection" , str ]] = None ,
539
543
tags : Optional [Dict [str , str ]] = None ,
540
544
):
541
545
"""
@@ -622,7 +626,7 @@ def configure_index(
622
626
pass
623
627
624
628
@abstractmethod
625
- def create_collection (self , name : str , source : str ):
629
+ def create_collection (self , name : str , source : str ) -> None :
626
630
"""Create a collection from a pod-based index
627
631
628
632
:param name: Name of the collection
@@ -631,7 +635,7 @@ def create_collection(self, name: str, source: str):
631
635
pass
632
636
633
637
@abstractmethod
634
- def list_collections (self ) -> CollectionList :
638
+ def list_collections (self ) -> " CollectionList" :
635
639
"""List all collections
636
640
637
641
```python
0 commit comments