weaviate-ruby 0.3.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52fb7ba7147345178fa220aa2bbed2ce66a7903a4df42b8cf5a016ddd329ff3f
4
- data.tar.gz: c03e3a537651f2c9e5beb4febdf826f22eadbce6cc1c96ed983b8e0311140604
3
+ metadata.gz: 7188f7ab1cb378b6ffecf86e173bcfd2d6f513cd004559d18cfa011d8c2f9407
4
+ data.tar.gz: fd07382e798c763a27adbce3543d224bfed059a2035625569a5247e83d11f598
5
5
  SHA512:
6
- metadata.gz: f53cf142fa41ce9236e865c251c8e183669b0c3fea0b8b3fe0720a8e9b30dedfd0e37fea888a86b75e9e3d8c5a7118592e5d4b14b1dcfc36221c85a996e332c6
7
- data.tar.gz: a71fa15a01d2d75c51de572b2f87d231862ae442a5841a2022ef25c7b20400cc3469217c1ca6d5af42a4995d5b4393f4f33795e846361cdfb663cdf6431edeed
6
+ metadata.gz: 5cb63f9f341edb1acdc580f3fab0e27190221400183c9191590d4ed7e2d08f3d48ce01167381885e3cbdda894cd0cb32c1c418a2827e2625a2a16d26306395ee
7
+ data.tar.gz: 17aa43b9a7f42b063a3e5f148a697481ea3b73bfc6dc62c7b6ab101cc24d30d8d78e4e501b3e414e6bf6ef6f73d94914df211f0025aac0f1c8d5b0fe599a1a6e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- weaviate-ruby (0.3.0)
4
+ weaviate-ruby (0.5.0)
5
5
  faraday (~> 2.7)
6
6
  graphlient (~> 0.7.0)
7
7
 
data/README.md CHANGED
@@ -134,6 +134,16 @@ response = client.objects.batch_create(objects: [
134
134
  }
135
135
  ])
136
136
  response.data
137
+
138
+ # Batch delete objects
139
+ client.objects.batch_delete(
140
+ class_name: "Question",
141
+ where: {
142
+ valueString: "1",
143
+ operator: "Equal",
144
+ path: ["id"]
145
+ }
146
+ )
137
147
  ```
138
148
 
139
149
  ### Querying
@@ -187,6 +197,55 @@ client.query.aggs(
187
197
  )
188
198
  ```
189
199
 
200
+ ### Classification
201
+ ```ruby
202
+ client.classifications.create(
203
+ type: "zeroshot",
204
+ class_name: "Posts",
205
+ classify_properties: ["hasColor"],
206
+ based_on_properties: ["text"]
207
+ )
208
+
209
+ client.classifications.get(
210
+ id: ""
211
+ )
212
+ ```
213
+
214
+ ### Backups
215
+ ```ruby
216
+ client.backups.create(
217
+ backend: "filesystem",
218
+ id: "my-first-backup",
219
+ include: ["Question"]
220
+ )
221
+
222
+ client.backups.get(
223
+ backend: "filesystem",
224
+ id: "my-first-backup"
225
+ )
226
+
227
+ client.backups.restore(
228
+ backend: "filesystem",
229
+ id: "my-first-backup"
230
+ )
231
+
232
+ client.backups.restore_status(
233
+ backend: "filesystem",
234
+ id: "my-first-backup"
235
+ )
236
+ ```
237
+
238
+ ### Nodes
239
+ ```ruby
240
+ client.nodes
241
+ ```
242
+
243
+ ### Health
244
+ ```ruby
245
+ client.live?
246
+ client.ready?
247
+ ```
248
+
190
249
  ## Development
191
250
 
192
251
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Weaviate
4
+ class Backups < Base
5
+ PATH = "backups"
6
+
7
+ def create(
8
+ backend:,
9
+ id:,
10
+ include: nil,
11
+ exclude: nil
12
+ )
13
+ response = client.connection.post("#{PATH}/#{backend}") do |req|
14
+ req.body = {}
15
+ req.body["id"] = id
16
+ req.body["include"] = include if include
17
+ req.body["exclude"] = exclude if exclude
18
+ end
19
+
20
+ response.body
21
+ end
22
+
23
+ def get(
24
+ backend:,
25
+ id:
26
+ )
27
+ response = client.connection.get("#{PATH}/#{backend}/#{id}")
28
+ response.body
29
+ end
30
+
31
+ def restore(
32
+ backend:,
33
+ id:,
34
+ include: nil,
35
+ exclude: nil
36
+ )
37
+ response = client.connection.post("#{PATH}/#{backend}/#{id}/restore") do |req|
38
+ req.body = {}
39
+ req.body["include"] = include if include
40
+ req.body["exclude"] = exclude if exclude
41
+ end
42
+
43
+ response.body
44
+ end
45
+
46
+ def restore_status(
47
+ backend:,
48
+ id:
49
+ )
50
+ response = client.connection.get("#{PATH}/#{backend}/#{id}/restore")
51
+ response.body
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Weaviate
4
+ class Classifications < Base
5
+ PATH = "classifications"
6
+
7
+ def get(id:)
8
+ response = client.connection.get("#{PATH}/#{id}")
9
+ response.body
10
+ end
11
+
12
+ def create(
13
+ class_name:,
14
+ type:,
15
+ classify_properties: nil,
16
+ based_on_properties: nil,
17
+ settings: nil,
18
+ filters: nil
19
+ )
20
+ response = client.connection.post(PATH) do |req|
21
+ req.body = {}
22
+ req.body["class"] = class_name
23
+ req.body["type"] = type
24
+ req.body["classifyProperties"] = classify_properties if classify_properties
25
+ req.body["basedOnProperties"] = based_on_properties if based_on_properties
26
+ req.body["settings"] = settings if settings
27
+ req.body["filters"] = filters if filters
28
+ end
29
+
30
+ if response.success?
31
+ response.body
32
+ end
33
+ end
34
+ end
35
+ end
@@ -44,6 +44,29 @@ module Weaviate
44
44
  @meta.get
45
45
  end
46
46
 
47
+ def nodes
48
+ @nodes ||= Weaviate::Nodes.new(client: self)
49
+ @nodes.list
50
+ end
51
+
52
+ def live?
53
+ @health ||= Weaviate::Health.new(client: self)
54
+ @health.live?
55
+ end
56
+
57
+ def ready?
58
+ @health ||= Weaviate::Health.new(client: self)
59
+ @health.ready?
60
+ end
61
+
62
+ def backups
63
+ @backups ||= Weaviate::Backups.new(client: self)
64
+ end
65
+
66
+ def classifications
67
+ @classifications ||= Weaviate::Classifications.new(client: self)
68
+ end
69
+
47
70
  def objects
48
71
  @objects ||= Weaviate::Objects.new(client: self)
49
72
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Weaviate
4
+ class Health < Base
5
+ PATH = ".well-known"
6
+
7
+ def live?
8
+ response = client.connection.get("#{PATH}/live")
9
+ response.status == 200
10
+ end
11
+
12
+ def ready?
13
+ response = client.connection.get("#{PATH}/ready")
14
+ response.status == 200
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Weaviate
4
+ class Nodes < Base
5
+ PATH = "nodes"
6
+
7
+ def list
8
+ response = client.connection.get(PATH)
9
+ response.body
10
+ end
11
+ end
12
+ end
@@ -40,8 +40,11 @@ module Weaviate
40
40
  req.body["id"] = id unless id.nil?
41
41
  req.body["vector"] = vector unless vector.nil?
42
42
  end
43
+
43
44
  if response.success?
44
45
  Weaviate::Response::Object.new(response.body)
46
+ else
47
+ response.body
45
48
  end
46
49
  end
47
50
 
@@ -105,6 +108,30 @@ module Weaviate
105
108
  response.success? && response.body.empty?
106
109
  end
107
110
 
111
+ def batch_delete(
112
+ class_name:,
113
+ where:,
114
+ consistency_level: nil,
115
+ output: nil,
116
+ dry_run: nil
117
+ )
118
+ path = "batch/#{PATH}"
119
+ path << "?consistency_level=#{consistency_level}" unless consistency_level.nil?
120
+
121
+ response = client.connection.delete(path) do |req|
122
+ req.body = {
123
+ match: {
124
+ class: class_name,
125
+ where: where
126
+ }
127
+ }
128
+ req.body["output"] = output unless output.nil?
129
+ req.body["dryRun"] = dry_run unless dry_run.nil?
130
+ end
131
+
132
+ response.body
133
+ end
134
+
108
135
  # Validate a data object
109
136
  # def validate
110
137
  # end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Weaviate
4
- VERSION = "0.3.0"
4
+ VERSION = "0.5.0"
5
5
  end
data/lib/weaviate.rb CHANGED
@@ -11,6 +11,10 @@ module Weaviate
11
11
  autoload :Objects, "weaviate/objects"
12
12
  autoload :OIDC, "weaviate/oidc"
13
13
  autoload :Query, "weaviate/query"
14
+ autoload :Nodes, "weaviate/nodes"
15
+ autoload :Health, "weaviate/health"
16
+ autoload :Classifications, "weaviate/classifications"
17
+ autoload :Backups, "weaviate/backups"
14
18
 
15
19
  module Response
16
20
  autoload :Base, "weaviate/response/base"
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.3.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Bondarev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-02 00:00:00.000000000 Z
11
+ date: 2023-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -68,10 +68,14 @@ files:
68
68
  - README.md
69
69
  - Rakefile
70
70
  - lib/weaviate.rb
71
+ - lib/weaviate/backups.rb
71
72
  - lib/weaviate/base.rb
73
+ - lib/weaviate/classifications.rb
72
74
  - lib/weaviate/client.rb
73
75
  - lib/weaviate/error.rb
76
+ - lib/weaviate/health.rb
74
77
  - lib/weaviate/meta.rb
78
+ - lib/weaviate/nodes.rb
75
79
  - lib/weaviate/objects.rb
76
80
  - lib/weaviate/oidc.rb
77
81
  - lib/weaviate/query.rb
@@ -82,13 +86,13 @@ files:
82
86
  - lib/weaviate/schema.rb
83
87
  - lib/weaviate/version.rb
84
88
  - sig/weaviate.rbs
85
- homepage: https://github.com/andreibondarev/weaviate
89
+ homepage: https://github.com/andreibondarev/weaviate-ruby
86
90
  licenses:
87
91
  - MIT
88
92
  metadata:
89
- homepage_uri: https://github.com/andreibondarev/weaviate
90
- source_code_uri: https://github.com/andreibondarev/weaviate
91
- changelog_uri: https://github.com/andreibondarev/weaviate/CHANGELOG.md
93
+ homepage_uri: https://github.com/andreibondarev/weaviate-ruby
94
+ source_code_uri: https://github.com/andreibondarev/weaviate-ruby
95
+ changelog_uri: https://github.com/andreibondarev/weaviate-ruby/CHANGELOG.md
92
96
  post_install_message:
93
97
  rdoc_options: []
94
98
  require_paths: