Skip to content

Commit

Permalink
Merge pull request #62 from patterns-ai-core/0.9.2
Browse files Browse the repository at this point in the history
Weaviate::Client constructor accepts customer logger: to be passed in…
  • Loading branch information
andreibondarev authored Oct 1, 2024
2 parents 1cc409c + 58ce8dc commit bef476a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## [Unreleased]

## [0.9.2] - 2024-10-01
- Weaviate::Client constructor accepts customer logger: to be passed in

## [0.9.1] - 2024-09-19

## [0.9.0] - 2024-07-08
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
weaviate-ruby (0.9.1)
weaviate-ruby (0.9.2)
faraday (>= 2.0.1, < 3.0)
graphlient (>= 0.7.0, < 0.9.0)

Expand Down
7 changes: 5 additions & 2 deletions lib/weaviate/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

module Weaviate
class Client
attr_reader :url, :api_key, :model_service, :model_service_api_key, :adapter
attr_reader :url, :api_key, :model_service, :model_service_api_key, :adapter, :logger

API_VERSION = "v1"

Expand All @@ -23,7 +23,8 @@ def initialize(
api_key: nil,
model_service: nil,
model_service_api_key: nil,
adapter: Faraday.default_adapter
adapter: Faraday.default_adapter,
logger: nil
)
validate_model_service!(model_service) unless model_service.nil?

Expand All @@ -32,6 +33,7 @@ def initialize(
@model_service = model_service
@model_service_api_key = model_service_api_key
@adapter = adapter
@logger = logger || Logger.new($stdout)
end

def oidc
Expand Down Expand Up @@ -105,6 +107,7 @@ def connection
faraday.request :authorization, :Bearer, api_key
end
faraday.request :json
faraday.response :logger, logger, {headers: true, bodies: true, errors: true}
faraday.response :json, content_type: /\bjson$/
faraday.response :raise_error
faraday.adapter adapter
Expand Down
2 changes: 1 addition & 1 deletion lib/weaviate/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Weaviate
VERSION = "0.9.1"
VERSION = "0.9.2"
end
12 changes: 11 additions & 1 deletion spec/weaviate/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

RSpec.describe Weaviate::Client do
let(:client) {
Weaviate::Client.new(
described_class.new(
url: "http://localhost:8080",
model_service: :openai,
model_service_api_key: "123"
Expand All @@ -15,6 +15,16 @@
it "creates a client" do
expect(client).to be_a(Weaviate::Client)
end

it "accepts a custom logger" do
logger = Logger.new($stdout)
client = described_class.new(
url: "localhost:8080",
api_key: "123",
logger: logger
)
expect(client.logger).to eq(logger)
end
end

describe "#schema" do
Expand Down

0 comments on commit bef476a

Please sign in to comment.