weaviate-ruby 0.9.0 → 0.9.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 +5 -0
- data/Gemfile.lock +2 -2
- data/README.md +21 -26
- data/lib/weaviate/client.rb +6 -2
- data/lib/weaviate/objects.rb +1 -1
- data/lib/weaviate/schema.rb +11 -5
- data/lib/weaviate/version.rb +1 -1
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7146b65ddc08015512a98785cfab5da9165c8a60f0b4ecad1a19b344047c633
|
4
|
+
data.tar.gz: 963d5665c14c5e8adc11d4ef4cbac828f960f71a26cb87904382c65a881b8fef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2597247cb0fc90705d9cad7a64f2760c2d60ded206e64081a3b7295d33b4938cac15020c0c4f5d2bdbbc04a4282e564f9196e30d454c794b71d65e3fb11749bd
|
7
|
+
data.tar.gz: 4328796a3fa21acee33699b0e915b434decccfcff4c2524ad01697c526ffea2f28b29b7c953f8dc6b7e245f5b83161fa7f0e7a47f9e9e13f7c0791277f639f14
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.9.2] - 2024-10-01
|
4
|
+
- Weaviate::Client constructor accepts customer logger: to be passed in
|
5
|
+
|
6
|
+
## [0.9.1] - 2024-09-19
|
7
|
+
|
3
8
|
## [0.9.0] - 2024-07-08
|
4
9
|
|
5
10
|
- Add object.replace method which uses PUT which performs a complete object replacement
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -144,7 +144,7 @@ client.schema.create(
|
|
144
144
|
### Using the Objects endpoint
|
145
145
|
```ruby
|
146
146
|
# Create a new data object.
|
147
|
-
client.objects.create(
|
147
|
+
output = client.objects.create(
|
148
148
|
class_name: 'Question',
|
149
149
|
properties: {
|
150
150
|
answer: '42',
|
@@ -152,6 +152,7 @@ client.objects.create(
|
|
152
152
|
category: 'philosophy'
|
153
153
|
}
|
154
154
|
)
|
155
|
+
uuid = output["id"]
|
155
156
|
|
156
157
|
# Lists all data objects in reverse order of creation.
|
157
158
|
client.objects.list()
|
@@ -159,19 +160,19 @@ client.objects.list()
|
|
159
160
|
# Get a single data object.
|
160
161
|
client.objects.get(
|
161
162
|
class_name: "Question",
|
162
|
-
id:
|
163
|
+
id: uuid
|
163
164
|
)
|
164
165
|
|
165
166
|
# Check if a data object exists.
|
166
167
|
client.objects.exists?(
|
167
168
|
class_name: "Question",
|
168
|
-
id:
|
169
|
+
id: uuid
|
169
170
|
)
|
170
171
|
|
171
172
|
# Perform a partial update on an object based on its uuid.
|
172
173
|
client.objects.update(
|
173
174
|
class_name: "Question",
|
174
|
-
id:
|
175
|
+
id: uuid,
|
175
176
|
properties: {
|
176
177
|
category: "simple-math"
|
177
178
|
}
|
@@ -180,7 +181,7 @@ client.objects.update(
|
|
180
181
|
# Replace an object based on its uuid.
|
181
182
|
client.objects.replace(
|
182
183
|
class_name: "Question",
|
183
|
-
id:
|
184
|
+
id: uuid,
|
184
185
|
properties: {
|
185
186
|
question: "What does 6 times 7 equal to?",
|
186
187
|
category: "math",
|
@@ -191,34 +192,35 @@ client.objects.replace(
|
|
191
192
|
# Delete a single data object from Weaviate.
|
192
193
|
client.objects.delete(
|
193
194
|
class_name: "Question",
|
194
|
-
id:
|
195
|
+
id: uuid
|
195
196
|
)
|
196
197
|
|
197
198
|
# Batch create objects
|
198
|
-
client.objects.batch_create(objects: [
|
199
|
+
output = client.objects.batch_create(objects: [
|
199
200
|
{
|
200
201
|
class: "Question",
|
201
202
|
properties: {
|
202
|
-
|
203
|
-
|
204
|
-
|
203
|
+
answer: "42",
|
204
|
+
question: "What is the meaning of life?",
|
205
|
+
category: "philosophy"
|
205
206
|
}
|
206
207
|
}, {
|
207
208
|
class: "Question",
|
208
209
|
properties: {
|
209
|
-
|
210
|
-
|
211
|
-
|
210
|
+
answer: "42",
|
211
|
+
question: "What does 6 times 7 equal to?",
|
212
|
+
category: "math"
|
212
213
|
}
|
213
214
|
}
|
214
215
|
])
|
216
|
+
uuids = output.pluck("id")
|
215
217
|
|
216
218
|
# Batch delete objects
|
217
219
|
client.objects.batch_delete(
|
218
220
|
class_name: "Question",
|
219
221
|
where: {
|
220
|
-
|
221
|
-
operator: "
|
222
|
+
valueStringArray: uuids,
|
223
|
+
operator: "ContainsAny",
|
222
224
|
path: ["id"]
|
223
225
|
}
|
224
226
|
)
|
@@ -352,21 +354,14 @@ client.ready?
|
|
352
354
|
|
353
355
|
### Tenants
|
354
356
|
|
355
|
-
Any schema can be multi-tenant
|
356
|
-
|
357
|
-
```ruby
|
358
|
-
client.schema.create(
|
359
|
-
# Other keys...
|
360
|
-
mutli_tenant: true, # passes { enabled: true } to weaviate
|
361
|
-
)
|
362
|
-
```
|
363
|
-
|
364
|
-
You can also manually specify your multi tenancy configuration with a hash
|
357
|
+
Any schema can be multi-tenant by passing in these options for to `schema.create()`.
|
365
358
|
|
366
359
|
```ruby
|
367
360
|
client.schema.create(
|
368
361
|
# Other keys...
|
369
|
-
|
362
|
+
multi_tenant: true,
|
363
|
+
auto_tenant_creation: true,
|
364
|
+
auto_tenant_activation: true
|
370
365
|
)
|
371
366
|
```
|
372
367
|
|
data/lib/weaviate/client.rb
CHANGED
@@ -5,7 +5,7 @@ require "graphlient"
|
|
5
5
|
|
6
6
|
module Weaviate
|
7
7
|
class Client
|
8
|
-
attr_reader :url, :api_key, :model_service, :model_service_api_key, :adapter
|
8
|
+
attr_reader :url, :api_key, :model_service, :model_service_api_key, :adapter, :logger
|
9
9
|
|
10
10
|
API_VERSION = "v1"
|
11
11
|
|
@@ -23,7 +23,8 @@ module Weaviate
|
|
23
23
|
api_key: nil,
|
24
24
|
model_service: nil,
|
25
25
|
model_service_api_key: nil,
|
26
|
-
adapter: Faraday.default_adapter
|
26
|
+
adapter: Faraday.default_adapter,
|
27
|
+
logger: nil
|
27
28
|
)
|
28
29
|
validate_model_service!(model_service) unless model_service.nil?
|
29
30
|
|
@@ -32,6 +33,7 @@ module Weaviate
|
|
32
33
|
@model_service = model_service
|
33
34
|
@model_service_api_key = model_service_api_key
|
34
35
|
@adapter = adapter
|
36
|
+
@logger = logger || Logger.new($stdout)
|
35
37
|
end
|
36
38
|
|
37
39
|
def oidc
|
@@ -105,7 +107,9 @@ module Weaviate
|
|
105
107
|
faraday.request :authorization, :Bearer, api_key
|
106
108
|
end
|
107
109
|
faraday.request :json
|
110
|
+
faraday.response :logger, logger, {headers: true, bodies: true, errors: true}
|
108
111
|
faraday.response :json, content_type: /\bjson$/
|
112
|
+
faraday.response :raise_error
|
109
113
|
faraday.adapter adapter
|
110
114
|
|
111
115
|
faraday.headers[API_KEY_HEADERS[model_service]] = model_service_api_key if model_service && model_service_api_key
|
data/lib/weaviate/objects.rb
CHANGED
@@ -50,7 +50,7 @@ module Weaviate
|
|
50
50
|
req.body = {}
|
51
51
|
req.body["class"] = class_name
|
52
52
|
req.body["properties"] = properties
|
53
|
-
req.body["tenant"] = tenant unless tenant.
|
53
|
+
req.body["tenant"] = tenant unless tenant.nil?
|
54
54
|
req.body["id"] = id unless id.nil?
|
55
55
|
req.body["vector"] = vector unless vector.nil?
|
56
56
|
end
|
data/lib/weaviate/schema.rb
CHANGED
@@ -26,7 +26,9 @@ module Weaviate
|
|
26
26
|
class_name:,
|
27
27
|
description: nil,
|
28
28
|
properties: nil,
|
29
|
-
multi_tenant:
|
29
|
+
multi_tenant: false,
|
30
|
+
auto_tenant_creation: false,
|
31
|
+
auto_tenant_activation: false,
|
30
32
|
vector_index_type: nil,
|
31
33
|
vector_index_config: nil,
|
32
34
|
vectorizer: nil,
|
@@ -43,11 +45,15 @@ module Weaviate
|
|
43
45
|
req.body["vectorizer"] = vectorizer unless vectorizer.nil?
|
44
46
|
req.body["moduleConfig"] = module_config unless module_config.nil?
|
45
47
|
req.body["properties"] = properties unless properties.nil?
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
48
|
+
|
49
|
+
if multi_tenant
|
50
|
+
req.body["multiTenancyConfig"] = {
|
51
|
+
enabled: multi_tenant,
|
52
|
+
autoTenantCreation: auto_tenant_creation,
|
53
|
+
autoTenantActivation: auto_tenant_activation
|
54
|
+
}
|
50
55
|
end
|
56
|
+
|
51
57
|
req.body["invertedIndexConfig"] = inverted_index_config unless inverted_index_config.nil?
|
52
58
|
req.body["replicationConfig"] = replication_config unless replication_config.nil?
|
53
59
|
end
|
data/lib/weaviate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weaviate-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Bondarev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -34,16 +34,22 @@ dependencies:
|
|
34
34
|
name: graphlient
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "
|
37
|
+
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: 0.7.0
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.9.0
|
40
43
|
type: :runtime
|
41
44
|
prerelease: false
|
42
45
|
version_requirements: !ruby/object:Gem::Requirement
|
43
46
|
requirements:
|
44
|
-
- - "
|
47
|
+
- - ">="
|
45
48
|
- !ruby/object:Gem::Version
|
46
49
|
version: 0.7.0
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.9.0
|
47
53
|
- !ruby/object:Gem::Dependency
|
48
54
|
name: pry-byebug
|
49
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
144
|
- !ruby/object:Gem::Version
|
139
145
|
version: '0'
|
140
146
|
requirements: []
|
141
|
-
rubygems_version: 3.
|
147
|
+
rubygems_version: 3.5.11
|
142
148
|
signing_key:
|
143
149
|
specification_version: 4
|
144
150
|
summary: Ruby wrapper for the Weaviate.io API
|