chromable 0.1.3 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -10
- data/chromable.gemspec +0 -1
- data/lib/chromable/version.rb +1 -1
- data/lib/chromable.rb +12 -15
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9df743def1991fb00b56fdfb0878642a2e5568136d4078dcb77084cf47c6ce14
|
4
|
+
data.tar.gz: 6972ef16ef5c9f6f2f39de7e18c7028399d73b917001243c272e3b94d41839dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07adc75fffe609a6e493f30091745093c3bb9164cd8e64c1f81519f8c447c4a6142075de97d461062903c28ac4d1a15d79bc501c57731e0d167a8562a696650b
|
7
|
+
data.tar.gz: 7818ee8d5a931f5e7936a0e27bb3bc716f349415e01f3cda33ff4cd72cf3ee237a5df157709a562238469659a828121e7d55b772b531bd06c1ddc2c7bc499204
|
data/README.md
CHANGED
@@ -4,19 +4,11 @@ Ruby on Rails integration for ChromaDB based on `chroma-db` gem.
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
$ bundle add chroma-db
|
10
|
-
|
11
|
-
Or, if you are not using bundler, install it by executing:
|
12
|
-
|
13
|
-
$ gem install chroma-db
|
14
|
-
|
15
|
-
Then, install `chromable` and add to the application's Gemfile by executing:
|
7
|
+
Install `chromable` and add it to the application's Gemfile by executing:
|
16
8
|
|
17
9
|
$ bundle add chromable
|
18
10
|
|
19
|
-
Or, if
|
11
|
+
Or, if bundler is not being used to manage dependencies, install `chromable` by executing:
|
20
12
|
|
21
13
|
$ gem install chromable
|
22
14
|
|
@@ -39,6 +31,10 @@ class Post < ApplicationRecord
|
|
39
31
|
include Chromable
|
40
32
|
|
41
33
|
chromable document: :content, metadata: %i[author category], embedder: :embed
|
34
|
+
|
35
|
+
def embed
|
36
|
+
# Call OpenAI now please :)
|
37
|
+
end
|
42
38
|
end
|
43
39
|
```
|
44
40
|
|
@@ -51,6 +47,8 @@ Optionaly you can pass `collection_name:`. If not passed, the plural form of the
|
|
51
47
|
|
52
48
|
All `chromable` method arguments are optional.
|
53
49
|
|
50
|
+
At this point, `chromable` will create, update, and destroy the ChromaDB embeddings for your objects based on Rails callbacks.
|
51
|
+
|
54
52
|
To interact with the ChromaDB collection, `chromable` provides `Model.collection` method to retrieve the collection instance.
|
55
53
|
Also, `chromable` provides the following methods for each model instance:
|
56
54
|
|
data/chromable.gemspec
CHANGED
@@ -32,7 +32,6 @@ 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
35
|
spec.add_dependency 'chroma-db', '>= 0.6.0'
|
37
36
|
|
38
37
|
# For more information and examples about making a new gem, check out our
|
data/lib/chromable/version.rb
CHANGED
data/lib/chromable.rb
CHANGED
@@ -1,24 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'active_support/concern'
|
4
|
-
|
5
3
|
require_relative 'chromable/version'
|
6
4
|
|
7
5
|
# Ruby on Rails integration for ChromaDB.
|
8
6
|
module Chromable
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
class_attribute :embedder
|
7
|
+
def self.included(base)
|
8
|
+
base.extend ClassMethods
|
9
|
+
base.class_attribute :collection_name
|
10
|
+
base.class_attribute :document
|
11
|
+
base.class_attribute :metadata
|
12
|
+
base.class_attribute :embedder
|
13
|
+
|
14
|
+
base.after_save :chroma_upsert_embedding
|
15
|
+
base.after_destroy :chroma_destroy_embedding
|
19
16
|
end
|
20
17
|
|
21
|
-
|
18
|
+
module ClassMethods
|
22
19
|
def chromable(collection_name: nil, document: nil, metadata: nil, embedder: nil)
|
23
20
|
self.collection_name = (collection_name.presence || name.underscore.pluralize)
|
24
21
|
self.document = document
|
@@ -53,6 +50,6 @@ module Chromable
|
|
53
50
|
end
|
54
51
|
|
55
52
|
alias embedding chroma_embedding unless method_defined? :embedding
|
56
|
-
alias upsert_embedding
|
57
|
-
alias destroy_embedding
|
53
|
+
alias upsert_embedding chroma_upsert_embedding unless method_defined? :upsert_embedding
|
54
|
+
alias destroy_embedding chroma_destroy_embedding unless method_defined? :destroy_embedding
|
58
55
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ali Hamdi Ali Fadel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: activesupport
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '6.1'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '6.1'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: chroma-db
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|