Learn R Programming

⚠️There's a newer version (0.2.0) of this package.Take me there.

rchroma

rchroma provides a clean interface to ChromaDB, a modern vector database for storing and querying embeddings.

Installation

You can install rchroma from GitHub:

# install.packages("remotes")
remotes::install_github("cynkra/rchroma")

You also need a running ChromaDB instance. The easiest way to get started is using Docker:

docker pull chromadb/chroma
docker run -p 8000:8000 chromadb/chroma

See the ChromaDB documentation for other installation methods.

Usage

library(rchroma)

# Connect to ChromaDB
client <- chroma_connect()

# Create a collection and add documents with embeddings
create_collection(client, "my_collection")
add_documents(
  client,
  "my_collection",
  documents = c("apple", "banana"),
  ids = c("doc1", "doc2"),
  embeddings = list(
    c(1.0, 0.0),  # apple
    c(0.8, 0.2)   # banana (similar to apple)
  )
)

# Query similar documents using embeddings
query(
  client,
  "my_collection",
  query_embeddings = list(c(1.0, 0.0)),  # should match apple best
  n_results = 2
)

Copy Link

Version

Install

install.packages('rchroma')

Monthly Downloads

154

Version

0.1.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

David Schoch

Last Published

February 13th, 2025

Functions in rchroma (0.1.0)

version

Get ChromaDB Server Version
pre_flight_checks

Get ChromaDB Server Information
query

Query Documents in a Collection
add_documents

Add Documents to a Collection
get_auth_identity

Get Authentication Identity
create_database

Create a Database
chroma_connect

ChromaDB Client
get_collection

Get a Collection
delete_collection

Delete a Collection
create_tenant

Create a Tenant
create_collection

Create a Collection in ChromaDB
delete_documents

Delete Documents from a Collection
count_collections

Count Collections in a Database
update_documents

Update Documents in a Collection
reset

Reset ChromaDB
heartbeat

Check ChromaDB Server Heartbeat
get_database

Get a Database
get_tenant

Get a Tenant
upsert_documents

Upsert Documents to a Collection
update_collection

Update a Collection
list_collections

List Collections in a Database