Skip to content

Commit c3d69e4

Browse files
committed
Add support request timeout
1 parent f6ddad2 commit c3d69e4

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

bin/console

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

1414
client = Cohere::Client.new(
15-
api_key: ENV['COHERE_API_KEY']
15+
ENV['COHERE_API_KEY']
1616
)
1717

1818
require "irb"

lib/cohere/client.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ class Client
88

99
ENDPOINT_URL = "https://api.cohere.ai/v1"
1010

11-
def initialize(api_key)
11+
def initialize(api_key, timeout: nil)
1212
@api_key = api_key
13+
@timeout = timeout
1314
end
1415

1516
def chat(
@@ -181,7 +182,7 @@ def summarize(
181182

182183
# standard:disable Lint/DuplicateMethods
183184
def connection
184-
@connection ||= Faraday.new(url: ENDPOINT_URL) do |faraday|
185+
@connection ||= Faraday.new(url: ENDPOINT_URL, request: { timeout: @timeout }) do |faraday|
185186
if api_key
186187
faraday.request :authorization, :Bearer, api_key
187188
end

0 commit comments

Comments
 (0)