chromable 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8aaa1100d93658218b9e57e77b9720ad67ab4efc042aa696f2fd79618951674
4
- data.tar.gz: f4d8cebff2db9c51f52a14d1ae2207efeb78b069f648ac1c5091351828275923
3
+ metadata.gz: 5695e34925255a187cf2cdca8337c8cb408e688b905984f28af08f43a12b8ffc
4
+ data.tar.gz: 5cbb179745647c0fd4fb982a4890570f6dbdf7e9d269f3af6b468949829cf83b
5
5
  SHA512:
6
- metadata.gz: aeff8a1f0407ab8596a578e0243a42de80b882d3ae0db19e6ce5e973763d4149a926b2cf8a84fdad9fa4b89d008cfae7f7abac9a14eccb1e8fdb0983eac946e6
7
- data.tar.gz: ce1f9e3b1ec077832a914a46ba4259803051ef8db36d488e1ed5c074574c36645412777929b7bf116c449f89e4a5162652ac8733fc66b275cefc07c86ceafa41
6
+ metadata.gz: e281b9fd661de160e7c4c27a0333f7db04b57971a87cba74b8aaa4ff2eb1d5e12f4cb7683692b6ad26e8f048cb2e78ace7113e16f07c420fb3962e2259f3b8db
7
+ data.tar.gz: 73531acad9fecd1eea5da410e3191994bea0a7ff149da71f1f630b0c3770b8594af900c4efd86d64f0db02be2d8193d07d8c31f60790ae92233b578fc2595933
data/README.md CHANGED
@@ -1,34 +1,60 @@
1
1
  # Chromable
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
4
-
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/chromable`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Ruby on Rails integration for ChromaDB based on `chroma-db` gem.
6
4
 
7
5
  ## Installation
8
6
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
-
11
7
  Install the gem and add to the application's Gemfile by executing:
12
8
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
9
+ $ bundle add chromable
14
10
 
15
11
  If bundler is not being used to manage dependencies, install the gem by executing:
16
12
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
13
+ $ gem install chromable
18
14
 
19
15
  ## Usage
20
16
 
21
- TODO: Write usage instructions here
17
+ `chromable` is depending on `chroma-db`, so you will need to initialize it in `config/initializers/chroma.rb`:
18
+
19
+ ```ruby
20
+ require 'chroma-db'
21
+
22
+ Chroma.connect_host = ENV.fetch('CHROMA_DB_URL', 'http://localhost:8000')
23
+ Chroma.logger = Logger.new($stdout)
24
+ Chroma.log_level = Chroma::LEVEL_ERROR
25
+ ```
26
+
27
+ Then, add the following line to your Rails model:
28
+
29
+ ```ruby
30
+ chromable document: :content, metadata: %i[author category], embedder: :embed
31
+ ```
32
+
33
+ Where:
34
+ - `document:` is a callable represents the text content you want to embed and store in ChromaDB.
35
+ - `metadata:` is the list of attributes to be passed to ChromaDB as metadata.
36
+ - `embedder:` is the method that returns the embedding representation for the current instance.
37
+
38
+ Optionaly you can pass `collection_name:`. If not passed, the plural form of the model name will be used.
39
+
40
+ To interact with the ChromaDB collection, `chromable` provides `Model.collection` method to retrieve the collection instance.
41
+ Also, `chromable` provides the following methods for each model instance:
42
+
43
+ - `embedding`: Retrieves the instance's ChromaDB embedding object.
44
+ - `upsert_embedding`: Creates or updates the instance's ChromaDB embedding object.
45
+ - `destroy_embedding`: Destroys the instance's ChromaDB embedding object.
46
+
47
+ All these methods (including `Model.collection`) are available with `chroma_` prefix, if you have similar methods defined in your model.
22
48
 
23
49
  ## Development
24
50
 
25
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
51
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
52
 
27
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
53
+ To install this gem onto your local machine, run `bundle install`. To release a new version, update the version number in `version.rb`, and then create a git tag for the version, push git commits and the created tag. The `Publish Gem` Github Action will push the `.gem` file to [rubygems.org](https://rubygems.org).
28
54
 
29
55
  ## Contributing
30
56
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/chromable. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/chromable/blob/main/CODE_OF_CONDUCT.md).
57
+ Bug reports and pull requests are welcome on GitHub at https://github.com/AliOsm/chromable. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/chromable/blob/main/CODE_OF_CONDUCT.md).
32
58
 
33
59
  ## License
34
60
 
data/chromable.gemspec CHANGED
@@ -32,8 +32,8 @@ Gem::Specification.new do |spec|
32
32
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
33
33
  spec.require_paths = ['lib']
34
34
 
35
- spec.add_dependency 'activesupport', '~> 6.1'
36
- spec.add_dependency 'chroma-db', '~> 0.6.0'
35
+ spec.add_dependency 'activesupport', '>= 6.1'
36
+ spec.add_dependency 'chroma-db', '>= 0.6.0'
37
37
 
38
38
  # For more information and examples about making a new gem, check out our
39
39
  # guide at: https://bundler.io/guides/creating_gem.html
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Chromable
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chromable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ali Hamdi Ali Fadel
@@ -14,28 +14,28 @@ dependencies:
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '6.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '6.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: chroma-db
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.6.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.6.0
41
41
  description: