pinecone.models

 1from .index_description import ServerlessSpecDefinition, PodSpecDefinition
 2from .collection_description import CollectionDescription
 3from .serverless_spec import ServerlessSpec
 4from .pod_spec import PodSpec
 5from .index_list import IndexList
 6from .collection_list import CollectionList
 7from .index_model import IndexModel
 8
 9__all__ = [
10    "CollectionDescription",
11    "PodSpec",
12    "PodSpecDefinition",
13    "ServerlessSpec",
14    "ServerlessSpecDefinition",
15    "IndexList",
16    "CollectionList",
17    "IndexModel",
18]
class CollectionDescription(typing.NamedTuple):
 5class CollectionDescription(NamedTuple):
 6    """
 7    The description of a collection.
 8    """
 9
10    name: str
11    """
12    The name of the collection.
13    """
14
15    source: str
16    """
17    The name of the index used to create the collection.
18    """

The description of a collection.

CollectionDescription(name: str, source: str)

Create new instance of CollectionDescription(name, source)

name: str

The name of the collection.

source: str

The name of the index used to create the collection.

Inherited Members
builtins.tuple
index
count
class PodSpec(typing.NamedTuple):
 5class PodSpec(NamedTuple):
 6    """
 7    PodSpec represents the configuration used to deploy a pod-based index.
 8
 9    To learn more about the options for each configuration, please see [Understanding Indexes](https://docs.pinecone.io/docs/indexes)
10    """
11
12    environment: str
13    """
14    The environment where the pod index will be deployed. Example: 'us-east1-gcp'
15    """
16
17    replicas: Optional[int] = None
18    """
19    The number of replicas to deploy for the pod index. Default: 1
20    """
21
22    shards: Optional[int] = None
23    """
24    The number of shards to use. Shards are used to expand the amount of vectors you can store beyond the capacity of a single pod. Default: 1
25    """
26
27    pods: Optional[int] = None
28    """
29    Number of pods to deploy. Default: 1
30    """
31
32    pod_type: Optional[str] = "p1.x1"
33    """
34    This value combines pod type and pod size into a single string. This configuration is your main lever for vertical scaling.
35    """
36
37    metadata_config: Optional[Dict] = {}
38    """
39    If you are storing a lot of metadata, you can use this configuration to limit the fields which are indexed for search. 
40
41    This configuration should be a dictionary with the key 'indexed' and the value as a list of fields to index.
42
43    For example, if your vectors have metadata along like this:
44    
45    ```python
46    from pinecone import Vector
47
48    vector = Vector(
49        id='237438191', 
50        values=[...], 
51        metadata={
52            'productId': '237438191',
53            'description': 'Stainless Steel Tumbler with Straw',
54            'category': 'kitchen',
55            'price': '19.99'
56        }
57    )
58    ```
59
60    You might want to limit which fields are indexed with metadata config such as this: 
61    ```
62    {'indexed': ['field1', 'field2']}
63    """
64
65    source_collection: Optional[str] = None
66    """
67    The name of the collection to use as the source for the pod index. This configuration is only used when creating a pod index from an existing collection.
68    """
69
70    def asdict(self):
71        """
72        Returns the PodSpec as a dictionary.
73        """
74        return {"pod": self._asdict()}

PodSpec represents the configuration used to deploy a pod-based index.

To learn more about the options for each configuration, please see Understanding Indexes

PodSpec( environment: str, replicas: Optional[int] = None, shards: Optional[int] = None, pods: Optional[int] = None, pod_type: Optional[str] = 'p1.x1', metadata_config: Optional[Dict] = {}, source_collection: Optional[str] = None)

Create new instance of PodSpec(environment, replicas, shards, pods, pod_type, metadata_config, source_collection)

environment: str

The environment where the pod index will be deployed. Example: 'us-east1-gcp'

replicas: Optional[int]

The number of replicas to deploy for the pod index. Default: 1

shards: Optional[int]

The number of shards to use. Shards are used to expand the amount of vectors you can store beyond the capacity of a single pod. Default: 1

pods: Optional[int]

Number of pods to deploy. Default: 1

pod_type: Optional[str]

This value combines pod type and pod size into a single string. This configuration is your main lever for vertical scaling.

metadata_config: Optional[Dict]

If you are storing a lot of metadata, you can use this configuration to limit the fields which are indexed for search.

This configuration should be a dictionary with the key 'indexed' and the value as a list of fields to index.

For example, if your vectors have metadata along like this:

from pinecone import Vector

vector = Vector(
    id='237438191', 
    values=[...], 
    metadata={
        'productId': '237438191',
        'description': 'Stainless Steel Tumbler with Straw',
        'category': 'kitchen',
        'price': '19.99'
    }
)

You might want to limit which fields are indexed with metadata config such as this: ``` {'indexed': ['field1', 'field2']}

source_collection: Optional[str]

The name of the collection to use as the source for the pod index. This configuration is only used when creating a pod index from an existing collection.

def asdict(self):
70    def asdict(self):
71        """
72        Returns the PodSpec as a dictionary.
73        """
74        return {"pod": self._asdict()}

Returns the PodSpec as a dictionary.

Inherited Members
builtins.tuple
index
count
class PodSpecDefinition(typing.NamedTuple):
 5class PodSpecDefinition(NamedTuple):
 6    replicas: int
 7    shards: int
 8    pods: int
 9    pod_type: str
10    environment: str
11    metadata_config: Optional[Dict]

PodSpecDefinition(replicas, shards, pods, pod_type, environment, metadata_config)

PodSpecDefinition( replicas: int, shards: int, pods: int, pod_type: str, environment: str, metadata_config: Optional[Dict])

Create new instance of PodSpecDefinition(replicas, shards, pods, pod_type, environment, metadata_config)

replicas: int

Alias for field number 0

shards: int

Alias for field number 1

pods: int

Alias for field number 2

pod_type: str

Alias for field number 3

environment: str

Alias for field number 4

metadata_config: Optional[Dict]

Alias for field number 5

Inherited Members
builtins.tuple
index
count
class ServerlessSpec(typing.NamedTuple):
 5class ServerlessSpec(NamedTuple):
 6    cloud: str
 7    region: str
 8
 9    def asdict(self):
10        return {"serverless": self._asdict()}

ServerlessSpec(cloud, region)

ServerlessSpec(cloud: str, region: str)

Create new instance of ServerlessSpec(cloud, region)

cloud: str

Alias for field number 0

region: str

Alias for field number 1

def asdict(self):
 9    def asdict(self):
10        return {"serverless": self._asdict()}
Inherited Members
builtins.tuple
index
count
class ServerlessSpecDefinition(typing.NamedTuple):
14class ServerlessSpecDefinition(NamedTuple):
15    cloud: str
16    region: str

ServerlessSpecDefinition(cloud, region)

ServerlessSpecDefinition(cloud: str, region: str)

Create new instance of ServerlessSpecDefinition(cloud, region)

cloud: str

Alias for field number 0

region: str

Alias for field number 1

Inherited Members
builtins.tuple
index
count
class IndexList:
 7class IndexList:
 8    def __init__(self, index_list: OpenAPIIndexList):
 9        self.index_list = index_list
10        self.indexes = [IndexModel(i) for i in self.index_list.indexes]
11        self.current = 0
12
13    def names(self):
14        return [i.name for i in self.indexes]
15
16    def __getitem__(self, key):
17        return self.indexes[key]
18
19    def __len__(self):
20        return len(self.indexes)
21
22    def __iter__(self):
23        return iter(self.indexes)
24
25    def __str__(self):
26        return str(self.indexes)
27
28    def __repr__(self):
29        return json.dumps([i.to_dict() for i in self.indexes], indent=4)
30
31    def __getattr__(self, attr):
32        return getattr(self.index_list, attr)
IndexList(index_list: pinecone.core.openapi.control.model.index_list.IndexList)
 8    def __init__(self, index_list: OpenAPIIndexList):
 9        self.index_list = index_list
10        self.indexes = [IndexModel(i) for i in self.index_list.indexes]
11        self.current = 0
index_list
indexes
current
def names(self):
13    def names(self):
14        return [i.name for i in self.indexes]
class CollectionList:
 6class CollectionList:
 7    """
 8    A list of collections.
 9    """
10
11    def __init__(self, collection_list: OpenAPICollectionList):
12        self.collection_list = collection_list
13        self.current = 0
14
15    def names(self):
16        return [i["name"] for i in self.collection_list.collections]
17
18    def __getitem__(self, key):
19        return self.collection_list.collections[key]
20
21    def __len__(self):
22        return len(self.collection_list.collections)
23
24    def __iter__(self):
25        return iter(self.collection_list.collections)
26
27    def __str__(self):
28        return str(self.collection_list)
29
30    def __repr__(self):
31        return json.dumps([c.to_dict() for c in self.collection_list.collections], indent=4)
32
33    def __getattr__(self, attr):
34        return getattr(self.collection_list, attr)

A list of collections.

CollectionList( collection_list: pinecone.core.openapi.control.model.collection_list.CollectionList)
11    def __init__(self, collection_list: OpenAPICollectionList):
12        self.collection_list = collection_list
13        self.current = 0
collection_list
current
def names(self):
15    def names(self):
16        return [i["name"] for i in self.collection_list.collections]
class IndexModel:
 5class IndexModel:
 6    def __init__(self, index: OpenAPIIndexModel):
 7        self.index = index
 8        self.deletion_protection = index.deletion_protection.value
 9
10    def __str__(self):
11        return str(self.index)
12
13    def __getattr__(self, attr):
14        return getattr(self.index, attr)
15
16    def __getitem__(self, key):
17        return self.__getattr__(key)
18
19    def to_dict(self):
20        return self.index.to_dict()
IndexModel(index: pinecone.core.openapi.control.model.index_model.IndexModel)
6    def __init__(self, index: OpenAPIIndexModel):
7        self.index = index
8        self.deletion_protection = index.deletion_protection.value
index
deletion_protection
def to_dict(self):
19    def to_dict(self):
20        return self.index.to_dict()