weaviate-ruby 0.7.2 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1944f940c8677b6293af834af96e6b2c3635475703bffb96a123bfc7e164a4d
4
- data.tar.gz: c4b719e54d31ae823054bd40d1a450efd7c5d7738bca23fb8187366ee4e9e140
3
+ metadata.gz: e3fbf2a33be8c215b77162ae797f54be34962fa8f26b9c47880b6e80028997da
4
+ data.tar.gz: 6e3cd21e2c087e180afa031366d4284b9c5a65cd98a4162e6cbf23049164fb0a
5
5
  SHA512:
6
- metadata.gz: 4e81d9d0960153df197c746b120408f74a08da2c6336665e73756243e6ba2d84354b8ef6770998cae8d0411904a988fa0ec82f2ccba1d69ec4da6765b2da65c8
7
- data.tar.gz: 62751834232ad87ef75aa115c55781dd9d9aec47ecddea7c9b21a035c91ebf8824dad0a506c7c8d44fa56ac8f16bb2f5295f5b7fdebf198ab5dc6c6d480392dd
6
+ metadata.gz: 182607f0a3efbdfbd473289c005218ef2987100f2eac33b22c1d01cdc38a39183ce589943232e61a504b17831722875546c56780caa96b33086adb1d031edf86
7
+ data.tar.gz: 9b3b1b947bc19268e11f53a3df2988bec3c3f124a3c8144b1ecb5b69c5220f2eb3c2158cde198fbeab43f3f73ff2f5f19feb9241b12c43d55d77980ec8bd84b2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.8.0] - 2023-04-18
4
+
5
+ ### Breaking
6
+ - Initializing the weaviate client requires the single `url:` key instead of separate `host:` and `schema:`
7
+
3
8
  ## [0.1.0] - 2023-03-24
4
9
 
5
10
  - Initial release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- weaviate-ruby (0.7.2)
4
+ weaviate-ruby (0.8.0)
5
5
  faraday (~> 2.7)
6
6
  graphlient (~> 0.7.0)
7
7
 
data/README.md CHANGED
@@ -28,8 +28,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
28
28
  require 'weaviate'
29
29
 
30
30
  client = Weaviate::Client.new(
31
- scheme: 'https',
32
- host: 'some-endpoint.weaviate.network', # Replace with your endpoint
31
+ url: 'https://some-endpoint.weaviate.network', # Replace with your endpoint
33
32
  api_key: '', # Weaviate API key
34
33
  model_service: :openai, # Service that will be used to generate vectors. Possible values: :openai, :cohere, :huggingface
35
34
  model_service_api_key: 'xxxxxxx' # Either OpenAI, Cohere or Hugging Face API key
@@ -181,7 +180,7 @@ client.query.get(
181
180
  offset: "1",
182
181
  after: "id",
183
182
  sort: sort_obj,
184
- where_obj: where_obj,
183
+ where: where_obj,
185
184
 
186
185
  # To use this parameter you must have created your schema by setting the `vectorizer:` property to
187
186
  # either 'text2vec-transformers', 'text2vec-contextionary', 'text2vec-openai', 'multi2vec-clip', 'text2vec-huggingface' or 'text2vec-cohere'
@@ -5,8 +5,7 @@ require "graphlient"
5
5
 
6
6
  module Weaviate
7
7
  class Client
8
- attr_reader :scheme, :host, :api_key, :model_service, :model_service_api_key, :adapter,
9
- :username, :password
8
+ attr_reader :url, :api_key, :model_service, :model_service_api_key, :adapter
10
9
 
11
10
  API_VERSION = "v1"
12
11
 
@@ -17,25 +16,19 @@ module Weaviate
17
16
  }
18
17
 
19
18
  def initialize(
20
- scheme:,
21
- host:,
19
+ url:,
22
20
  api_key: nil,
23
21
  model_service: nil,
24
22
  model_service_api_key: nil,
25
- adapter: Faraday.default_adapter,
26
- username: nil,
27
- password: nil
23
+ adapter: Faraday.default_adapter
28
24
  )
29
25
  validate_model_service!(model_service) unless model_service.nil?
30
26
 
31
- @scheme = scheme
32
- @host = host
27
+ @url = url
33
28
  @api_key = api_key
34
29
  @model_service = model_service
35
30
  @model_service_api_key = model_service_api_key
36
31
  @adapter = adapter
37
- @username = username
38
- @password = password
39
32
  end
40
33
 
41
34
  def oidc
@@ -82,10 +75,6 @@ module Weaviate
82
75
  @query ||= Weaviate::Query.new(client: self)
83
76
  end
84
77
 
85
- def clusters
86
- @clusters ||= Weaviate::Clusters.new(client: self)
87
- end
88
-
89
78
  def graphql
90
79
  headers = {}
91
80
 
@@ -98,7 +87,7 @@ module Weaviate
98
87
  end
99
88
 
100
89
  @graphql ||= Graphlient::Client.new(
101
- "#{scheme}://#{host}/#{API_VERSION}/graphql",
90
+ "#{url}/#{API_VERSION}/graphql",
102
91
  headers: headers,
103
92
  http_options: {
104
93
  read_timeout: 20,
@@ -107,23 +96,8 @@ module Weaviate
107
96
  )
108
97
  end
109
98
 
110
- def wsc
111
- @wsc ||= Faraday.new(url: "https://wcs.api.semi.technology/v1") do |faraday|
112
- # if api_key
113
- # faraday.request :authorization, :Bearer, api_key
114
- if password && username
115
- # faraday.request :authorization, :Basic, Base64.encode64("#{username}:#{password}")
116
- end
117
-
118
-
119
- faraday.request :json
120
- faraday.response :json, content_type: /\bjson$/
121
- faraday.adapter adapter
122
- end
123
- end
124
-
125
99
  def connection
126
- @connection ||= Faraday.new(url: "#{scheme}://#{host}/#{API_VERSION}/") do |faraday|
100
+ @connection ||= Faraday.new(url: "#{url}/#{API_VERSION}/") do |faraday|
127
101
  if api_key
128
102
  faraday.request :authorization, :Bearer, api_key
129
103
  end
@@ -12,6 +12,7 @@ module Weaviate
12
12
  where: nil,
13
13
  near_text: nil,
14
14
  near_vector: nil,
15
+ near_image: nil,
15
16
  near_object: nil,
16
17
  with_hybrid: nil,
17
18
  bm25: nil,
@@ -25,6 +26,7 @@ module Weaviate
25
26
  where: where,
26
27
  near_text: near_text,
27
28
  near_vector: near_vector,
29
+ near_image: near_image,
28
30
  near_object: near_object,
29
31
  with_hybrid: with_hybrid,
30
32
  bm25: bm25,
@@ -45,6 +47,7 @@ module Weaviate
45
47
  object_limit: nil,
46
48
  near_text: nil,
47
49
  near_vector: nil,
50
+ near_image: nil,
48
51
  near_object: nil,
49
52
  group_by: nil
50
53
  )
@@ -54,6 +57,7 @@ module Weaviate
54
57
  fields: fields,
55
58
  near_text: near_text,
56
59
  near_vector: near_vector,
60
+ near_image: near_image,
57
61
  near_object: near_object
58
62
  ),
59
63
  group_by: group_by,
@@ -73,6 +77,7 @@ module Weaviate
73
77
  where: nil,
74
78
  near_text: nil,
75
79
  near_vector: nil,
80
+ near_image: nil,
76
81
  near_object: nil
77
82
  )
78
83
  response = client.graphql.execute(
@@ -80,6 +85,7 @@ module Weaviate
80
85
  fields: fields,
81
86
  near_text: near_text,
82
87
  near_vector: near_vector,
88
+ near_image: near_image,
83
89
  near_object: near_object
84
90
  ),
85
91
  after: after,
@@ -98,6 +104,7 @@ module Weaviate
98
104
  where: nil,
99
105
  near_text: nil,
100
106
  near_vector: nil,
107
+ near_image: nil,
101
108
  near_object: nil,
102
109
  sort: nil
103
110
  )
@@ -111,6 +118,7 @@ module Weaviate
111
118
  offset: $offset,
112
119
  #{near_text.present? ? "nearText: #{near_text}" : ""},
113
120
  #{near_vector.present? ? "nearVector: #{near_vector}" : ""},
121
+ #{near_image.present? ? "nearImage: #{near_image}" : ""},
114
122
  #{near_object.present? ? "nearObject: #{near_object}" : ""}
115
123
  #{where.present? ? "where: #{where}" : ""},
116
124
  #{sort.present? ? "sort: #{sort}" : ""}
@@ -127,6 +135,7 @@ module Weaviate
127
135
  where: nil,
128
136
  near_text: nil,
129
137
  near_vector: nil,
138
+ near_image: nil,
130
139
  near_object: nil,
131
140
  with_hybrid: nil,
132
141
  bm25: nil,
@@ -146,6 +155,7 @@ module Weaviate
146
155
  offset: $offset,
147
156
  #{near_text.present? ? "nearText: #{near_text}" : ""},
148
157
  #{near_vector.present? ? "nearVector: #{near_vector}" : ""},
158
+ #{near_image.present? ? "nearImage: #{near_image}" : ""},
149
159
  #{near_object.present? ? "nearObject: #{near_object}" : ""},
150
160
  #{with_hybrid.present? ? "hybrid: #{with_hybrid}" : ""},
151
161
  #{bm25.present? ? "bm25: #{bm25}" : ""},
@@ -165,6 +175,7 @@ module Weaviate
165
175
  fields:,
166
176
  near_text: nil,
167
177
  near_vector: nil,
178
+ near_image: nil,
168
179
  near_object: nil
169
180
  )
170
181
  client.graphql.parse <<~GRAPHQL
@@ -178,6 +189,7 @@ module Weaviate
178
189
  groupBy: $group_by,
179
190
  #{near_text.present? ? "nearText: #{near_text}" : ""},
180
191
  #{near_vector.present? ? "nearVector: #{near_vector}" : ""},
192
+ #{near_image.present? ? "nearImage: #{near_image}" : ""},
181
193
  #{near_object.present? ? "nearObject: #{near_object}" : ""}
182
194
  ) {
183
195
  #{fields}
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Weaviate
4
- VERSION = "0.7.2"
4
+ VERSION = "0.8.0"
5
5
  end
data/lib/weaviate.rb CHANGED
@@ -5,7 +5,6 @@ require_relative "weaviate/version"
5
5
  module Weaviate
6
6
  autoload :Base, "weaviate/base"
7
7
  autoload :Client, "weaviate/client"
8
- autoload :Clusters, "weaviate/clusters"
9
8
  autoload :Error, "weaviate/error"
10
9
  autoload :Schema, "weaviate/schema"
11
10
  autoload :Meta, "weaviate/meta"
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.7.2
4
+ version: 0.8.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-13 00:00:00.000000000 Z
11
+ date: 2023-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday