Chroma is the open-source embedding database. Chroma makes it easy to build LLM apps by making knowledge, facts, and skills pluggable for LLMs.
This Ruby gem is a client to connect to Chroma's database via its API.
Find more information about Chroma on how to install at their website. https://www.trychroma.com/
Chroma-rb is a Ruby client for Chroma Database. It works with version 0.3.22 or better (Please see requirements below).
A small example usage
require "logger"
# Requiere Chroma Ruby client.
require "chroma-db"
# Configure Chroma's host. Here you can specify your own host.
Chroma.connect_host = "http://localhost:8000"
Chroma.logger = Logger.new($stdout)
Chroma.log_level = Chroma::LEVEL_ERROR
# Check current Chrome server version
version = Chroma::Resources::Database.version
puts version
# Create a new collection
collection = Chroma::Resources::Collection.create(collection_name, {lang: "ruby", gem: "chroma-db"})
# Add embeddings
embeddings = [
Chroma::Resources::Embedding.new(id: "1", embedding: [1.3, 2.6, 3.1], metadata: {client: "chroma-rb"}, document: "ruby"),
Chroma::Resources::Embedding.new(id: "2", embedding: [3.7, 2.8, 0.9], metadata: {client: "chroma-rb"}, document: "rails")
]
collection.add(embeddings)
For a complete example, please refer to the Jupyter Noterbook Chroma gem
- Ruby 2.7.8 or newer
- Chroma Database 0.3.25 or later running as a client/server model.
For Chroma database 0.3.22 or older, please use version 0.3.0 of this gem.
To install the gem and add to the application's Gemfile, execute:
$ bundle add chroma-db
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install chroma-db
To use the Jupyter Noterbook Chroma gem in this repository, please install python 3.9 or better, iruby and Jupyter notebook dependencies:
$ pip install jupyterlab notebook ipywidgets
$ gem install iruby
$ iruby register --force
After checking out the repo, run bin/setup
to install dependencies. Then, run rake test
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
.
To generate Rdoc documentation for the gem, run bundle exec rake rdoc
.
Bug reports and pull requests are welcome on GitHub at https://github.com/mariochavez/chroma. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Chroma project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.