Crates.io | chromadb-rs |
lib.rs | chromadb-rs |
version | 0.1.8 |
source | src |
created_at | 2024-03-27 20:07:20.990531 |
updated_at | 2024-03-28 20:31:52.514608 |
description | The unofficial lib for Chroma vector database in rust |
homepage | https://github.com/PierreLouisLetoquart/chroma-rs.git |
repository | https://github.com/PierreLouisLetoquart/chroma-rs.git |
max_upload_size | |
id | 1188377 |
size | 25,520 |
This is a Rust library for interacting with the ChromaDB vector database. It's intended for learning and educational purposes. For a more advanced library, please check out chromadb.
The asynchronous example uses Tokio crate.
Here's how to run the ChromaDB backend using Docker:
default configuration:
docker pull chromadb/chroma
docker run -p 8000:8000 chromadb/chroma
with auth using token & persistant storage:
docker pull chromadb/chroma
docker run \
-p 8000:8000 \
-e chroma_server_auth_credentials_provider="chromadb.auth.token.tokenconfigserverauthcredentialsprovider" \
-e chroma_server_auth_provider="chromadb.auth.token.tokenauthserverprovider" \
-e chroma_server_auth_token_transport_header="x_chroma_token" \
-e chroma_server_auth_credentials="pilou2024" \
-v /path/to/persistent/storage/:/chroma/chroma \
chromadb/chroma
Here's a basic example of how to create a default client:
use chromadb_rs::client::{ChromaClient, ChromaClientParams};
let client = ChromaClient::new(ChromaClientParams::default());
For more advanced usage, you can create a client with custom parameters:
let mut hmap = HeaderMap::new();
hmap.insert("X-Chroma-Token", "test-token".parse().unwrap());
let settings = Settings {
tenant: "my-tenant".to_string(),
database: "my-database".to_string(),
}
let client = ChromaClient::new(ChromaClientParams {
host: "localhost".to_string(),
port: "8000".to_string(),
ssl: false,
headers: Some(hmap),
settings: Some(settings), // Some(Settings::default()) for default settings
});
let hb = client.heartbeat().await?;
let collections = client.list_collections().await?;
let new_collection = client.create_collection("test-name", None).await?;
let mut metadata = HashMap::new();
metadata.insert("key1", "value1");
metadata.insert("key2", "value2");
let new_collection = client
.create_collection("test-name", Some(metadata)).await?;
let new_collection = client.get_or_create_collection("test-name", None).await?;
let collection = client.get_collection("test-name").await?;
let deleted_collection = client.delete_collection("test-name").await?;
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.