chroma-db 0.6.0 → 0.7.0

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: c10027541e8648c0ba4e6ebe73fef4fdb75d55a1c04c0e59bcd681a1b2108598
4
- data.tar.gz: fb5a8a590885bc26fcabfd379b6ee5aaada355f99e05ab50eca32280a80bccea
3
+ metadata.gz: 860772eeeda54b7057681aa0d82bf1d1737501c6d699645d74f0df907e2881d0
4
+ data.tar.gz: 66acb245e05333fdf2c2abae27823d8963f7c75c7186b0922ae83265cdb577ca
5
5
  SHA512:
6
- metadata.gz: 3665995e6028599eae9daf8f546e2923075b441596b4f5854bfb33901405ea8c59c47d8ec237d1c079e8e9b68115181fb2cfb4db5fd794db1e2a5a8cd61bf755
7
- data.tar.gz: 1f1a9534d6422b34b7d7f0a8a6cb1a4f331076e44dc030e46fcbf7af971b9181747b1fa38a616cf3c44636010a54ea0eaba357dd3f7878f94cf51c40d883d854
6
+ metadata.gz: '09c0a28cc809673c658558f95bb3fa85bc6e4845eb95b076105b4aa0e083693663e0fab386e534ae674848fc0007944b135e8a85d48a4bd616a5a105b7592b31'
7
+ data.tar.gz: b1037adef96c371cbc794580000e40ea1017085093889f248019095f80c82f18d74ca6a5394703f81f873d6366d9a99aebae56dbe6391c4e34274b56d794ccae
data/Gemfile.lock CHANGED
@@ -1,91 +1,103 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chroma-db (0.6.0)
4
+ chroma-db (0.7.0)
5
5
  dry-monads (~> 1.6)
6
6
  ruby-next (>= 0.15.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.8.4)
11
+ abbrev (0.1.2)
12
+ addressable (2.8.6)
12
13
  public_suffix (>= 2.0.2, < 6.0)
13
14
  ast (2.4.2)
14
- concurrent-ruby (1.2.2)
15
- crack (0.4.5)
15
+ bigdecimal (3.1.7)
16
+ concurrent-ruby (1.2.3)
17
+ crack (1.0.0)
18
+ bigdecimal
16
19
  rexml
17
- diff-lcs (1.5.0)
18
- dry-core (1.0.0)
20
+ diff-lcs (1.5.1)
21
+ dry-core (1.0.1)
19
22
  concurrent-ruby (~> 1.0)
20
23
  zeitwerk (~> 2.6)
21
24
  dry-monads (1.6.0)
22
25
  concurrent-ruby (~> 1.0)
23
26
  dry-core (~> 1.0, < 2)
24
27
  zeitwerk (~> 2.6)
25
- hashdiff (1.0.1)
26
- json (2.6.3)
28
+ hashdiff (1.1.0)
29
+ json (2.7.2)
27
30
  language_server-protocol (3.17.0.3)
28
- lint_roller (1.0.0)
29
- minitest (5.18.0)
30
- parallel (1.23.0)
31
- parser (3.2.2.1)
31
+ lint_roller (1.1.0)
32
+ minitest (5.22.3)
33
+ paco (0.2.3)
34
+ parallel (1.24.0)
35
+ parser (3.3.0.5)
32
36
  ast (~> 2.4.1)
33
- psych (5.1.0)
37
+ racc
38
+ psych (5.1.2)
34
39
  stringio
35
- public_suffix (5.0.1)
40
+ public_suffix (5.0.5)
41
+ racc (1.7.3)
36
42
  rainbow (3.1.1)
37
- rake (13.0.6)
38
- rbs (3.1.0)
39
- rdoc (6.5.0)
43
+ rake (13.2.1)
44
+ rbs (3.4.4)
45
+ abbrev
46
+ rdoc (6.6.3.1)
40
47
  psych (>= 4.0.0)
41
- regexp_parser (2.8.0)
42
- rexml (3.2.5)
43
- rubocop (1.50.2)
48
+ regexp_parser (2.9.0)
49
+ require-hooks (0.2.2)
50
+ rexml (3.2.6)
51
+ rubocop (1.62.1)
44
52
  json (~> 2.3)
53
+ language_server-protocol (>= 3.17.0)
45
54
  parallel (~> 1.10)
46
- parser (>= 3.2.0.0)
55
+ parser (>= 3.3.0.2)
47
56
  rainbow (>= 2.2.2, < 4.0)
48
57
  regexp_parser (>= 1.8, < 3.0)
49
58
  rexml (>= 3.2.5, < 4.0)
50
- rubocop-ast (>= 1.28.0, < 2.0)
59
+ rubocop-ast (>= 1.31.1, < 2.0)
51
60
  ruby-progressbar (~> 1.7)
52
61
  unicode-display_width (>= 2.4.0, < 3.0)
53
- rubocop-ast (1.28.1)
54
- parser (>= 3.2.1.0)
55
- rubocop-performance (1.16.0)
56
- rubocop (>= 1.7.0, < 2.0)
57
- rubocop-ast (>= 0.4.0)
58
- ruby-next (0.15.3)
59
- ruby-next-core (= 0.15.3)
60
- ruby-next-parser (>= 3.1.1.0)
62
+ rubocop-ast (1.31.2)
63
+ parser (>= 3.3.0.4)
64
+ rubocop-performance (1.20.2)
65
+ rubocop (>= 1.48.1, < 2.0)
66
+ rubocop-ast (>= 1.30.0, < 2.0)
67
+ ruby-next (1.0.2)
68
+ paco (~> 0.2)
69
+ require-hooks (~> 0.2)
70
+ ruby-next-core (= 1.0.2)
71
+ ruby-next-parser (>= 3.2.2.0)
61
72
  unparser (~> 0.6.0)
62
- ruby-next-core (0.15.3)
63
- ruby-next-parser (3.1.1.3)
73
+ ruby-next-core (1.0.2)
74
+ ruby-next-parser (3.2.2.0)
64
75
  parser (>= 3.0.3.1)
65
76
  ruby-progressbar (1.13.0)
66
77
  sdoc (2.6.1)
67
78
  rdoc (>= 5.0)
68
- standard (1.28.2)
79
+ standard (1.35.1)
69
80
  language_server-protocol (~> 3.17.0.2)
70
81
  lint_roller (~> 1.0)
71
- rubocop (~> 1.50.2)
82
+ rubocop (~> 1.62.0)
72
83
  standard-custom (~> 1.0.0)
73
- standard-performance (~> 1.0.1)
74
- standard-custom (1.0.0)
84
+ standard-performance (~> 1.3)
85
+ standard-custom (1.0.2)
75
86
  lint_roller (~> 1.0)
76
- standard-performance (1.0.1)
77
- lint_roller (~> 1.0)
78
- rubocop-performance (~> 1.16.0)
79
- stringio (3.0.6)
80
- unicode-display_width (2.4.2)
81
- unparser (0.6.7)
87
+ rubocop (~> 1.50)
88
+ standard-performance (1.3.1)
89
+ lint_roller (~> 1.1)
90
+ rubocop-performance (~> 1.20.2)
91
+ stringio (3.1.0)
92
+ unicode-display_width (2.5.0)
93
+ unparser (0.6.13)
82
94
  diff-lcs (~> 1.3)
83
- parser (>= 3.2.0)
84
- webmock (3.18.1)
95
+ parser (>= 3.3.0)
96
+ webmock (3.23.0)
85
97
  addressable (>= 2.8.0)
86
98
  crack (>= 0.3.2)
87
99
  hashdiff (>= 0.4.0, < 2.0.0)
88
- zeitwerk (2.6.8)
100
+ zeitwerk (2.6.13)
89
101
 
90
102
  PLATFORMS
91
103
  arm64-darwin-22
data/README.md CHANGED
@@ -41,7 +41,7 @@ For a complete example, please refer to the Jupyter Noterbook [Chroma gem](https
41
41
 
42
42
  ## Requirements
43
43
  - Ruby 2.7.8 or newer
44
- - Chroma Database 0.3.25 or later running as a client/server model.
44
+ - Chroma Database 0.4.24 or later running as a client/server model.
45
45
 
46
46
  For Chroma database 0.3.22 or older, please use version 0.3.0 of this gem.
47
47
 
@@ -61,6 +61,7 @@ To use the Jupyter Noterbook [Chroma gem](https://github.com/mariochavez/chroma/
61
61
  $ gem install iruby
62
62
  $ iruby register --force
63
63
 
64
+ **NOTE: ** Notebook has an example on how to create embeddings using [Ollama](https://ollama.com) and [Nomic embed text](https://ollama.com/library/nomic-embed-text) with a simple Ruby HTTP client.
64
65
  ## Development 
65
66
  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. 
66
67
 
@@ -68,6 +69,8 @@ To install this gem onto your local machine, run `bundle exec rake install`.
68
69
 
69
70
  To generate Rdoc documentation for the gem, run `bundle exec rake rdoc`.
70
71
 
72
+ ## Rails integration
73
+ If you are looking for a solution to embed your ActiveRecord models into ChromaDB, look at [Cromable gem](https://github.com/AliOsm/chromable)
71
74
  ## Contributing
72
75
  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](https://github.com/mariochavez/chroma/blob/main/CODE_OF_CONDUCT.md). 
73
76
 
@@ -44,7 +44,7 @@ module Chroma
44
44
 
45
45
  request = build_request(method, uri, params)
46
46
 
47
- use_ssl = options.delete(:use_ssl) || false
47
+ use_ssl = uri.scheme == "https"
48
48
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: use_ssl) do |http|
49
49
  Chroma::Util.log_debug("Sending a request", {method: method, uri: uri, params: params})
50
50
  http.request(request)
@@ -125,6 +125,7 @@ module Chroma
125
125
 
126
126
  request.content_type = "application/json"
127
127
  request.body = params.to_json if params.size > 0
128
+ request.basic_auth(uri.user, uri.password) if !uri.user.nil?
128
129
 
129
130
  request
130
131
  end
@@ -180,7 +180,7 @@ module Chroma
180
180
  # Embedding.new(id: "Array#fetch", embeddings: [9.8, 2.3, 2.9], metadata: {url: "https://..."}),
181
181
  # Embedding.new(id: "Array#select", embeddings: [5.6, 3.1, 4.7], metadata: {url: "https://..."})
182
182
  # ]
183
- # collection.upsert()
183
+ # collection.upsert(embeddings)
184
184
  #
185
185
  # Returns true with success or raises a Chroma::Error on failure.
186
186
  def upsert(embeddings = [])
@@ -237,22 +237,6 @@ module Chroma
237
237
  end
238
238
  end
239
239
 
240
- # Creates an index for the collection.
241
- #
242
- # Examples:
243
- #
244
- # collection = Chroma::Resource::Collection.get("ruby-documentation")
245
- # collection.create_index
246
- #
247
- # Returns true on success or raise a Chroma::Error on failure.
248
- def create_index
249
- result = self.class.execute_request(:post, "#{Chroma.api_url}/collections/#{id}/create_index")
250
-
251
- return true if result.success?
252
-
253
- self.class.raise_failure_error(result)
254
- end
255
-
256
240
  # Create a new collection on the database.
257
241
  #
258
242
  # name - The name of the collection. Name needs to be between 3-63 characters, starts and ends
@@ -29,17 +29,6 @@ module Chroma
29
29
  raise_failure_error(result)
30
30
  end
31
31
 
32
- # Persist Chroma database data.
33
- #
34
- # Resturn true on success or raise a Chroma::Error on failure.
35
- def self.persist
36
- result = execute_request(:post, "#{Chroma.api_url}/persist")
37
-
38
- return result.success.body if result.success?
39
-
40
- raise_failure_error(result)
41
- end
42
-
43
32
  # Check the heartbeat of the Chroma database server.
44
33
  #
45
34
  # Return a Hash with a timestamp.
@@ -44,7 +44,7 @@ module Chroma
44
44
 
45
45
  request = build_request(method, uri, params)
46
46
 
47
- use_ssl = options.delete(:use_ssl) || false
47
+ use_ssl = uri.scheme == "https"
48
48
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: use_ssl) do |http|
49
49
  Chroma::Util.log_debug("Sending a request", {method: method, uri: uri, params: params})
50
50
  http.request(request)
@@ -117,6 +117,7 @@ module Chroma
117
117
 
118
118
  request.content_type = "application/json"
119
119
  request.body = params.to_json if params.size > 0
120
+ request.basic_auth(uri.user, uri.password) if !uri.user.nil?
120
121
 
121
122
  request
122
123
  end
@@ -180,7 +180,7 @@ module Chroma
180
180
  # Embedding.new(id: "Array#fetch", embeddings: [9.8, 2.3, 2.9], metadata: {url: "https://..."}),
181
181
  # Embedding.new(id: "Array#select", embeddings: [5.6, 3.1, 4.7], metadata: {url: "https://..."})
182
182
  # ]
183
- # collection.upsert()
183
+ # collection.upsert(embeddings)
184
184
  #
185
185
  # Returns true with success or raises a Chroma::Error on failure.
186
186
  def upsert(embeddings = [])
@@ -237,22 +237,6 @@ module Chroma
237
237
  end
238
238
  end
239
239
 
240
- # Creates an index for the collection.
241
- #
242
- # Examples:
243
- #
244
- # collection = Chroma::Resource::Collection.get("ruby-documentation")
245
- # collection.create_index
246
- #
247
- # Returns true on success or raise a Chroma::Error on failure.
248
- def create_index
249
- result = self.class.execute_request(:post, "#{Chroma.api_url}/collections/#{id}/create_index")
250
-
251
- return true if result.success?
252
-
253
- self.class.raise_failure_error(result)
254
- end
255
-
256
240
  # Create a new collection on the database.
257
241
  #
258
242
  # name - The name of the collection. Name needs to be between 3-63 characters, starts and ends
@@ -44,7 +44,7 @@ module Chroma
44
44
 
45
45
  request = build_request(method, uri, params)
46
46
 
47
- use_ssl = options.delete(:use_ssl) || false
47
+ use_ssl = uri.scheme == "https"
48
48
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl:) do |http|
49
49
  Chroma::Util.log_debug("Sending a request", {method:, uri:, params:})
50
50
  http.request(request)
@@ -117,6 +117,7 @@ module Chroma
117
117
 
118
118
  request.content_type = "application/json"
119
119
  request.body = params.to_json if params.size > 0
120
+ request.basic_auth(uri.user, uri.password) if !uri.user.nil?
120
121
 
121
122
  request
122
123
  end
@@ -180,7 +180,7 @@ module Chroma
180
180
  # Embedding.new(id: "Array#fetch", embeddings: [9.8, 2.3, 2.9], metadata: {url: "https://..."}),
181
181
  # Embedding.new(id: "Array#select", embeddings: [5.6, 3.1, 4.7], metadata: {url: "https://..."})
182
182
  # ]
183
- # collection.upsert()
183
+ # collection.upsert(embeddings)
184
184
  #
185
185
  # Returns true with success or raises a Chroma::Error on failure.
186
186
  def upsert(embeddings = [])
@@ -237,22 +237,6 @@ module Chroma
237
237
  end
238
238
  end
239
239
 
240
- # Creates an index for the collection.
241
- #
242
- # Examples:
243
- #
244
- # collection = Chroma::Resource::Collection.get("ruby-documentation")
245
- # collection.create_index
246
- #
247
- # Returns true on success or raise a Chroma::Error on failure.
248
- def create_index
249
- result = self.class.execute_request(:post, "#{Chroma.api_url}/collections/#{id}/create_index")
250
-
251
- return true if result.success?
252
-
253
- self.class.raise_failure_error(result)
254
- end
255
-
256
240
  # Create a new collection on the database.
257
241
  #
258
242
  # name - The name of the collection. Name needs to be between 3-63 characters, starts and ends
@@ -29,17 +29,6 @@ module Chroma
29
29
  raise_failure_error(result)
30
30
  end
31
31
 
32
- # Persist Chroma database data.
33
- #
34
- # Resturn true on success or raise a Chroma::Error on failure.
35
- def self.persist
36
- result = execute_request(:post, "#{Chroma.api_url}/persist")
37
-
38
- return result.success.body if result.success?
39
-
40
- raise_failure_error(result)
41
- end
42
-
43
32
  # Check the heartbeat of the Chroma database server.
44
33
  #
45
34
  # Return a Hash with a timestamp.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Chroma
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chroma-db
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Alberto Chávez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-06 00:00:00.000000000 Z
11
+ date: 2024-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-monads
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
109
  requirements: []
110
- rubygems_version: 3.4.12
110
+ rubygems_version: 3.5.9
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: Ruby client for Chroma DB.