pub struct PineconeClient { /* private fields */ }
Expand description
The PineconeClient
struct is the main entry point for interacting with Pinecone via this Rust SDK.
Implementations§
Source§impl PineconeClient
impl PineconeClient
Sourcepub async fn create_serverless_index(
&self,
name: &str,
dimension: i32,
metric: Metric,
cloud: Cloud,
region: &str,
deletion_protection: DeletionProtection,
timeout: WaitPolicy,
) -> Result<IndexModel, PineconeError>
pub async fn create_serverless_index( &self, name: &str, dimension: i32, metric: Metric, cloud: Cloud, region: &str, deletion_protection: DeletionProtection, timeout: WaitPolicy, ) -> Result<IndexModel, PineconeError>
Creates a serverless index.
§Arguments
name: &str
- Name of the index to create.dimension: i32
- Dimension of the vectors to be inserted in the index.metric: Metric
- The distance metric to be used for similarity search.cloud: Cloud
- The public cloud where you would like your index hosted.region: &str
- The region where you would like your index to be created.deletion_protection: DeletionProtection
- Deletion protection for the index.timeout: WaitPolicy
- The wait policy for index creation. If the index becomes ready before the specified duration, the function will return early. If the index is not ready after the specified duration, the function will return an error.
§Return
Result<IndexModel, PineconeError>
§Example
use pinecone_sdk::models::{IndexModel, Metric, Cloud, WaitPolicy, DeletionProtection};
use pinecone_sdk::utils::errors::PineconeError;
let pinecone = pinecone_sdk::pinecone::default_client()?;
// Create an index.
let response: Result<IndexModel, PineconeError> = pinecone.create_serverless_index(
"index-name", // Name of the index
10, // Dimension of the vectors
Metric::Cosine, // Distance metric
Cloud::Aws, // Cloud provider
"us-east-1", // Region
DeletionProtection::Enabled, // Deletion protection
WaitPolicy::NoWait // Timeout
).await;
Sourcepub async fn create_pod_index(
&self,
name: &str,
dimension: i32,
metric: Metric,
environment: &str,
pod_type: &str,
pods: i32,
replicas: i32,
shards: i32,
deletion_protection: DeletionProtection,
metadata_indexed: Option<&[&str]>,
source_collection: Option<&str>,
timeout: WaitPolicy,
) -> Result<IndexModel, PineconeError>
pub async fn create_pod_index( &self, name: &str, dimension: i32, metric: Metric, environment: &str, pod_type: &str, pods: i32, replicas: i32, shards: i32, deletion_protection: DeletionProtection, metadata_indexed: Option<&[&str]>, source_collection: Option<&str>, timeout: WaitPolicy, ) -> Result<IndexModel, PineconeError>
Creates a pod index.
§Arguments
name: &str
- The name of the indexdimension: i32
- The dimension of the indexmetric: Metric
- The metric to use for the indexenvironment: &str
- The environment where the pod index will be deployed. Example: ‘us-east1-gcp’pod_type: &str
- This value combines pod type and pod size into a single string. This configuration is your main lever for vertical scaling.pods: i32
- The number of pods to deploy.replicas: i32
- The number of replicas to deploy for the pod index.shards: i32
- 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.deletion_protection: DeletionProtection
- Deletion protection for the index.metadata_indexed: Option<&[&str]>
- The metadata fields to index.source_collection: Option<&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.timeout: WaitPolicy
- The wait policy for index creation. If the index becomes ready before the specified duration, the function will return early. If the index is not ready after the specified duration, the function will return an error.
§Return
- Result<IndexModel, PineconeError>`
§Example
use pinecone_sdk::models::{IndexModel, Metric, Cloud, WaitPolicy, DeletionProtection};
use pinecone_sdk::utils::errors::PineconeError;
use std::time::Duration;
let pinecone = pinecone_sdk::pinecone::default_client()?;
// Create a pod index.
let response: Result<IndexModel, PineconeError> = pinecone.create_pod_index(
"index_name", // Name of the index
10, // Dimension of the index
Metric::Cosine, // Distance metric
"us-east-1", // Environment
"p1.x1", // Pod type
1, // Number of pods
1, // Number of replicas
1, // Number of shards
DeletionProtection::Enabled, // Deletion protection
Some( // Metadata fields to index
&vec!["genre",
"title",
"imdb_rating"]),
Some("example-collection"), // Source collection
WaitPolicy::WaitFor(Duration::from_secs(10)), // Timeout
)
.await;
Sourcepub async fn describe_index(
&self,
name: &str,
) -> Result<IndexModel, PineconeError>
pub async fn describe_index( &self, name: &str, ) -> Result<IndexModel, PineconeError>
Describes an index.
§Arguments
name: &str
- Name of the index to describe.
§Return
Result<IndexModel, PineconeError>
§Example
use pinecone_sdk::models::IndexModel;
use pinecone_sdk::utils::errors::PineconeError;
let pinecone = pinecone_sdk::pinecone::default_client()?;
// Describe an index in the project.
let response: Result<IndexModel, PineconeError> = pinecone.describe_index("index-name").await;
Sourcepub async fn list_indexes(&self) -> Result<IndexList, PineconeError>
pub async fn list_indexes(&self) -> Result<IndexList, PineconeError>
Lists all indexes.
The results include a description of all indexes in your project, including the index name, dimension, metric, status, and spec.
§Return
Result<IndexList, PineconeError>
§Example
use pinecone_sdk::models::IndexList;
use pinecone_sdk::utils::errors::PineconeError;
let pinecone = pinecone_sdk::pinecone::default_client()?;
// List all indexes in the project.
let response: Result<IndexList, PineconeError> = pinecone.list_indexes().await;
Sourcepub async fn configure_index(
&self,
name: &str,
deletion_protection: Option<DeletionProtection>,
replicas: Option<i32>,
pod_type: Option<&str>,
) -> Result<IndexModel, PineconeError>
pub async fn configure_index( &self, name: &str, deletion_protection: Option<DeletionProtection>, replicas: Option<i32>, pod_type: Option<&str>, ) -> Result<IndexModel, PineconeError>
Configures an index.
This operation changes the deletion protection specification, the pod type, and the number of replicas for an index. Deletion protection can be changed for both pod and serverless indexes, while pod types and number of replicas can only be changed for pod indexes.
§Arguments
- name: &str - The name of the index to be configured.
- deletion_protection: Option
- Deletion protection for the index. - replicas: Option
- The desired number of replicas, lowest value is 0. This parameter should be None
if the index is serverless. - pod_type: Option<&str> - The new pod_type for the index. This parameter should be
None
if the index is serverless.
§Return
Result<IndexModel, PineconeError>
§Example
use pinecone_sdk::models::{DeletionProtection, IndexModel};
use pinecone_sdk::utils::errors::PineconeError;
let pinecone = pinecone_sdk::pinecone::default_client()?;
// Configure an index in the project.
let response: Result<IndexModel, PineconeError> = pinecone.configure_index(
"index-name",
Some(DeletionProtection::Enabled),
Some(6),
Some("s1.x1")
).await;
Sourcepub async fn delete_index(&self, name: &str) -> Result<(), PineconeError>
pub async fn delete_index(&self, name: &str) -> Result<(), PineconeError>
Deletes an index.
§Arguments
- name: &str - The name of the index to be deleted.
§Return
Result<(), PineconeError>
§Example
use pinecone_sdk::utils::errors::PineconeError;
let pinecone = pinecone_sdk::pinecone::default_client()?;
// Delete an index in the project.
let response: Result<(), PineconeError> = pinecone.delete_index("index-name").await;
Sourcepub async fn create_collection(
&self,
name: &str,
source: &str,
) -> Result<CollectionModel, PineconeError>
pub async fn create_collection( &self, name: &str, source: &str, ) -> Result<CollectionModel, PineconeError>
Creates a collection from an index.
§Arguments
name: &str
- Name of the collection to create.source: &str
- Name of the index to be used as the source for the collection.
§Return
Result<CollectionModel, PineconeError>
§Example
use pinecone_sdk::models::CollectionModel;
use pinecone_sdk::utils::errors::PineconeError;
let pinecone = pinecone_sdk::pinecone::default_client()?;
// Describe an index in the project.
let response: Result<CollectionModel, PineconeError> = pinecone.create_collection("collection-name", "index-name").await;
Sourcepub async fn describe_collection(
&self,
name: &str,
) -> Result<CollectionModel, PineconeError>
pub async fn describe_collection( &self, name: &str, ) -> Result<CollectionModel, PineconeError>
Describe a collection.
§Arguments
- name: &str - The name of the collection to describe.
§Return
Result<(), PineconeError>
§Example
use pinecone_sdk::models::CollectionModel;
use pinecone_sdk::utils::errors::PineconeError;
let pinecone = pinecone_sdk::pinecone::default_client()?;
// Describe a collection in the project.
let collection: CollectionModel = pinecone.describe_collection("collection-name").await?;
Sourcepub async fn list_collections(&self) -> Result<CollectionList, PineconeError>
pub async fn list_collections(&self) -> Result<CollectionList, PineconeError>
Lists all collections.
This operation returns a list of all collections in a project.
§Return
Result<CollectionList, PineconeError>
§Example
use pinecone_sdk::models::CollectionList;
use pinecone_sdk::utils::errors::PineconeError;
let pinecone = pinecone_sdk::pinecone::default_client()?;
// List all collections in the project.
let response: Result<CollectionList, PineconeError> = pinecone.list_collections().await;
Sourcepub async fn delete_collection(&self, name: &str) -> Result<(), PineconeError>
pub async fn delete_collection(&self, name: &str) -> Result<(), PineconeError>
Deletes a collection.
§Arguments
- name: &str - The name of the collection to be deleted.
§Return
Result<(), PineconeError>
§Example
use pinecone_sdk::utils::errors::PineconeError;
let pinecone = pinecone_sdk::pinecone::default_client()?;
// Delete a collection in the project.
let response: Result<(), PineconeError> = pinecone.delete_collection("collection-name").await;
Source§impl PineconeClient
impl PineconeClient
Sourcepub async fn index(&self, host: &str) -> Result<Index, PineconeError>
pub async fn index(&self, host: &str) -> Result<Index, PineconeError>
Target an index for data operations.
§Arguments
host: &str
- The host of the index to target. If the host does not contain a scheme, it will default tohttps://
. If the host does not contain a port, it will default to443
.
§Return
Result<Index, PineconeError>
§Example
let pinecone = pinecone_sdk::pinecone::default_client()?;
let index = pinecone.index("index-host").await?;
Source§impl PineconeClient
impl PineconeClient
Sourcepub async fn embed(
&self,
model: &str,
parameters: Option<EmbedRequestParameters>,
inputs: &Vec<&str>,
) -> Result<EmbeddingsList, PineconeError>
pub async fn embed( &self, model: &str, parameters: Option<EmbedRequestParameters>, inputs: &Vec<&str>, ) -> Result<EmbeddingsList, PineconeError>
Generate embeddings for input data.
§Arguments
model: &str
- The model to use for embedding.parameters: Option<EmbedRequestParameters>
- Model-specific parameters.inputs: &Vec<&str>
- The input data to embed.
§Return
Result<EmbeddingsList, PineconeError>
§Example
let pinecone = pinecone_sdk::pinecone::default_client()?;
let response = pinecone.embed("multilingual-e5-large", None, &vec!["Hello, world!"]).await.expect("Failed to embed");
Trait Implementations§
Source§impl Clone for PineconeClient
impl Clone for PineconeClient
Source§fn clone(&self) -> PineconeClient
fn clone(&self) -> PineconeClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PineconeClient
impl Debug for PineconeClient
Source§impl TryFrom<PineconeClientConfig> for PineconeClient
impl TryFrom<PineconeClientConfig> for PineconeClient
Source§type Error = PineconeError
type Error = PineconeError
Auto Trait Implementations§
impl Freeze for PineconeClient
impl !RefUnwindSafe for PineconeClient
impl Send for PineconeClient
impl Sync for PineconeClient
impl Unpin for PineconeClient
impl !UnwindSafe for PineconeClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request