Git Product home page Git Product logo

chroma's Introduction

Chroma's Ruby client

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/

Description

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

Requirements

  • Ruby 2.7.8 or newer
  • Chroma Database 0.4.24 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.

Installation

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

Use the Jupyter notebook

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

**NOTE: ** Notebook has an example on how to create embeddings using Ollama and Nomic embed text with a simple Ruby HTTP client.

Development 

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.

Rails integration

If you are looking for a solution to embed your ActiveRecord models into ChromaDB, look at Cromable gem

Contributing

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

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Chroma project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.