weaviate-ruby 0.8.10 → 0.8.11

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: 78db75797066d9789e8c9da6e48aeb031f71f8d47709b87b08ce5caac3b3e04b
4
- data.tar.gz: 96f9491d8ea9970cb2b2e0a1b5935b66ff63c18629055b5b08de9a9967167387
3
+ metadata.gz: f1533db1f83e65e849863776ab0312149c0e5dcdcbb2c65ea922294ea9af6ee7
4
+ data.tar.gz: ce9ca1a00db9c4b117a8c19216c9049663f481750b7773bd69a4637f26074282
5
5
  SHA512:
6
- metadata.gz: 621fb1ba1685ac3c934e545732184b10509dc4366089cc8d6e985dbfe49144aa82894e78281c0761857999b920b549a1ccc3da863f3a85d3843e9c2cdeef0128
7
- data.tar.gz: 17b5588cddb8ada1fd1ebe0e8bd877d74ca637a9756f686418c6a751504ef3b54369ed7c0a2ee319802d72b87329108a018ed1b5041af2103f6511438fa03170
6
+ metadata.gz: 8af749e6537bdef2d2c87fdc0b0724e860368f00f37550c94a7b3e0139555c89d624fda050abda601b7c7d317ad9eccdfb01ee654586e6ce038e7048128d37cb
7
+ data.tar.gz: 4afef756ad24eba7c8fb9314219dda512e49ae2cf0dc07ce9f8cc9ec1269d4b71c7ef738b4f36de780147e9b707f384bf0cb271d7ebf57d3333c2ce9e135ac07
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- weaviate-ruby (0.8.10)
4
+ weaviate-ruby (0.8.11)
5
5
  faraday (>= 2.0.1, < 3.0)
6
6
  graphlient (~> 0.7.0)
7
7
 
data/README.md CHANGED
@@ -10,11 +10,14 @@ Ruby wrapper for the Weaviate.io API.
10
10
 
11
11
  Part of the [Langchain.rb](https://github.com/andreibondarev/langchainrb) stack.
12
12
 
13
+ Available for paid consulting engagements! [Email me](mailto:andrei@sourcelabs.io).
14
+
13
15
  ![Tests status](https://github.com/andreibondarev/weaviate-ruby/actions/workflows/ci.yml/badge.svg)
14
16
  [![Gem Version](https://badge.fury.io/rb/weaviate-ruby.svg)](https://badge.fury.io/rb/weaviate-ruby)
15
17
  [![Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/gems/weaviate-ruby)
16
18
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/andreibondarev/weaviate-ruby/blob/main/LICENSE.txt)
17
19
  [![](https://dcbadge.vercel.app/api/server/WDARp7J2n8?compact=true&style=flat)](https://discord.gg/WDARp7J2n8)
20
+ [![X](https://img.shields.io/twitter/url/https/twitter.com/cloudposse.svg?style=social&label=Follow%20%40rushing_andrei)](https://twitter.com/rushing_andrei)
18
21
 
19
22
  ## Installation
20
23
 
@@ -63,7 +66,7 @@ client.schema.create(
63
66
  "name": "category"
64
67
  }
65
68
  ],
66
- # Possible values: 'text2vec-cohere', 'text2vec-openai', 'text2vec-huggingface', 'text2vec-transformers', 'text2vec-contextionary', 'img2vec-neural', 'multi2vec-clip', 'ref2vec-centroid'
69
+ # Possible values: 'text2vec-cohere', 'text2vec-ollama', 'text2vec-openai', 'text2vec-huggingface', 'text2vec-transformers', 'text2vec-contextionary', 'img2vec-neural', 'multi2vec-clip', 'ref2vec-centroid'
67
70
  vectorizer: "text2vec-openai"
68
71
  )
69
72
 
@@ -73,9 +76,6 @@ client.schema.get(class_name: 'Question')
73
76
  # Get the schema
74
77
  client.schema.list()
75
78
 
76
- # Remove a class (and all data in the instances) from the schema.
77
- client.schema.delete(class_name: 'Question')
78
-
79
79
  # Update settings of an existing schema class.
80
80
  # Does not support modifying existing properties.
81
81
  client.schema.update(
@@ -94,6 +94,51 @@ client.schema.add_property(
94
94
 
95
95
  # Inspect the shards of a class
96
96
  client.schema.shards(class_name: 'Question')
97
+
98
+ # Remove a class (and all data in the instances) from the schema.
99
+ client.schema.delete(class_name: 'Question')
100
+
101
+ # Creating a new data object class in the schema while configuring the vectorizer on the schema and on individual properties (Ollama example)
102
+ client.schema.create(
103
+ class_name: 'Question',
104
+ description: 'Information from a Jeopardy! question',
105
+ properties: [
106
+ {
107
+ "dataType": ["text"],
108
+ "description": "The question",
109
+ "name": "question"
110
+ # By default all properties are included in the vector
111
+ }, {
112
+ "dataType": ["text"],
113
+ "description": "The answer",
114
+ "name": "answer",
115
+ "moduleConfig": {
116
+ "text2vec-ollama": {
117
+ "skip": false,
118
+ "vectorizePropertyName": true,
119
+ },
120
+ },
121
+ }, {
122
+ "dataType": ["text"],
123
+ "description": "The category",
124
+ "name": "category",
125
+ "indexFilterable": true,
126
+ "indexSearchable": false,
127
+ "moduleConfig": {
128
+ "text2vec-ollama": {
129
+ "skip": true, # Don't include in the vector
130
+ },
131
+ },
132
+ }
133
+ ],
134
+ vectorizer: "text2vec-ollama",
135
+ module_config: {
136
+ "text2vec-ollama": {
137
+ apiEndpoint: "http://localhost:11434",
138
+ model: "mxbai-embed-large",
139
+ },
140
+ },
141
+ )
97
142
  ```
98
143
 
99
144
  ### Using the Objects endpoint
@@ -296,6 +341,30 @@ client.live?
296
341
  client.ready?
297
342
  ```
298
343
 
344
+ ### Tenants
345
+
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
356
+
357
+ ```ruby
358
+ client.schema.create(
359
+ # Other keys...
360
+ mutli_tenant: { enabled: true, autoTenantCreation: true, autoTenantActivation: true },
361
+ )
362
+ ```
363
+
364
+ See [Weaviate Multi-tenancy operations](https://weaviate.io/developers/weaviate/manage-data/multi-tenancy). Note that the mix of snake case(used by Ruby) and lower camel case(used by Weaviate) is intentional as that hash is passed directly to Weaviate.
365
+
366
+ All data methods in this library support an optional `tenant` argument which must be passed if multi-tenancy is enabled on the related collection
367
+
299
368
  ## Development
300
369
 
301
370
  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.
@@ -10,6 +10,7 @@ module Weaviate
10
10
  API_VERSION = "v1"
11
11
 
12
12
  API_KEY_HEADERS = {
13
+ ollama: "X-Ollama-Not-Used",
13
14
  openai: "X-OpenAI-Api-Key",
14
15
  azure_openai: "X-Azure-Api-Key",
15
16
  cohere: "X-Cohere-Api-Key",
@@ -162,14 +162,13 @@ module Weaviate
162
162
  where:,
163
163
  consistency_level: nil,
164
164
  output: nil,
165
- dry_run: nil
165
+ dry_run: nil,
166
+ tenant: nil
166
167
  )
167
168
  path = "batch/#{PATH}"
168
169
 
169
170
  unless consistency_level.nil?
170
171
  validate_consistency_level!(consistency_level)
171
-
172
- path << "?consistency_level=#{consistency_level.to_s.upcase}"
173
172
  end
174
173
 
175
174
  response = client.connection.delete(path) do |req|
@@ -181,6 +180,8 @@ module Weaviate
181
180
  }
182
181
  req.body["output"] = output unless output.nil?
183
182
  req.body["dryRun"] = dry_run unless dry_run.nil?
183
+ req.params["consistency_level"] = consistency_level.to_s.upcase unless consistency_level.nil?
184
+ req.params["tenant"] = tenant unless tenant.nil?
184
185
  end
185
186
 
186
187
  response.body
@@ -48,6 +48,7 @@ module Weaviate
48
48
  def aggs(
49
49
  class_name:,
50
50
  fields: nil,
51
+ tenant: nil,
51
52
  where: nil,
52
53
  object_limit: nil,
53
54
  near_text: nil,
@@ -59,6 +60,7 @@ module Weaviate
59
60
  response = client.graphql.execute(
60
61
  aggs_query(
61
62
  class_name: class_name,
63
+ tenant: tenant,
62
64
  fields: fields,
63
65
  where: where,
64
66
  near_text: near_text,
@@ -185,6 +187,7 @@ module Weaviate
185
187
  def aggs_query(
186
188
  class_name:,
187
189
  fields:,
190
+ tenant: nil,
188
191
  where: nil,
189
192
  near_text: nil,
190
193
  near_vector: nil,
@@ -200,6 +203,7 @@ module Weaviate
200
203
  #{class_name}(
201
204
  objectLimit: $object_limit,
202
205
  groupBy: $group_by,
206
+ #{(!tenant.nil?) ? "tenant: \"#{tenant}\"" : ""},
203
207
  #{(!near_text.nil?) ? "nearText: #{near_text}" : ""},
204
208
  #{(!near_vector.nil?) ? "nearVector: #{near_vector}" : ""},
205
209
  #{(!near_image.nil?) ? "nearImage: #{near_image}" : ""},
@@ -43,7 +43,11 @@ module Weaviate
43
43
  req.body["vectorizer"] = vectorizer unless vectorizer.nil?
44
44
  req.body["moduleConfig"] = module_config unless module_config.nil?
45
45
  req.body["properties"] = properties unless properties.nil?
46
- req.body["multiTenancyConfig"] = {enabled: true} unless multi_tenant.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}
50
+ end
47
51
  req.body["invertedIndexConfig"] = inverted_index_config unless inverted_index_config.nil?
48
52
  req.body["replicationConfig"] = replication_config unless replication_config.nil?
49
53
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Weaviate
4
- VERSION = "0.8.10"
4
+ VERSION = "0.8.11"
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.10
4
+ version: 0.8.11
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-01-25 00:00:00.000000000 Z
11
+ date: 2024-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday