Skip to content

Allow specification of timeout variable for GenerativeModel.generate_content and GenerativeModel.generate_content_async #182

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

Closed
spencermyoung513 opened this issue Jan 29, 2024 · 1 comment · Fixed by #204
Labels
component:python sdk Issue/PR related to Python SDK type:feature request New feature request/enhancement

Comments

@spencermyoung513
Copy link

spencermyoung513 commented Jan 29, 2024

Description of the feature request:

Currently, when making a request to the Gemini Pro Vision API via GenerativeModel.generate_content or GenerativeModel.generate_content_async, there is no easy way to change the default timeout value on the request. It would be great to have this as a parameter (perhaps just as a non-documented kwarg) in the generate_content and other sibling methods.

What problem are you trying to solve with this feature?

Sometimes, API requests with multiple images or lots of tokens take longer than 60 seconds to get a response. But with a hard-enforced timeout setting of 60 seconds, these requests fail no matter what.

Any other information you'd like to share?

For the GenerativeServiceAsyncClient, at least, timeout is a parameter of many methods like generate_content. It is not a parameter of the GenerativeModel.generate_content method (or any of its siblings), however.

This could be amended currently by creating a custom client class that inherits from, say, GenerativeServiceAsyncClient and overriding the internal _client or _async_client attributes of a GenerativeModel. Such a workaround is far from elegant though, and creates a lot of pain on the developer side.

@spencermyoung513 spencermyoung513 added component:python sdk Issue/PR related to Python SDK type:feature request New feature request/enhancement labels Jan 29, 2024
@ymodak ymodak added the status:triaged Issue/PR triaged to the corresponding sub-team label Jan 30, 2024
@jun0wanan
Copy link

Description of the feature request:

Currently, when making a request to the Gemini Pro Vision API via GenerativeModel.generate_content or GenerativeModel.generate_content_async, there is no easy way to change the default timeout value on the request. It would be great to have this as a parameter (perhaps just as a non-documented kwarg) in the generate_content and other sibling methods.

What problem are you trying to solve with this feature?

Sometimes, API requests with multiple images or lots of tokens take longer than 60 seconds to get a response. But with a hard-enforced timeout setting of 60 seconds, these requests fail no matter what.

Any other information you'd like to share?

For the GenerativeServiceAsyncClient, at least, timeout is a parameter of many methods like generate_content. It is not a parameter of the GenerativeModel.generate_content method (or any of its siblings), however.

This could be amended currently by creating a custom client class that inherits from, say, GenerativeServiceAsyncClient and overriding the internal _client or _async_client attributes of a GenerativeModel. Such a workaround is far from elegant though, and creates a lot of pain on the developer side.

Now, How can we use it ?

response = model.generate_content(contents=[],generation_config=dict(
candidate_count=1,
max_output_tokens=4096,
temperature=0,
)
)

@github-actions github-actions bot removed the status:triaged Issue/PR triaged to the corresponding sub-team label Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:python sdk Issue/PR related to Python SDK type:feature request New feature request/enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants