Skip to content

Commit 94aeba1

Browse files
Initializing the weaviate client requires the single url: key instead of separate host: and schema:
1 parent 7e450bd commit 94aeba1

File tree

14 files changed

+22
-29
lines changed

14 files changed

+22
-29
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## [Unreleased]
22

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+
38
## [0.1.0] - 2023-03-24
49

510
- Initial release

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
weaviate-ruby (0.7.3)
4+
weaviate-ruby (0.8.0)
55
faraday (~> 2.7)
66
graphlient (~> 0.7.0)
77

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
2828
require 'weaviate'
2929

3030
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
3332
api_key: '', # Weaviate API key
3433
model_service: :openai, # Service that will be used to generate vectors. Possible values: :openai, :cohere, :huggingface
3534
model_service_api_key: 'xxxxxxx' # Either OpenAI, Cohere or Hugging Face API key

bin/console

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ require "weaviate"
1212
# Pry.start
1313

1414
client = Weaviate::Client.new(
15-
scheme: "http",
16-
host: ENV["WEAVIATE_HOST"],
15+
url: ENV["WEAVIATE_URL"],
1716
api_key: ENV["WEAVIATE_API_KEY"],
1817
model_service: :openai,
1918
model_service_api_key: ENV["MODEL_SERVICE_API_KEY"]

lib/weaviate/client.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
module Weaviate
77
class Client
8-
attr_reader :scheme, :host, :api_key, :model_service, :model_service_api_key, :adapter
8+
attr_reader :url, :api_key, :model_service, :model_service_api_key, :adapter
99

1010
API_VERSION = "v1"
1111

@@ -16,17 +16,15 @@ class Client
1616
}
1717

1818
def initialize(
19-
scheme:,
20-
host:,
19+
url:,
2120
api_key: nil,
2221
model_service: nil,
2322
model_service_api_key: nil,
2423
adapter: Faraday.default_adapter
2524
)
2625
validate_model_service!(model_service) unless model_service.nil?
2726

28-
@scheme = scheme
29-
@host = host
27+
@url = url
3028
@api_key = api_key
3129
@model_service = model_service
3230
@model_service_api_key = model_service_api_key
@@ -89,7 +87,7 @@ def graphql
8987
end
9088

9189
@graphql ||= Graphlient::Client.new(
92-
"#{scheme}://#{host}/#{API_VERSION}/graphql",
90+
"#{url}/#{API_VERSION}/graphql",
9391
headers: headers,
9492
http_options: {
9593
read_timeout: 20,
@@ -99,7 +97,7 @@ def graphql
9997
end
10098

10199
def connection
102-
@connection ||= Faraday.new(url: "#{scheme}://#{host}/#{API_VERSION}/") do |faraday|
100+
@connection ||= Faraday.new(url: "#{url}/#{API_VERSION}/") do |faraday|
103101
if api_key
104102
faraday.request :authorization, :Bearer, api_key
105103
end

lib/weaviate/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module Weaviate
4-
VERSION = "0.7.3"
4+
VERSION = "0.8.0"
55
end

spec/weaviate/backups_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
RSpec.describe Weaviate::Backups do
66
let(:client) {
77
Weaviate::Client.new(
8-
scheme: "http",
9-
host: "localhost:8080"
8+
url: "http://localhost:8080"
109
)
1110
}
1211

spec/weaviate/classifications_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
RSpec.describe Weaviate::Classifications do
66
let(:client) {
77
Weaviate::Client.new(
8-
scheme: "http",
9-
host: "localhost:8080"
8+
url: "http://localhost:8080"
109
)
1110
}
1211

spec/weaviate/client_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
RSpec.describe Weaviate::Client do
66
let(:client) {
77
Weaviate::Client.new(
8-
scheme: "http",
9-
host: "localhost:8080",
8+
url: "http://localhost:8080",
109
model_service: :openai,
1110
model_service_api_key: "123"
1211
)

spec/weaviate/health_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
RSpec.describe Weaviate::Health do
66
let(:client) {
77
Weaviate::Client.new(
8-
scheme: "http",
9-
host: "localhost:8080"
8+
url: "http://localhost:8080"
109
)
1110
}
1211

0 commit comments

Comments
 (0)