adamrushy / OpenAISwift

This is a wrapper library around the ChatGPT and OpenAI HTTP API
MIT License
1.62k stars 246 forks source link

The cause of 'The request timed out.' error #73

Open bluepixeltech opened 1 year ago

bluepixeltech commented 1 year ago

Hi, thanks for great library! I am wondering if there's a way to deal with 'The request timed out.' error which happens after a period of inactivity. Or is there a way to deactivate it?

elprl commented 1 year ago

+1 on this. I tried to extend the timeout on the URL session but it still happens.

        // Create a URLSessionConfiguration with a custom timeout because GPT takes a while
        let configuration = URLSessionConfiguration.default
        configuration.timeoutIntervalForRequest = 360 // Timeout in seconds
        // Create a URLSession with the custom configuration
        let customSession = URLSession(configuration: configuration)
        let sessionConfig = OpenAISwift.Config(session: customSession)
zSOLz commented 1 year ago

Unlike this solution does not work for large requests on MacOS for me :( I will be investigating this problem anyway.

jscalo commented 1 year ago

It appears to be using the default timeout of 60s, which is far too short for more complex completions.