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 +4 -4
- data/README.md +37 -11
- data/chromable.gemspec +2 -2
- data/lib/chromable/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5695e34925255a187cf2cdca8337c8cb408e688b905984f28af08f43a12b8ffc
|
4
|
+
data.tar.gz: 5cbb179745647c0fd4fb982a4890570f6dbdf7e9d269f3af6b468949829cf83b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e281b9fd661de160e7c4c27a0333f7db04b57971a87cba74b8aaa4ff2eb1d5e12f4cb7683692b6ad26e8f048cb2e78ace7113e16f07c420fb3962e2259f3b8db
|
7
|
+
data.tar.gz: 73531acad9fecd1eea5da410e3191994bea0a7ff149da71f1f630b0c3770b8594af900c4efd86d64f0db02be2d8193d07d8c31f60790ae92233b578fc2595933
|
data/README.md
CHANGED
@@ -1,34 +1,60 @@
|
|
1
1
|
# Chromable
|
2
2
|
|
3
|
-
|
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
|
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
|
13
|
+
$ gem install chromable
|
18
14
|
|
19
15
|
## Usage
|
20
16
|
|
21
|
-
|
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 `
|
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
|
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/
|
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', '
|
36
|
-
spec.add_dependency 'chroma-db', '
|
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
|
data/lib/chromable/version.rb
CHANGED
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.
|
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:
|