chroma-db 0.5.0 → 0.6.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: 2d7ef50774b1e00c56ee2f67670afc3b7d2fd0760ace64627985ed6460701b7b
4
- data.tar.gz: 9e4f771c7ab2fe8b3ceead3efa3dbe3e03155d2ab8823c895b90e72ac78f7f9b
3
+ metadata.gz: c10027541e8648c0ba4e6ebe73fef4fdb75d55a1c04c0e59bcd681a1b2108598
4
+ data.tar.gz: fb5a8a590885bc26fcabfd379b6ee5aaada355f99e05ab50eca32280a80bccea
5
5
  SHA512:
6
- metadata.gz: 3dee2d6604b17ac0baf2872ba0b807ebe7acafdbce4c3fdbc1453f737161e1916b30fe80e7a09daf34d0ced994a918d604e74b4aac355381fff1f89b635fc2ce
7
- data.tar.gz: bb8a63c2937041c4123d08f89704fa755a2096724e57176e37c8fed2d3902d7c6df2889c621cb7ced4372938a70870f47525560c09615c7d8d48520192d3ae4f
6
+ metadata.gz: 3665995e6028599eae9daf8f546e2923075b441596b4f5854bfb33901405ea8c59c47d8ec237d1c079e8e9b68115181fb2cfb4db5fd794db1e2a5a8cd61bf755
7
+ data.tar.gz: 1f1a9534d6422b34b7d7f0a8a6cb1a4f331076e44dc030e46fcbf7af971b9181747b1fa38a616cf3c44636010a54ea0eaba357dd3f7878f94cf51c40d883d854
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.6.0] 2023-06-05
4
+
5
+ - Fix failure to rescue from API call exceptions.
6
+ - Fix embedding loading into Embedding resource.
7
+
3
8
  ## [0.5.0] 2023-05-26
4
9
 
5
10
  - Adds method `get_or_create` to Collection class.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chroma-db (0.5.0)
4
+ chroma-db (0.6.0)
5
5
  dry-monads (~> 1.6)
6
6
  ruby-next (>= 0.15.0)
7
7
 
@@ -48,7 +48,7 @@ module Chroma
48
48
  if result.success?
49
49
  build_embeddings_response(result.success.body)
50
50
  else
51
- raise_failure_error(result)
51
+ self.class.raise_failure_error(result)
52
52
  end
53
53
  end
54
54
 
@@ -92,7 +92,7 @@ module Chroma
92
92
  if result.success?
93
93
  build_embeddings_response(result.success.body)
94
94
  else
95
- raise_failure_error(result)
95
+ self.class.raise_failure_error(result)
96
96
  end
97
97
  end
98
98
 
@@ -116,7 +116,7 @@ module Chroma
116
116
 
117
117
  return true if result.success?
118
118
 
119
- raise_failure_error(result)
119
+ self.class.raise_failure_error(result)
120
120
  end
121
121
 
122
122
  # Delete embeddings from the collection.
@@ -142,7 +142,7 @@ module Chroma
142
142
 
143
143
  return result.success.body if result.success?
144
144
 
145
- raise_failure_error(result)
145
+ self.class.raise_failure_error(result)
146
146
  end
147
147
 
148
148
  # Update one or many embeddings to the collection.
@@ -166,7 +166,7 @@ module Chroma
166
166
 
167
167
  return true if result.success?
168
168
 
169
- raise_failure_error(result)
169
+ self.class.raise_failure_error(result)
170
170
  end
171
171
 
172
172
  # Upsert (insert or update) one or many embeddings to the collection.
@@ -177,8 +177,8 @@ module Chroma
177
177
  #
178
178
  # collection = Chroma::Resource::Collection.get("ruby-documentation")
179
179
  # embeddings = [
180
- # Embedding.new(id: "Array#fetch", embeddings[9.8, 2.3, 2.9], metadata: {url: "https://..."}),
181
- # Embedding.new(id: "Array#select", embeddings[5.6, 3.1, 4.7], metadata: {url: "https://..."})
180
+ # Embedding.new(id: "Array#fetch", embeddings: [9.8, 2.3, 2.9], metadata: {url: "https://..."}),
181
+ # Embedding.new(id: "Array#select", embeddings: [5.6, 3.1, 4.7], metadata: {url: "https://..."})
182
182
  # ]
183
183
  # collection.upsert()
184
184
  #
@@ -193,7 +193,7 @@ module Chroma
193
193
 
194
194
  return true if result.success?
195
195
 
196
- raise_failure_error(result)
196
+ self.class.raise_failure_error(result)
197
197
  end
198
198
 
199
199
  # Count the number of embeddings in a collection.
@@ -209,7 +209,7 @@ module Chroma
209
209
 
210
210
  return result.success.body if result.success?
211
211
 
212
- raise_failure_error(result)
212
+ self.class.raise_failure_error(result)
213
213
  end
214
214
 
215
215
  # Modify the name and metadata of the current collection.
@@ -233,7 +233,7 @@ module Chroma
233
233
  @name = new_name
234
234
  @metadata = new_metadata
235
235
  else
236
- raise_failure_error(result)
236
+ self.class.raise_failure_error(result)
237
237
  end
238
238
  end
239
239
 
@@ -250,7 +250,7 @@ module Chroma
250
250
 
251
251
  return true if result.success?
252
252
 
253
- raise_failure_error(result)
253
+ self.class.raise_failure_error(result)
254
254
  end
255
255
 
256
256
  # Create a new collection on the database.
@@ -376,7 +376,6 @@ module Chroma
376
376
  raise Chroma::APIError.new(result.failure.body, status: result.failure.status, body: result.failure.body)
377
377
  end
378
378
  end
379
- private_class_method :raise_failure_error
380
379
 
381
380
  private
382
381
 
@@ -397,7 +396,7 @@ module Chroma
397
396
  Chroma::Util.log_debug("Building embeddings from #{result.inspect}")
398
397
 
399
398
  result_ids = result.fetch("ids", []).flatten
400
- result_embeddings = (result.dig("embeddings") || []).flatten
399
+ result_embeddings = result.dig("embeddings") || []
401
400
  result_documents = (result.dig("documents") || []).flatten
402
401
  result_metadatas = (result.dig("metadatas") || []).flatten
403
402
  result_distances = (result.dig("distances") || []).flatten
@@ -48,7 +48,7 @@ module Chroma
48
48
  if result.success?
49
49
  build_embeddings_response(result.success.body)
50
50
  else
51
- raise_failure_error(result)
51
+ self.class.raise_failure_error(result)
52
52
  end
53
53
  end
54
54
 
@@ -92,7 +92,7 @@ module Chroma
92
92
  if result.success?
93
93
  build_embeddings_response(result.success.body)
94
94
  else
95
- raise_failure_error(result)
95
+ self.class.raise_failure_error(result)
96
96
  end
97
97
  end
98
98
 
@@ -116,7 +116,7 @@ module Chroma
116
116
 
117
117
  return true if result.success?
118
118
 
119
- raise_failure_error(result)
119
+ self.class.raise_failure_error(result)
120
120
  end
121
121
 
122
122
  # Delete embeddings from the collection.
@@ -142,7 +142,7 @@ module Chroma
142
142
 
143
143
  return result.success.body if result.success?
144
144
 
145
- raise_failure_error(result)
145
+ self.class.raise_failure_error(result)
146
146
  end
147
147
 
148
148
  # Update one or many embeddings to the collection.
@@ -166,7 +166,7 @@ module Chroma
166
166
 
167
167
  return true if result.success?
168
168
 
169
- raise_failure_error(result)
169
+ self.class.raise_failure_error(result)
170
170
  end
171
171
 
172
172
  # Upsert (insert or update) one or many embeddings to the collection.
@@ -177,8 +177,8 @@ module Chroma
177
177
  #
178
178
  # collection = Chroma::Resource::Collection.get("ruby-documentation")
179
179
  # embeddings = [
180
- # Embedding.new(id: "Array#fetch", embeddings[9.8, 2.3, 2.9], metadata: {url: "https://..."}),
181
- # Embedding.new(id: "Array#select", embeddings[5.6, 3.1, 4.7], metadata: {url: "https://..."})
180
+ # Embedding.new(id: "Array#fetch", embeddings: [9.8, 2.3, 2.9], metadata: {url: "https://..."}),
181
+ # Embedding.new(id: "Array#select", embeddings: [5.6, 3.1, 4.7], metadata: {url: "https://..."})
182
182
  # ]
183
183
  # collection.upsert()
184
184
  #
@@ -193,7 +193,7 @@ module Chroma
193
193
 
194
194
  return true if result.success?
195
195
 
196
- raise_failure_error(result)
196
+ self.class.raise_failure_error(result)
197
197
  end
198
198
 
199
199
  # Count the number of embeddings in a collection.
@@ -209,7 +209,7 @@ module Chroma
209
209
 
210
210
  return result.success.body if result.success?
211
211
 
212
- raise_failure_error(result)
212
+ self.class.raise_failure_error(result)
213
213
  end
214
214
 
215
215
  # Modify the name and metadata of the current collection.
@@ -233,7 +233,7 @@ module Chroma
233
233
  @name = new_name
234
234
  @metadata = new_metadata
235
235
  else
236
- raise_failure_error(result)
236
+ self.class.raise_failure_error(result)
237
237
  end
238
238
  end
239
239
 
@@ -250,7 +250,7 @@ module Chroma
250
250
 
251
251
  return true if result.success?
252
252
 
253
- raise_failure_error(result)
253
+ self.class.raise_failure_error(result)
254
254
  end
255
255
 
256
256
  # Create a new collection on the database.
@@ -372,7 +372,6 @@ module Chroma
372
372
  raise Chroma::APIError.new(result.failure.body, status: result.failure.status, body: result.failure.body)
373
373
  end
374
374
  end
375
- private_class_method :raise_failure_error
376
375
 
377
376
  private
378
377
 
@@ -393,7 +392,7 @@ module Chroma
393
392
  Chroma::Util.log_debug("Building embeddings from #{result.inspect}")
394
393
 
395
394
  result_ids = result.fetch("ids", []).flatten
396
- result_embeddings = (result.dig("embeddings") || []).flatten
395
+ result_embeddings = result.dig("embeddings") || []
397
396
  result_documents = (result.dig("documents") || []).flatten
398
397
  result_metadatas = (result.dig("metadatas") || []).flatten
399
398
  result_distances = (result.dig("distances") || []).flatten
@@ -48,7 +48,7 @@ module Chroma
48
48
  if result.success?
49
49
  build_embeddings_response(result.success.body)
50
50
  else
51
- raise_failure_error(result)
51
+ self.class.raise_failure_error(result)
52
52
  end
53
53
  end
54
54
 
@@ -92,7 +92,7 @@ module Chroma
92
92
  if result.success?
93
93
  build_embeddings_response(result.success.body)
94
94
  else
95
- raise_failure_error(result)
95
+ self.class.raise_failure_error(result)
96
96
  end
97
97
  end
98
98
 
@@ -116,7 +116,7 @@ module Chroma
116
116
 
117
117
  return true if result.success?
118
118
 
119
- raise_failure_error(result)
119
+ self.class.raise_failure_error(result)
120
120
  end
121
121
 
122
122
  # Delete embeddings from the collection.
@@ -142,7 +142,7 @@ module Chroma
142
142
 
143
143
  return result.success.body if result.success?
144
144
 
145
- raise_failure_error(result)
145
+ self.class.raise_failure_error(result)
146
146
  end
147
147
 
148
148
  # Update one or many embeddings to the collection.
@@ -166,7 +166,7 @@ module Chroma
166
166
 
167
167
  return true if result.success?
168
168
 
169
- raise_failure_error(result)
169
+ self.class.raise_failure_error(result)
170
170
  end
171
171
 
172
172
  # Upsert (insert or update) one or many embeddings to the collection.
@@ -177,8 +177,8 @@ module Chroma
177
177
  #
178
178
  # collection = Chroma::Resource::Collection.get("ruby-documentation")
179
179
  # embeddings = [
180
- # Embedding.new(id: "Array#fetch", embeddings[9.8, 2.3, 2.9], metadata: {url: "https://..."}),
181
- # Embedding.new(id: "Array#select", embeddings[5.6, 3.1, 4.7], metadata: {url: "https://..."})
180
+ # Embedding.new(id: "Array#fetch", embeddings: [9.8, 2.3, 2.9], metadata: {url: "https://..."}),
181
+ # Embedding.new(id: "Array#select", embeddings: [5.6, 3.1, 4.7], metadata: {url: "https://..."})
182
182
  # ]
183
183
  # collection.upsert()
184
184
  #
@@ -193,7 +193,7 @@ module Chroma
193
193
 
194
194
  return true if result.success?
195
195
 
196
- raise_failure_error(result)
196
+ self.class.raise_failure_error(result)
197
197
  end
198
198
 
199
199
  # Count the number of embeddings in a collection.
@@ -209,7 +209,7 @@ module Chroma
209
209
 
210
210
  return result.success.body if result.success?
211
211
 
212
- raise_failure_error(result)
212
+ self.class.raise_failure_error(result)
213
213
  end
214
214
 
215
215
  # Modify the name and metadata of the current collection.
@@ -233,7 +233,7 @@ module Chroma
233
233
  @name = new_name
234
234
  @metadata = new_metadata
235
235
  else
236
- raise_failure_error(result)
236
+ self.class.raise_failure_error(result)
237
237
  end
238
238
  end
239
239
 
@@ -250,7 +250,7 @@ module Chroma
250
250
 
251
251
  return true if result.success?
252
252
 
253
- raise_failure_error(result)
253
+ self.class.raise_failure_error(result)
254
254
  end
255
255
 
256
256
  # Create a new collection on the database.
@@ -372,7 +372,6 @@ module Chroma
372
372
  raise Chroma::APIError.new(result.failure.body, status: result.failure.status, body: result.failure.body)
373
373
  end
374
374
  end
375
- private_class_method :raise_failure_error
376
375
 
377
376
  private
378
377
 
@@ -393,7 +392,7 @@ module Chroma
393
392
  Chroma::Util.log_debug("Building embeddings from #{result.inspect}")
394
393
 
395
394
  result_ids = result.fetch("ids", []).flatten
396
- result_embeddings = (result.dig("embeddings") || []).flatten
395
+ result_embeddings = result.dig("embeddings") || []
397
396
  result_documents = (result.dig("documents") || []).flatten
398
397
  result_metadatas = (result.dig("metadatas") || []).flatten
399
398
  result_distances = (result.dig("distances") || []).flatten
data/lib/chroma/util.rb CHANGED
@@ -63,7 +63,7 @@ module Chroma
63
63
  def self.log_internal(message, data = {}, level:, logger:)
64
64
  data_str = data.reject { |_k, v| v.nil? }.map { |(k, v)| "#{k}=#{v}" }.join(" ")
65
65
 
66
- logger&.log(level, "message=#{message} #{data_str}".strip)
66
+ logger&.add(level, "message=#{message} #{data_str}".strip)
67
67
  end
68
68
  private_class_method :log_internal
69
69
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Chroma
4
- VERSION = "0.5.0"
4
+ VERSION = "0.6.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.5.0
4
+ version: 0.6.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-05-26 00:00:00.000000000 Z
11
+ date: 2023-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-monads
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.6'
27
27
  - !ruby/object:Gem::Dependency
28
- name: ruby-next-core
28
+ name: ruby-next
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="