Skip to content

Commit cd9743a

Browse files
committed
Rubocop
1 parent ba4de29 commit cd9743a

File tree

5 files changed

+20
-24
lines changed

5 files changed

+20
-24
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ You can pass [Faraday middleware](https://lostisland.github.io/faraday/#/middlew
114114

115115
```ruby
116116
client = OpenAI::Client.new do |f|
117-
f.response :logger, ::Logger.new(STDOUT), bodies: true
117+
f.response :logger, Logger.new($stdout), bodies: true
118118
end
119119
```
120120

lib/openai/client.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ class Client
1111
request_timeout
1212
extra_headers
1313
].freeze
14-
attr_reader *CONFIG_KEYS
15-
attr_reader :faraday_middleware
14+
attr_reader *CONFIG_KEYS, :faraday_middleware
1615

1716
def initialize(config = {}, &faraday_middleware)
1817
CONFIG_KEYS.each do |key|

lib/openai/http.rb

+1-3
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ def conn(multipart: false)
7878
f.response :json
7979
end
8080

81-
if @faraday_middleware
82-
@faraday_middleware.call(connection)
83-
end
81+
@faraday_middleware&.call(connection)
8482

8583
connection
8684
end

spec/openai/client/chat_spec.rb

+16-17
Original file line numberDiff line numberDiff line change
@@ -31,38 +31,37 @@
3131
let(:messages) do
3232
[
3333
{
34-
"role"=>"function",
34+
"role" => "function",
3535
# "name" => "function",
36-
"content"=>"function"
36+
"content" => "function"
3737
}
3838
]
3939
end
4040
let(:functions) do
4141
[
4242
{
43-
"name"=>"function",
44-
"description"=>"function",
45-
"parameters"=>
43+
"name" => "function",
44+
"description" => "function",
45+
"parameters" =>
4646
{
47-
"type"=>"object",
48-
"properties"=>{
49-
"user"=>{
50-
"type"=>"string",
51-
"description"=>"the full name of the user"
47+
"type" => "object",
48+
"properties" => {
49+
"user" => {
50+
"type" => "string",
51+
"description" => "the full name of the user"
5252
}
53-
},
53+
}
5454
}
55-
},
55+
}
5656
]
5757
end
5858

5959
it "raises an error containing the reason" do
6060
VCR.use_cassette(cassette) do
61-
begin
62-
response
63-
rescue Faraday::Error => e
64-
expect(e.response.dig(:body, "error", "message")).to eq("Missing parameter 'name': messages with role 'function' must have a 'name'.")
65-
end
61+
response
62+
rescue Faraday::Error => e
63+
expect(e.response.dig(:body, "error",
64+
"message")).to include("Missing parameter 'name'")
6665
end
6766
end
6867
end

spec/openai/client/client_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
context "with a block" do
124124
let(:client) do
125125
OpenAI::Client.new do |client|
126-
client.response :logger, ::Logger.new(STDOUT), bodies: true
126+
client.response :logger, Logger.new($stdout), bodies: true
127127
end
128128
end
129129

0 commit comments

Comments
 (0)