I am interacting with openAI using ruby-openAI gem, but I get timeout error, is there a way I can exceed the timeout limit?
response = @client.completions(
parameters: {
model: "text-davinci-003",
prompt: "In the style of #{@as_written_by}, write a longer article in HTML of at least 750 words using the #{article} as the primary source and basis for the new article, and include interesting facts from the #{secondary_sources}, with a tags around the source of the information pointing to the original URLs",
max_tokens: 3000
})
When you instantiate your client you can pass it the "request_timeout" attribute with the desired duration (in seconds).
@client = OpenAI::Client.new(
access_token: "access_token_goes_here",
request_timeout: 240 #Optional and can be increased/decreased as required.
)
You can also do this at a config level:
OpenAI.configure do |config|
config.access_token = ENV.fetch("OPENAI_ACCESS_TOKEN")
config.organization_id = ENV.fetch("OPENAI_ORGANIZATION_ID") # Optional
config.request_timeout = 240 # Optional
end
more info see the docs here: https://github.com/alexrudall/ruby-openai#custom-timeout-or-base-uri
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With