Struct PineconeClient

Source
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

Source

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;
Source

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 index
  • dimension: i32 - The dimension of the index
  • metric: Metric - The metric to use for the index
  • environment: &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;
Source

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;
Source

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;
Source

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;
Source

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;
Source

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;
Source

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?;
Source

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;
Source

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

Source

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 to https://. If the host does not contain a port, it will default to 443.
§Return
  • Result<Index, PineconeError>
§Example

let pinecone = pinecone_sdk::pinecone::default_client()?;

let index = pinecone.index("index-host").await?;
Source§

impl PineconeClient

Source

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

Source§

fn clone(&self) -> PineconeClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PineconeClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl TryFrom<PineconeClientConfig> for PineconeClient

Source§

type Error = PineconeError

The type returned in the event of a conversion error.
Source§

fn try_from(config: PineconeClientConfig) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,