3

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
  })
vimuth
  • 5,064
  • 33
  • 79
  • 116

1 Answers1

1

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