weaviate-ruby 0.8.11 → 0.9.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1533db1f83e65e849863776ab0312149c0e5dcdcbb2c65ea922294ea9af6ee7
4
- data.tar.gz: ce9ca1a00db9c4b117a8c19216c9049663f481750b7773bd69a4637f26074282
3
+ metadata.gz: 1132fea78a812b9835eef5a94fffc191551e9f327955e1ba89f4509888fa8146
4
+ data.tar.gz: 68eb70bc73f8641c2915028c6d64c48c959bb8bc785a042f0ddee95b0ef07c50
5
5
  SHA512:
6
- metadata.gz: 8af749e6537bdef2d2c87fdc0b0724e860368f00f37550c94a7b3e0139555c89d624fda050abda601b7c7d317ad9eccdfb01ee654586e6ce038e7048128d37cb
7
- data.tar.gz: 4afef756ad24eba7c8fb9314219dda512e49ae2cf0dc07ce9f8cc9ec1269d4b71c7ef738b4f36de780147e9b707f384bf0cb271d7ebf57d3333c2ce9e135ac07
6
+ metadata.gz: 1ac5684f8542587c703b2b694552bb256390af95171e25bce26157fb19c09d4e409a3adaee6b6b9372b8092b4d43e93b03784cbdfe761beb46fc2037d69d14f5
7
+ data.tar.gz: 5a1de134f24d453e4fdb2876d4d58ba0564f485aa093f727d37830a9f970c2dce60c648741dcf01dce2f33ccd458ebbb1a514ad546ea399be5c1feec0ec02b20
data/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.9.1] - 2024-09-19
4
+
5
+ ## [0.9.0] - 2024-07-08
6
+
7
+ - Add object.replace method which uses PUT which performs a complete object replacement
8
+
9
+ ### Breaking
10
+ - Change the object.update method to use PATCH which only performs a partial update(previously performed a replacement)
11
+
12
+ ## [0.8.11] - 2024-07-02
13
+ - Allow the user to specify any options they want for multi-tenancy when creating a schema using their own hash
14
+ - Allow Ollama vectorizer
15
+
16
+ ## [0.8.10] - 2024-01-25
17
+
18
+ ## [0.8.9] - 2023-10-10
19
+
20
+ ## [0.8.8] - 2023-10-10
21
+
22
+ ## [0.8.7] - 2023-09-11
23
+
24
+ ## [0.8.6] - 2023-08-10
25
+
3
26
  ## [0.8.5] - 2023-07-19
4
27
  - Add multi-tenancy support
5
28
 
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- weaviate-ruby (0.8.11)
4
+ weaviate-ruby (0.9.1)
5
5
  faraday (>= 2.0.1, < 3.0)
6
- graphlient (~> 0.7.0)
6
+ graphlient (>= 0.7.0, < 0.9.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
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,25 +160,28 @@ client.objects.list()
159
160
  # Get a single data object.
160
161
  client.objects.get(
161
162
  class_name: "Question",
162
- id: "uuid"
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: "uuid"
169
+ id: uuid
169
170
  )
170
171
 
171
- # Delete a single data object from Weaviate.
172
- client.objects.delete(
172
+ # Perform a partial update on an object based on its uuid.
173
+ client.objects.update(
173
174
  class_name: "Question",
174
- id: "uuid"
175
+ id: uuid,
176
+ properties: {
177
+ category: "simple-math"
178
+ }
175
179
  )
176
180
 
177
- # Update a single data object based on its uuid.
178
- client.objects.update(
181
+ # Replace an object based on its uuid.
182
+ client.objects.replace(
179
183
  class_name: "Question",
180
- id: "uuid",
184
+ id: uuid,
181
185
  properties: {
182
186
  question: "What does 6 times 7 equal to?",
183
187
  category: "math",
@@ -185,31 +189,38 @@ client.objects.update(
185
189
  }
186
190
  )
187
191
 
192
+ # Delete a single data object from Weaviate.
193
+ client.objects.delete(
194
+ class_name: "Question",
195
+ id: uuid
196
+ )
197
+
188
198
  # Batch create objects
189
- client.objects.batch_create(objects: [
199
+ output = client.objects.batch_create(objects: [
190
200
  {
191
201
  class: "Question",
192
202
  properties: {
193
- answer: "42",
194
- question: "What is the meaning of life?",
195
- category: "philosophy"
203
+ answer: "42",
204
+ question: "What is the meaning of life?",
205
+ category: "philosophy"
196
206
  }
197
207
  }, {
198
208
  class: "Question",
199
209
  properties: {
200
- answer: "42",
201
- question: "What does 6 times 7 equal to?",
202
- category: "math"
210
+ answer: "42",
211
+ question: "What does 6 times 7 equal to?",
212
+ category: "math"
203
213
  }
204
214
  }
205
215
  ])
216
+ uuids = output.pluck("id")
206
217
 
207
218
  # Batch delete objects
208
219
  client.objects.batch_delete(
209
220
  class_name: "Question",
210
221
  where: {
211
- valueString: "uuid",
212
- operator: "Equal",
222
+ valueStringArray: uuids,
223
+ operator: "ContainsAny",
213
224
  path: ["id"]
214
225
  }
215
226
  )
@@ -343,21 +354,14 @@ client.ready?
343
354
 
344
355
  ### Tenants
345
356
 
346
- Any schema can be multi-tenant
347
-
348
- ```ruby
349
- client.schema.create(
350
- # Other keys...
351
- mutli_tenant: true, # passes { enabled: true } to weaviate
352
- )
353
- ```
354
-
355
- 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()`.
356
358
 
357
359
  ```ruby
358
360
  client.schema.create(
359
361
  # Other keys...
360
- mutli_tenant: { enabled: true, autoTenantCreation: true, autoTenantActivation: true },
362
+ multi_tenant: true,
363
+ auto_tenant_creation: true,
364
+ auto_tenant_activation: true
361
365
  )
362
366
  ```
363
367
 
@@ -106,6 +106,7 @@ module Weaviate
106
106
  end
107
107
  faraday.request :json
108
108
  faraday.response :json, content_type: /\bjson$/
109
+ faraday.response :raise_error
109
110
  faraday.adapter adapter
110
111
 
111
112
  faraday.headers[API_KEY_HEADERS[model_service]] = model_service_api_key if model_service && model_service_api_key
@@ -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.blank?
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
@@ -122,6 +122,31 @@ module Weaviate
122
122
  )
123
123
  validate_consistency_level!(consistency_level) unless consistency_level.nil?
124
124
 
125
+ response = client.connection.patch("#{PATH}/#{class_name}/#{id}") do |req|
126
+ req.params["consistency_level"] = consistency_level.to_s.upcase unless consistency_level.nil?
127
+
128
+ req.body = {}
129
+ req.body["id"] = id
130
+ req.body["class"] = class_name
131
+ req.body["properties"] = properties
132
+ req.body["vector"] = vector unless vector.nil?
133
+ req.body["tenant"] = tenant unless tenant.nil?
134
+ end
135
+
136
+ response.body
137
+ end
138
+
139
+ # Replace an individual data object based on its uuid.
140
+ def replace(
141
+ class_name:,
142
+ id:,
143
+ properties:,
144
+ vector: nil,
145
+ tenant: nil,
146
+ consistency_level: nil
147
+ )
148
+ validate_consistency_level!(consistency_level) unless consistency_level.nil?
149
+
125
150
  response = client.connection.put("#{PATH}/#{class_name}/#{id}") do |req|
126
151
  req.params["consistency_level"] = consistency_level.to_s.upcase unless consistency_level.nil?
127
152
 
@@ -26,7 +26,9 @@ module Weaviate
26
26
  class_name:,
27
27
  description: nil,
28
28
  properties: nil,
29
- multi_tenant: nil,
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
- if multi_tenant.is_a?(Hash)
47
- req.body["multiTenancyConfig"] = multi_tenant
48
- elsif multi_tenant.present?
49
- req.body["multiTenancyConfig"] = {enabled: true}
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Weaviate
4
- VERSION = "0.8.11"
4
+ VERSION = "0.9.1"
5
5
  end
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.8.11
4
+ version: 0.9.1
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-07-02 00:00:00.000000000 Z
11
+ date: 2024-09-19 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.4.1
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