4 个版本
0.1.3 | 2023 年 8 月 15 日 |
---|---|
0.1.2 | 2023 年 6 月 24 日 |
0.1.1 | 2023 年 6 月 18 日 |
0.1.0 | 2023 年 6 月 18 日 |
#698 在 身份验证 中
每月 41 次下载
49KB
782 行
此 crate 允许您连接并与向量数据库 Pinecone 交互。在验证您的 API 密钥和您的环境密钥后,此 crate 促进了与 pinecone 索引的连接。一旦连接得到验证,此 API 允许您在 Pinecone 中进行 upsert、查询和更新数据,以及更多未提及的命令。有关不同 API 方法的更多详细信息,请参阅 此处
此 crate 目前仅支持 http / rest Pinecone API,不支持 GRPC。GRPC 将在未来作为可选功能实现。Http 目前是默认设置
要连接,请使用 Client
的 Client::new
方法初始化。这是一个异步操作,它还将验证您的凭据,如果提供无效凭据,则会出错。然后您可以使用 Client
上的方法在您的客户端 / 账户上运行操作,或通过 Client::index
方法创建一个新的 Index
。此索引最初不会进行验证,可以通过调用 Index::describe
方法进行验证,该方法将尝试获取有关索引的信息,并随后如果成功通过则验证凭据。
以下是一个基本客户端和索引示例。
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)
}
}
依赖项
~4–19MB
~255K SLoC