chroma-db 0.8.0 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/chroma/api_operations/request.rb +6 -3
- data/lib/chroma/chroma.rb +1 -12
- data/lib/chroma/resources/collection.rb +3 -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: 8f7a0ef254b27e7e3d06c9720893c4b416f971948aeda404da63d18325309c6f
|
4
|
+
data.tar.gz: 356777eec892cd99f11635cadcd4e510e5041cc40b8b04c2a8e4ecaa1179da65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbb667f3547c3a08f0a3859d3dc3fe4802bbbca46722af363cfcfad556c163c83e3606b48254fd43c8b1186ace9c63e764e32568e7e7eef4987b8e89632847f0
|
7
|
+
data.tar.gz: 1822f4ff02a4dafffbb32078ed186da5d9ccb0228725bb8fbf5b61f8d1f89fd78c0297605e49a9e050e2086ce81ac67771b0a273db25ed59970b5930729a2baa
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## 0.8.2 2024-10-16
|
4
|
+
|
5
|
+
- Fixes API change in Collection#query method. Parameters `where` and `where_document` are now optional.
|
6
|
+
|
7
|
+
## 0.8.1 2024-10-16
|
8
|
+
|
9
|
+
- Adds support for Chroma hosted service. See README for more details how to set your `api_key`, `tenant`, and `database`.
|
10
|
+
|
3
11
|
## [0.6.0] 2023-06-05
|
4
12
|
|
5
13
|
- Fix failure to rescue from API call exceptions.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -54,7 +54,7 @@ Chroma.database = "my_database" # Optional
|
|
54
54
|
|
55
55
|
## Requirements
|
56
56
|
|
57
|
-
- Ruby 3.
|
57
|
+
- Ruby 3.1.4 or newer
|
58
58
|
- Chroma Database 0.4.24 or later running as a client/server model.
|
59
59
|
|
60
60
|
For Chroma database 0.3.22 or older, please use version 0.3.0 of this gem.
|
@@ -94,9 +94,9 @@ module Chroma
|
|
94
94
|
|
95
95
|
case response
|
96
96
|
in Net::HTTPSuccess
|
97
|
-
|
97
|
+
Success(response_data)
|
98
98
|
else
|
99
|
-
|
99
|
+
Failure(response_data)
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
@@ -107,6 +107,8 @@ module Chroma
|
|
107
107
|
end
|
108
108
|
|
109
109
|
private def build_request(method, uri, params)
|
110
|
+
uri.query = URI.encode_www_form(tenant: Chroma.tenant, database: Chroma.database) unless Chroma.api_key.nil?
|
111
|
+
|
110
112
|
request = case method
|
111
113
|
when :post then Net::HTTP::Post.new(uri)
|
112
114
|
when :put then Net::HTTP::Put.new(uri)
|
@@ -115,10 +117,11 @@ module Chroma
|
|
115
117
|
Net::HTTP::Get.new(uri)
|
116
118
|
end
|
117
119
|
|
120
|
+
api_key = ENV.fetch("CHROMA_SERVER_AUTHN_CREDENTIALS", Chroma.api_key)
|
118
121
|
request.content_type = "application/json"
|
119
122
|
request.body = params.to_json if params.size > 0
|
120
123
|
request.basic_auth(uri.user, uri.password) if !uri.user.nil?
|
121
|
-
request[
|
124
|
+
request["X-Chroma-Token"] = api_key unless api_key.nil?
|
122
125
|
request
|
123
126
|
end
|
124
127
|
end
|
data/lib/chroma/chroma.rb
CHANGED
@@ -25,18 +25,7 @@ module Chroma
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.api_url
|
28
|
-
|
29
|
-
uri = URI(base_url)
|
30
|
-
|
31
|
-
unless api_key.nil?
|
32
|
-
query_params = {
|
33
|
-
tenant: tenant,
|
34
|
-
database: database
|
35
|
-
}
|
36
|
-
query_params["x-chroma-token"] = api_key
|
37
|
-
uri.query = URI.encode_www_form(query_params)
|
38
|
-
end
|
39
|
-
uri.to_s
|
28
|
+
"#{connect_host}/#{api_base}/#{api_version}"
|
40
29
|
end
|
41
30
|
|
42
31
|
Chroma.log_level = ENV["CHROMA_LOG"].to_i unless ENV["CHROMA_LOG"].nil?
|
@@ -34,7 +34,7 @@ module Chroma
|
|
34
34
|
# embeddings = collection.query(query_embeddings: [[1.5, 2.9, 3.3]], results: 5)
|
35
35
|
#
|
36
36
|
# Return an Array of Embedding with query results.
|
37
|
-
def query(query_embeddings:, results: 10, where:
|
37
|
+
def query(query_embeddings:, results: 10, where: nil, where_document: nil, include: %w[metadatas documents distances])
|
38
38
|
payload = {
|
39
39
|
query_embeddings:,
|
40
40
|
n_results: results,
|
@@ -43,6 +43,8 @@ module Chroma
|
|
43
43
|
include:
|
44
44
|
}
|
45
45
|
|
46
|
+
payload.delete_if { |_key, value| value.nil? }
|
47
|
+
|
46
48
|
result = self.class.execute_request(:post, "#{Chroma.api_url}/collections/#{id}/query", payload)
|
47
49
|
|
48
50
|
if result.success?
|
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.8.
|
4
|
+
version: 0.8.2
|
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: 2024-
|
11
|
+
date: 2024-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-monads
|
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
- !ruby/object:Gem::Version
|
129
129
|
version: '0'
|
130
130
|
requirements: []
|
131
|
-
rubygems_version: 3.5.
|
131
|
+
rubygems_version: 3.5.23
|
132
132
|
signing_key:
|
133
133
|
specification_version: 4
|
134
134
|
summary: Ruby client for Chroma DB.
|