Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/openapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ All URIs are relative to *https://api.pinecone.io*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*InferenceApi* | [**embed**](docs/InferenceApi.md#embed) | **POST** /embed | Embed data
*InferenceApi* | [**embed**](docs/InferenceApi.md#embed) | **POST** /embed | Generate vectors
*ManageIndexesApi* | [**configure_index**](docs/ManageIndexesApi.md#configure_index) | **PATCH** /indexes/{index_name} | Configure an index
*ManageIndexesApi* | [**create_collection**](docs/ManageIndexesApi.md#create_collection) | **POST** /collections | Create a collection
*ManageIndexesApi* | [**create_index**](docs/ManageIndexesApi.md#create_index) | **POST** /indexes | Create an index
Expand Down
4 changes: 4 additions & 0 deletions src/openapi/apis/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* Generated by: https://openapi-generator.tech
*/



#[derive(Debug, Clone)]
pub struct Configuration {
pub base_path: String,
Expand All @@ -28,6 +30,7 @@ pub struct ApiKey {
pub key: String,
}


impl Configuration {
pub fn new() -> Configuration {
Configuration::default()
Expand All @@ -44,6 +47,7 @@ impl Default for Configuration {
oauth_access_token: None,
bearer_access_token: None,
api_key: None,

}
}
}
27 changes: 11 additions & 16 deletions src/openapi/apis/inference_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
* Generated by: https://openapi-generator.tech
*/

use super::{configuration, Error};
use crate::openapi::{apis::ResponseContent, models};

use reqwest;
use serde::{Deserialize, Serialize};
use crate::openapi::{apis::ResponseContent, models};
use super::{Error, configuration};


/// struct for typed errors of method [`embed`]
#[derive(Debug, Clone, Serialize, Deserialize)]
Expand All @@ -23,22 +25,18 @@ pub enum EmbedError {
UnknownValue(serde_json::Value),
}

/// Generate embeddings for input data
pub async fn embed(
configuration: &configuration::Configuration,
embed_request: Option<models::EmbedRequest>,
) -> Result<models::EmbeddingsList, Error<EmbedError>> {

/// Generate vector embeddings for input data. This endpoint uses Pinecone's [hosted embedding models](https://docs.pinecone.io/guides/index-data/create-an-index#embedding-models).
pub async fn embed(configuration: &configuration::Configuration, embed_request: Option<models::EmbedRequest>) -> Result<models::EmbeddingsList, Error<EmbedError>> {
let local_var_configuration = configuration;

let local_var_client = &local_var_configuration.client;

let local_var_uri_str = format!("{}/embed", local_var_configuration.base_path);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
Expand All @@ -60,11 +58,8 @@ pub async fn embed(
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<EmbedError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}

232 changes: 64 additions & 168 deletions src/openapi/apis/manage_indexes_api.rs

Large diffs are not rendered by default.

16 changes: 7 additions & 9 deletions src/openapi/apis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub enum Error<T> {
ResponseError(ResponseContent<T>),
}

impl<T> fmt::Display for Error<T> {
impl <T> fmt::Display for Error<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let (module, e) = match self {
Error::Reqwest(e) => ("reqwest", e.to_string()),
Expand All @@ -28,7 +28,7 @@ impl<T> fmt::Display for Error<T> {
}
}

impl<T: fmt::Debug> error::Error for Error<T> {
impl <T: fmt::Debug> error::Error for Error<T> {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
Some(match self {
Error::Reqwest(e) => e,
Expand All @@ -39,19 +39,19 @@ impl<T: fmt::Debug> error::Error for Error<T> {
}
}

impl<T> From<reqwest::Error> for Error<T> {
impl <T> From<reqwest::Error> for Error<T> {
fn from(e: reqwest::Error) -> Self {
Error::Reqwest(e)
}
}

impl<T> From<serde_json::Error> for Error<T> {
impl <T> From<serde_json::Error> for Error<T> {
fn from(e: serde_json::Error) -> Self {
Error::Serde(e)
}
}

impl<T> From<std::io::Error> for Error<T> {
impl <T> From<std::io::Error> for Error<T> {
fn from(e: std::io::Error) -> Self {
Error::Io(e)
}
Expand All @@ -78,10 +78,8 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String
value,
));
}
}
serde_json::Value::String(s) => {
params.push((format!("{}[{}]", prefix, key), s.clone()))
}
},
serde_json::Value::String(s) => params.push((format!("{}[{}]", prefix, key), s.clone())),
_ => params.push((format!("{}[{}]", prefix, key), value.to_string())),
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/openapi/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::enum_variant_names)]
#![allow(clippy::empty_docs)]
extern crate reqwest;

extern crate serde;
extern crate serde_json;
extern crate url;
extern crate reqwest;

pub mod apis;
pub mod models;
5 changes: 4 additions & 1 deletion src/openapi/models/collection_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ pub struct CollectionList {
impl CollectionList {
/// The list of collections that exist in the project.
pub fn new() -> CollectionList {
CollectionList { collections: None }
CollectionList {
collections: None,
}
}
}

1 change: 1 addition & 0 deletions src/openapi/models/collection_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@ impl Default for Status {
Self::Initializing
}
}

6 changes: 2 additions & 4 deletions src/openapi/models/configure_index_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ use serde::{Deserialize, Serialize};
pub struct ConfigureIndexRequest {
#[serde(rename = "spec", skip_serializing_if = "Option::is_none")]
pub spec: Option<Box<models::ConfigureIndexRequestSpec>>,
#[serde(
rename = "deletion_protection",
skip_serializing_if = "Option::is_none"
)]
#[serde(rename = "deletion_protection", skip_serializing_if = "Option::is_none")]
pub deletion_protection: Option<models::DeletionProtection>,
}

Expand All @@ -32,3 +29,4 @@ impl ConfigureIndexRequest {
}
}
}

5 changes: 4 additions & 1 deletion src/openapi/models/configure_index_request_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ pub struct ConfigureIndexRequestSpec {

impl ConfigureIndexRequestSpec {
pub fn new(pod: models::ConfigureIndexRequestSpecPod) -> ConfigureIndexRequestSpec {
ConfigureIndexRequestSpec { pod: Box::new(pod) }
ConfigureIndexRequestSpec {
pod: Box::new(pod),
}
}
}

1 change: 1 addition & 0 deletions src/openapi/models/configure_index_request_spec_pod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ impl ConfigureIndexRequestSpecPod {
}
}
}

8 changes: 6 additions & 2 deletions src/openapi/models/create_collection_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use serde::{Deserialize, Serialize};
/// CreateCollectionRequest : The configuration needed to create a Pinecone collection.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct CreateCollectionRequest {
/// The name of the collection to be created. Resource name must be 1-45 characters long, start and end with an alphanumeric character, and consist only of lower case alphanumeric characters or '-'.
/// The name of the collection to be created. Resource name must be 1-45 characters long, start and end with an alphanumeric character, and consist only of lower case alphanumeric characters or '-'.
#[serde(rename = "name")]
pub name: String,
/// The name of the index to be used as the source for the collection.
Expand All @@ -25,6 +25,10 @@ pub struct CreateCollectionRequest {
impl CreateCollectionRequest {
/// The configuration needed to create a Pinecone collection.
pub fn new(name: String, source: String) -> CreateCollectionRequest {
CreateCollectionRequest { name, source }
CreateCollectionRequest {
name,
source,
}
}
}

61 changes: 61 additions & 0 deletions src/openapi/models/create_index_from_dataset_request.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Pinecone Control Plane API
*
* Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors.
*
* The version of the OpenAPI document: unstable
* Contact: [email protected]
* Generated by: https://openapi-generator.tech
*/

use crate::openapi::models;
use serde::{Deserialize, Serialize};

/// CreateIndexFromDatasetRequest : The configuration needed to create a Pinecone index from a dataset.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct CreateIndexFromDatasetRequest {
/// The name of the index. Resource name must be 1-45 characters long, start and end with an alphanumeric character, and consist only of lower case alphanumeric characters or '-'.
#[serde(rename = "name")]
pub name: String,
/// The dimensions of the vectors to be inserted in the index.
#[serde(rename = "dimension")]
pub dimension: i32,
/// The distance metric to be used for similarity search. You can use 'euclidean', 'cosine', or 'dotproduct'.
#[serde(rename = "metric", skip_serializing_if = "Option::is_none")]
pub metric: Option<Metric>,
/// The name of the dataset to create the index from. This must correlate to the collection name.
#[serde(rename = "dataset_name", skip_serializing_if = "Option::is_none")]
pub dataset_name: Option<String>,
#[serde(rename = "spec", deserialize_with = "Option::deserialize")]
pub spec: Option<Box<models::CreateIndexFromDatasetRequestSpec>>,
}

impl CreateIndexFromDatasetRequest {
/// The configuration needed to create a Pinecone index from a dataset.
pub fn new(name: String, dimension: i32, spec: Option<models::CreateIndexFromDatasetRequestSpec>) -> CreateIndexFromDatasetRequest {
CreateIndexFromDatasetRequest {
name,
dimension,
metric: None,
dataset_name: None,
spec: if let Some(x) = spec {Some(Box::new(x))} else {None},
}
}
}
/// The distance metric to be used for similarity search. You can use 'euclidean', 'cosine', or 'dotproduct'.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Metric {
#[serde(rename = "cosine")]
Cosine,
#[serde(rename = "euclidean")]
Euclidean,
#[serde(rename = "dotproduct")]
Dotproduct,
}

impl Default for Metric {
fn default() -> Metric {
Self::Cosine
}
}

32 changes: 32 additions & 0 deletions src/openapi/models/create_index_from_dataset_request_spec.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Pinecone Control Plane API
*
* Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors.
*
* The version of the OpenAPI document: unstable
* Contact: [email protected]
* Generated by: https://openapi-generator.tech
*/

use crate::openapi::models;
use serde::{Deserialize, Serialize};

/// CreateIndexFromDatasetRequestSpec : The spec object defines how the index should be deployed. For serverless indexes, you define only the cloud and region where the index should be hosted. For pod-based indexes, you define the environment where the index should be hosted, the pod type and size to use, and other index characteristics. Serverless indexes are in public preview and are available only on AWS in the us-west-2 and us-east-1 regions. Test thoroughly before using serverless indexes in production.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct CreateIndexFromDatasetRequestSpec {
#[serde(rename = "serverless", skip_serializing_if = "Option::is_none")]
pub serverless: Option<Box<models::ServerlessSpec>>,
#[serde(rename = "deletion_protection", skip_serializing_if = "Option::is_none")]
pub deletion_protection: Option<models::DeletionProtection>,
}

impl CreateIndexFromDatasetRequestSpec {
/// The spec object defines how the index should be deployed. For serverless indexes, you define only the cloud and region where the index should be hosted. For pod-based indexes, you define the environment where the index should be hosted, the pod type and size to use, and other index characteristics. Serverless indexes are in public preview and are available only on AWS in the us-west-2 and us-east-1 regions. Test thoroughly before using serverless indexes in production.
pub fn new() -> CreateIndexFromDatasetRequestSpec {
CreateIndexFromDatasetRequestSpec {
serverless: None,
deletion_protection: None,
}
}
}

16 changes: 5 additions & 11 deletions src/openapi/models/create_index_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use serde::{Deserialize, Serialize};
/// CreateIndexRequest : The configuration needed to create a Pinecone index.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct CreateIndexRequest {
/// The name of the index. Resource name must be 1-45 characters long, start and end with an alphanumeric character, and consist only of lower case alphanumeric characters or '-'.
/// The name of the index. Resource name must be 1-45 characters long, start and end with an alphanumeric character, and consist only of lower case alphanumeric characters or '-'.
#[serde(rename = "name")]
pub name: String,
/// The dimensions of the vectors to be inserted in the index.
Expand All @@ -23,28 +23,21 @@ pub struct CreateIndexRequest {
/// The distance metric to be used for similarity search. You can use 'euclidean', 'cosine', or 'dotproduct'.
#[serde(rename = "metric", skip_serializing_if = "Option::is_none")]
pub metric: Option<Metric>,
#[serde(
rename = "deletion_protection",
skip_serializing_if = "Option::is_none"
)]
#[serde(rename = "deletion_protection", skip_serializing_if = "Option::is_none")]
pub deletion_protection: Option<models::DeletionProtection>,
#[serde(rename = "spec", deserialize_with = "Option::deserialize")]
pub spec: Option<Box<models::IndexSpec>>,
}

impl CreateIndexRequest {
/// The configuration needed to create a Pinecone index.
pub fn new(
name: String,
dimension: i32,
spec: Option<models::IndexSpec>,
) -> CreateIndexRequest {
pub fn new(name: String, dimension: i32, spec: Option<models::IndexSpec>) -> CreateIndexRequest {
CreateIndexRequest {
name,
dimension,
metric: None,
deletion_protection: None,
spec: spec.map(Box::new),
spec: if let Some(x) = spec {Some(Box::new(x))} else {None},
}
}
}
Expand All @@ -64,3 +57,4 @@ impl Default for Metric {
Self::Cosine
}
}

Loading
Loading