chroma-db 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/lib/.rbnext/2.7/chroma/resources/collection.rb +12 -13
- data/lib/.rbnext/3.1/chroma/resources/collection.rb +12 -13
- data/lib/chroma/resources/collection.rb +12 -13
- data/lib/chroma/util.rb +1 -1
- data/lib/chroma/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c10027541e8648c0ba4e6ebe73fef4fdb75d55a1c04c0e59bcd681a1b2108598
|
4
|
+
data.tar.gz: fb5a8a590885bc26fcabfd379b6ee5aaada355f99e05ab50eca32280a80bccea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3665995e6028599eae9daf8f546e2923075b441596b4f5854bfb33901405ea8c59c47d8ec237d1c079e8e9b68115181fb2cfb4db5fd794db1e2a5a8cd61bf755
|
7
|
+
data.tar.gz: 1f1a9534d6422b34b7d7f0a8a6cb1a4f331076e44dc030e46fcbf7af971b9181747b1fa38a616cf3c44636010a54ea0eaba357dd3f7878f94cf51c40d883d854
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -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 =
|
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 =
|
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 =
|
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&.
|
66
|
+
logger&.add(level, "message=#{message} #{data_str}".strip)
|
67
67
|
end
|
68
68
|
private_class_method :log_internal
|
69
69
|
end
|
data/lib/chroma/version.rb
CHANGED
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.
|
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-
|
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
|
28
|
+
name: ruby-next
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|