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
 8from .index_embed import IndexEmbed
 9
10__all__ = [
11    "CollectionDescription",
12    "PodSpec",
13    "PodSpecDefinition",
14    "ServerlessSpec",
15    "ServerlessSpecDefinition",
16    "IndexList",
17    "CollectionList",
18    "IndexModel",
19    "IndexEmbed",
20]
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
@dataclass(frozen=True)
class PodSpec:
 8@dataclass(frozen=True)
 9class PodSpec:
10    """
11    PodSpec represents the configuration used to deploy a pod-based index.
12
13    To learn more about the options for each configuration, please see [Understanding Indexes](https://docs.pinecone.io/docs/indexes)
14    """
15
16    environment: str
17    """
18    The environment where the pod index will be deployed. Example: 'us-east1-gcp'
19    """
20
21    replicas: Optional[int] = None
22    """
23    The number of replicas to deploy for the pod index. Default: 1
24    """
25
26    shards: Optional[int] = None
27    """
28    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
29    """
30
31    pods: Optional[int] = None
32    """
33    Number of pods to deploy. Default: 1
34    """
35
36    pod_type: Optional[str] = "p1.x1"
37    """
38    This value combines pod type and pod size into a single string. This configuration is your main lever for vertical scaling.
39    """
40
41    metadata_config: Optional[Dict] = field(default_factory=dict)
42    """
43    If you are storing a lot of metadata, you can use this configuration to limit the fields which are indexed for search.
44
45    This configuration should be a dictionary with the key 'indexed' and the value as a list of fields to index.
46
47    Example:
48    ```
49    {'indexed': ['field1', 'field2']}
50    ```
51    """
52
53    source_collection: Optional[str] = None
54    """
55    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.
56    """
57
58    def __init__(
59        self,
60        environment: Union[PodIndexEnvironment, str],
61        pod_type: Union[PodType, str] = "p1.x1",
62        replicas: Optional[int] = None,
63        shards: Optional[int] = None,
64        pods: Optional[int] = None,
65        metadata_config: Optional[Dict] = None,
66        source_collection: Optional[str] = None,
67    ):
68        object.__setattr__(
69            self,
70            "environment",
71            environment.value if isinstance(environment, PodIndexEnvironment) else str(environment),
72        )
73        object.__setattr__(
74            self, "pod_type", pod_type.value if isinstance(pod_type, PodType) else str(pod_type)
75        )
76        object.__setattr__(self, "replicas", replicas)
77        object.__setattr__(self, "shards", shards)
78        object.__setattr__(self, "pods", pods)
79        object.__setattr__(
80            self, "metadata_config", metadata_config if metadata_config is not None else {}
81        )
82        object.__setattr__(self, "source_collection", source_collection)
83
84    def asdict(self) -> Dict:
85        """
86        Returns the PodSpec as a dictionary.
87        """
88        return {"pod": self.__dict__}

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: Union[pinecone.enums.pod_index_environment.PodIndexEnvironment, str], pod_type: Union[pinecone.enums.pod_type.PodType, str] = 'p1.x1', replicas: Optional[int] = None, shards: Optional[int] = None, pods: Optional[int] = None, metadata_config: Optional[Dict] = None, source_collection: Optional[str] = None)
58    def __init__(
59        self,
60        environment: Union[PodIndexEnvironment, str],
61        pod_type: Union[PodType, str] = "p1.x1",
62        replicas: Optional[int] = None,
63        shards: Optional[int] = None,
64        pods: Optional[int] = None,
65        metadata_config: Optional[Dict] = None,
66        source_collection: Optional[str] = None,
67    ):
68        object.__setattr__(
69            self,
70            "environment",
71            environment.value if isinstance(environment, PodIndexEnvironment) else str(environment),
72        )
73        object.__setattr__(
74            self, "pod_type", pod_type.value if isinstance(pod_type, PodType) else str(pod_type)
75        )
76        object.__setattr__(self, "replicas", replicas)
77        object.__setattr__(self, "shards", shards)
78        object.__setattr__(self, "pods", pods)
79        object.__setattr__(
80            self, "metadata_config", metadata_config if metadata_config is not None else {}
81        )
82        object.__setattr__(self, "source_collection", source_collection)
environment: str

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

replicas: Optional[int] = None

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

shards: Optional[int] = None

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] = None

Number of pods to deploy. Default: 1

pod_type: Optional[str] = 'p1.x1'

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.

Example:

{'indexed': ['field1', 'field2']}
source_collection: Optional[str] = None

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) -> Dict:
84    def asdict(self) -> Dict:
85        """
86        Returns the PodSpec as a dictionary.
87        """
88        return {"pod": self.__dict__}

Returns the PodSpec as a dictionary.

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
@dataclass(frozen=True)
class ServerlessSpec:
 9@dataclass(frozen=True)
10class ServerlessSpec:
11    cloud: str
12    region: str
13
14    def __init__(
15        self,
16        cloud: Union[CloudProvider, str],
17        region: Union[AwsRegion, GcpRegion, AzureRegion, str],
18    ):
19        # Convert Enums to their string values if necessary
20        object.__setattr__(self, "cloud", cloud.value if isinstance(cloud, Enum) else str(cloud))
21        object.__setattr__(
22            self, "region", region.value if isinstance(region, Enum) else str(region)
23        )
24
25    def asdict(self):
26        return {"serverless": {"cloud": self.cloud, "region": self.region}}
ServerlessSpec( cloud: Union[pinecone.enums.clouds.CloudProvider, str], region: Union[pinecone.enums.clouds.AwsRegion, pinecone.enums.clouds.GcpRegion, pinecone.enums.clouds.AzureRegion, str])
14    def __init__(
15        self,
16        cloud: Union[CloudProvider, str],
17        region: Union[AwsRegion, GcpRegion, AzureRegion, str],
18    ):
19        # Convert Enums to their string values if necessary
20        object.__setattr__(self, "cloud", cloud.value if isinstance(cloud, Enum) else str(cloud))
21        object.__setattr__(
22            self, "region", region.value if isinstance(region, Enum) else str(region)
23        )
cloud: str
region: str
def asdict(self):
25    def asdict(self):
26        return {"serverless": {"cloud": self.cloud, "region": self.region}}
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:
 8class IndexList:
 9    def __init__(self, index_list: OpenAPIIndexList):
10        self.index_list = index_list
11        self.indexes = [IndexModel(i) for i in self.index_list.indexes]
12        self.current = 0
13
14    def names(self) -> List[str]:
15        return [i.name for i in self.indexes]
16
17    def __getitem__(self, key):
18        return self.indexes[key]
19
20    def __len__(self):
21        return len(self.indexes)
22
23    def __iter__(self):
24        return iter(self.indexes)
25
26    def __str__(self):
27        return str(self.indexes)
28
29    def __repr__(self):
30        return json.dumps([i.to_dict() for i in self.indexes], indent=4)
31
32    def __getattr__(self, attr):
33        return getattr(self.index_list, attr)
IndexList( index_list: pinecone.core.openapi.db_control.model.index_list.IndexList)
 9    def __init__(self, index_list: OpenAPIIndexList):
10        self.index_list = index_list
11        self.indexes = [IndexModel(i) for i in self.index_list.indexes]
12        self.current = 0
index_list
indexes
current
def names(self) -> List[str]:
14    def names(self) -> List[str]:
15        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.db_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.db_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()
@dataclass(frozen=True)
class IndexEmbed:
 9@dataclass(frozen=True)
10class IndexEmbed:
11    """
12    IndexEmbed represents the index embedding configuration when creating an index from a model.
13    """
14
15    model: str
16    """
17    The name of the embedding model to use for the index.
18    Required.
19    """
20
21    field_map: Dict[str, Any]
22    """
23    A mapping of field names to their types.
24    Required.
25    """
26
27    metric: Optional[str] = None
28    """
29    The metric to use for the index. If not provided, the default metric for the model is used.
30    Optional.
31    """
32
33    read_parameters: Optional[Dict[str, Any]] = None
34    """
35    The parameters to use when reading from the index.
36    Optional.
37    """
38
39    write_parameters: Optional[Dict[str, Any]] = None
40    """
41    The parameters to use when writing to the index.
42    Optional.
43    """
44
45    def as_dict(self) -> Dict[str, Any]:
46        """
47        Returns the IndexEmbed as a dictionary.
48        """
49        return self.__dict__
50
51    def __init__(
52        self,
53        model: Union[EmbedModel, str],
54        field_map: Dict[str, Any],
55        metric: Optional[Union[Metric, str]] = None,
56        read_parameters: Optional[Dict[str, Any]] = None,
57        write_parameters: Optional[Dict[str, Any]] = None,
58    ):
59        object.__setattr__(
60            self, "model", model.value if isinstance(model, EmbedModel) else str(model)
61        )
62        object.__setattr__(self, "field_map", field_map)
63        object.__setattr__(self, "metric", metric.value if isinstance(metric, Metric) else metric)
64        object.__setattr__(
65            self, "read_parameters", read_parameters if read_parameters is not None else {}
66        )
67        object.__setattr__(
68            self, "write_parameters", write_parameters if write_parameters is not None else {}
69        )

IndexEmbed represents the index embedding configuration when creating an index from a model.

IndexEmbed( model: Union[pinecone.data.features.inference.inference_request_builder.EmbedModel, str], field_map: Dict[str, Any], metric: Union[pinecone.enums.metric.Metric, str, NoneType] = None, read_parameters: Optional[Dict[str, Any]] = None, write_parameters: Optional[Dict[str, Any]] = None)
51    def __init__(
52        self,
53        model: Union[EmbedModel, str],
54        field_map: Dict[str, Any],
55        metric: Optional[Union[Metric, str]] = None,
56        read_parameters: Optional[Dict[str, Any]] = None,
57        write_parameters: Optional[Dict[str, Any]] = None,
58    ):
59        object.__setattr__(
60            self, "model", model.value if isinstance(model, EmbedModel) else str(model)
61        )
62        object.__setattr__(self, "field_map", field_map)
63        object.__setattr__(self, "metric", metric.value if isinstance(metric, Metric) else metric)
64        object.__setattr__(
65            self, "read_parameters", read_parameters if read_parameters is not None else {}
66        )
67        object.__setattr__(
68            self, "write_parameters", write_parameters if write_parameters is not None else {}
69        )
model: str

The name of the embedding model to use for the index. Required.

field_map: Dict[str, Any]

A mapping of field names to their types. Required.

metric: Optional[str] = None

The metric to use for the index. If not provided, the default metric for the model is used. Optional.

read_parameters: Optional[Dict[str, Any]] = None

The parameters to use when reading from the index. Optional.

write_parameters: Optional[Dict[str, Any]] = None

The parameters to use when writing to the index. Optional.

def as_dict(self) -> Dict[str, Any]:
45    def as_dict(self) -> Dict[str, Any]:
46        """
47        Returns the IndexEmbed as a dictionary.
48        """
49        return self.__dict__

Returns the IndexEmbed as a dictionary.