Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

context deadline exceeded (Client.Timeout or context cancellation while reading body) #24

Open
qimo2020 opened this issue Feb 18, 2023 · 3 comments

Comments

@qimo2020
Copy link

hello
The code reported an error:
“context deadline exceeded (Client.Timeout or context cancellation while reading body)”

@qimo2020
Copy link
Author

hello

Still return “context deadline exceeded (Client.Timeout or context cancellation while reading body)”
codes:
httpClient := &http.Client{ Timeout: time.Duration(600 * time.Second), } client := gpt3.NewClient(apiKey, gpt3.WithHTTPClient(httpClient))
I used streaming call(client.CompletionStreamWithEngine), but the problem was not solved

@letschers
Copy link
Contributor

Recently I started having this problem too, even if on curl request the request is working properly (ie is not an outage from openAI). Do you guys have any clue?

@letschers
Copy link
Contributor

letschers commented May 16, 2023

@qimo2020 to fix this you just need to set a timeout to their client when instantiating it, like in the example below:

client := gpt3.NewClient(apiKey, gpt3.WithTimeout(time.Second*300))

If you dont set a custom timeout, will be used their standard timeout time which is 30 seconds (you can read the snippet here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants