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

Add Timeout Param #39

Closed
Justintime50 opened this issue Jan 28, 2023 · 4 comments
Closed

Add Timeout Param #39

Justintime50 opened this issue Jan 28, 2023 · 4 comments

Comments

@Justintime50
Copy link

The official Python library allows a timeout to be set on requests. It would be really helpful for production applications to be able to set up a timeout on requests so we don't keep our web workers hanging if there is hiccups in connections or issues on the OpenAI side.

@nunomaduro
Copy link
Contributor

Can you make a pull request adding that feature?

@Justintime50
Copy link
Author

Hmmm, it doesn't even look like the PSR7 lib that is used here to make HTTP calls supports timeouts at all if I'm looking through their code correctly? Would potentially require a wrapper around the requests to handle this since it's not supported native.

@c0nst4ntin
Copy link

Might it be possible to use one of these options?

Afterall a Guzzle Client is being used by the OpenAI Class

@gehrisandro
Copy link
Collaborator

This can now be achieved by using the newly introduced factory:

$client = OpenAI::factory()
    ->withHttpClient(new \GuzzleHttp\Client(['timeout'  => 2.0]))
    ->make();

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

4 participants