weaviate-ruby 0.7.0 → 0.7.2

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: eec9c4e909fa4b73ed59023c291cbc0171c72fcc2aeeef2773b6744b2de6144c
4
- data.tar.gz: b66b81b77feb0b5777a15ef833eea0ebdd7f1660208c5f53893887c95aa56201
3
+ metadata.gz: f1944f940c8677b6293af834af96e6b2c3635475703bffb96a123bfc7e164a4d
4
+ data.tar.gz: c4b719e54d31ae823054bd40d1a450efd7c5d7738bca23fb8187366ee4e9e140
5
5
  SHA512:
6
- metadata.gz: 2b32d7546e9dc5484b63abe834667e03733e694b1fd6d7c10306cc09cb96ecbb8e63f84aaa682452ae881de79cf3f6f2c49dccf744761e6c95a7539e3feef068
7
- data.tar.gz: 1a3774e88f29d0de254bd06b912bbcf4b4fa33cfa2b0ac87a60c38e340503c9119fdc6556bc5d7ff77c06097519e9f9122d2ef6cc8ca1541c245091c4bef0115
6
+ metadata.gz: 4e81d9d0960153df197c746b120408f74a08da2c6336665e73756243e6ba2d84354b8ef6770998cae8d0411904a988fa0ec82f2ccba1d69ec4da6765b2da65c8
7
+ data.tar.gz: 62751834232ad87ef75aa115c55781dd9d9aec47ecddea7c9b21a035c91ebf8824dad0a506c7c8d44fa56ac8f16bb2f5295f5b7fdebf198ab5dc6c6d480392dd
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- weaviate-ruby (0.6.0)
4
+ weaviate-ruby (0.7.2)
5
5
  faraday (~> 2.7)
6
6
  graphlient (~> 0.7.0)
7
7
 
data/README.md CHANGED
@@ -3,12 +3,12 @@
3
3
  <p>
4
4
  <img alt='Weaviate logo' src='https://weaviate.io/img/site/weaviate-logo-light.png' height='50' />
5
5
  +&nbsp;&nbsp;
6
- <img alt='Weaviate logo' src='https://user-images.githubusercontent.com/541665/230231593-43861278-4550-421d-a543-fd3553aac4f6.png' height='40' />
6
+ <img alt='Ruby logo' src='https://user-images.githubusercontent.com/541665/230231593-43861278-4550-421d-a543-fd3553aac4f6.png' height='40' />
7
7
  </p>
8
8
 
9
9
  Ruby wrapper for the Weaviate.io API
10
10
 
11
- ![Tests status](https://github.com/andreibondarev/weaviate-ruby/actions/workflows/ci.yml/badge.svg)
11
+ ![Tests status](https://github.com/andreibondarev/weaviate-ruby/actions/workflows/ci.yml/badge.svg) [![Gem Version](https://badge.fury.io/rb/weaviate-ruby.svg)](https://badge.fury.io/rb/weaviate-ruby)
12
12
 
13
13
  ## Installation
14
14
 
@@ -172,10 +172,11 @@ client.objects.batch_delete(
172
172
  near_text = '{ concepts: ["biology"] }'
173
173
  sort_obj = '{ path: ["category"], order: desc }'
174
174
  where_obj = '{ path: ["id"], operator: Equal, valueString: "..." }'
175
+ with_hybrid = '{ query: "Sweets", alpha: 0.5 }'
175
176
 
176
177
  client.query.get(
177
178
  class_name: 'Question',
178
- fields: 'question answer category',
179
+ fields: "question answer category _additional { answer { result hasAnswer property startPosition endPosition } }",
179
180
  limit: "1",
180
181
  offset: "1",
181
182
  after: "id",
@@ -187,13 +188,15 @@ client.query.get(
187
188
  near_text: near_text,
188
189
 
189
190
  # To use this parameter you must have created your schema by setting the `vectorizer:` property to 'multi2vec-clip' or 'img2vec-neural'
190
- # near_image: ...,
191
+ near_image: near_image,
191
192
 
192
- # hybrid: ...,
193
+ with_hybrid: with_hybrid,
193
194
 
194
- # bm25: ...,
195
+ bm25: bm25,
195
196
 
196
- # near_object: ...,
197
+ near_object: near_object,
198
+
199
+ ask: '{ question: "your-question?" }'
197
200
  )
198
201
 
199
202
  # Example queries:
@@ -5,7 +5,8 @@ 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
8
+ attr_reader :scheme, :host, :api_key, :model_service, :model_service_api_key, :adapter,
9
+ :username, :password
9
10
 
10
11
  API_VERSION = "v1"
11
12
 
@@ -21,7 +22,9 @@ module Weaviate
21
22
  api_key: nil,
22
23
  model_service: nil,
23
24
  model_service_api_key: nil,
24
- adapter: Faraday.default_adapter
25
+ adapter: Faraday.default_adapter,
26
+ username: nil,
27
+ password: nil
25
28
  )
26
29
  validate_model_service!(model_service) unless model_service.nil?
27
30
 
@@ -31,6 +34,8 @@ module Weaviate
31
34
  @model_service = model_service
32
35
  @model_service_api_key = model_service_api_key
33
36
  @adapter = adapter
37
+ @username = username
38
+ @password = password
34
39
  end
35
40
 
36
41
  def oidc
@@ -77,12 +82,21 @@ module Weaviate
77
82
  @query ||= Weaviate::Query.new(client: self)
78
83
  end
79
84
 
85
+ def clusters
86
+ @clusters ||= Weaviate::Clusters.new(client: self)
87
+ end
88
+
80
89
  def graphql
81
90
  headers = {}
91
+
82
92
  if model_service && model_service_api_key
83
93
  headers[API_KEY_HEADERS[model_service]] = model_service_api_key
84
94
  end
85
95
 
96
+ if api_key
97
+ headers["Authorization"] = "Bearer #{api_key}"
98
+ end
99
+
86
100
  @graphql ||= Graphlient::Client.new(
87
101
  "#{scheme}://#{host}/#{API_VERSION}/graphql",
88
102
  headers: headers,
@@ -93,6 +107,21 @@ module Weaviate
93
107
  )
94
108
  end
95
109
 
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
+
96
125
  def connection
97
126
  @connection ||= Faraday.new(url: "#{scheme}://#{host}/#{API_VERSION}/") do |faraday|
98
127
  if api_key
@@ -12,7 +12,10 @@ module Weaviate
12
12
  where: nil,
13
13
  near_text: nil,
14
14
  near_vector: nil,
15
- near_object: nil
15
+ near_object: nil,
16
+ with_hybrid: nil,
17
+ bm25: nil,
18
+ ask: nil
16
19
  )
17
20
  response = client.graphql.execute(
18
21
  get_query(
@@ -22,7 +25,10 @@ module Weaviate
22
25
  where: where,
23
26
  near_text: near_text,
24
27
  near_vector: near_vector,
25
- near_object: near_object
28
+ near_object: near_object,
29
+ with_hybrid: with_hybrid,
30
+ bm25: bm25,
31
+ ask: ask
26
32
  ),
27
33
  after: after,
28
34
  limit: limit,
@@ -122,6 +128,9 @@ module Weaviate
122
128
  near_text: nil,
123
129
  near_vector: nil,
124
130
  near_object: nil,
131
+ with_hybrid: nil,
132
+ bm25: nil,
133
+ ask: nil,
125
134
  sort: nil
126
135
  )
127
136
  client.graphql.parse <<~GRAPHQL
@@ -138,6 +147,9 @@ module Weaviate
138
147
  #{near_text.present? ? "nearText: #{near_text}" : ""},
139
148
  #{near_vector.present? ? "nearVector: #{near_vector}" : ""},
140
149
  #{near_object.present? ? "nearObject: #{near_object}" : ""},
150
+ #{with_hybrid.present? ? "hybrid: #{with_hybrid}" : ""},
151
+ #{bm25.present? ? "bm25: #{bm25}" : ""},
152
+ #{ask.present? ? "ask: #{ask}" : ""},
141
153
  #{where.present? ? "where: #{where}" : ""},
142
154
  #{sort.present? ? "sort: #{sort}" : ""}
143
155
  ) {
@@ -46,8 +46,6 @@ module Weaviate
46
46
  req.body["replicationConfig"] = replication_config unless replication_config.nil?
47
47
  end
48
48
 
49
- if response.success?
50
- end
51
49
  response.body
52
50
  end
53
51
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Weaviate
4
- VERSION = "0.7.0"
4
+ VERSION = "0.7.2"
5
5
  end
data/lib/weaviate.rb CHANGED
@@ -5,6 +5,7 @@ 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"
8
9
  autoload :Error, "weaviate/error"
9
10
  autoload :Schema, "weaviate/schema"
10
11
  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.0
4
+ version: 0.7.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: 2023-04-05 00:00:00.000000000 Z
11
+ date: 2023-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday