1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! This crate allows you to connect and interact with Pinecone, the vector database. After
//! authenticating you're api key and you're environment key, this crate facilitates the connection
//! to a pinecone index. Once a connection has been validated this API allows you to upsert,
//! query, and update data within Pinecone as well more unmentioned commands. More details about
//! the different api methods can be found [here](https://docs.pinecone.io/reference/describe_index_stats_post)
//!
//! This crate currently only supports the http / rest pinecone api and does not support GRCP. GRCP
//! will be implemented into the future as opt in. Http is currently the default
//!
//! To connect, initalize a [`Client`] using the [`Client::new`] method. This is an asynchronous
//! operation that will also validate you're credentials and will error if invalid credentials are
//! given. You can then run operations on you're client / account using the methods on [`Client`]
//! or create a new [`Index`] via the [`Client::index`] method. This index will not be validated
//! intially, it can be validated by calling the [`Index::describe`] method which will attempt to
//! get information about the index and subsequently validate the credentials if it goes through
//! successfully.
//!
//! Below is a basic client and index example.
//!```no_run
//!use pinenut::{Client, models::Vector};
//!
//!async fn index_upsert() {
//!
//! // We create an instance of client first and firstmost. Panics if it couldn't authenticate.
//! let client = Client::new(env!("PINECONE_API_KEY"), env!("PINECONE_ENV")).await.unwrap();
//! // creates an index, will not authenticate.
//! let mut index = client.index(env!("PINECONE_INDEX_NAME"));
//!
//! // We use describe as a form of authenticate, panicing if we couldn't authenticate.
//! let _ = index.describe().await.unwrap();
//! let vec = Vector{
//! id: "B".to_string(),
//! values: vec![0.5; 32],
//! sparse_values: None,
//! metadata: None
//! };
//!
//! match index.upsert(String::from("odle"), vec![vec]).await {
//! Ok(_) => assert!(true),
//! Err(err) => panic!("unable to upsert: {:?}", err)
//! }
//!}
//!```
//!
//!
//!
//TODO: create macro for GRCP when that becomes implemented
if_rest!
pub use crate;