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 client timeout setting to overcome timeout errors. #335

Closed
homer6 opened this issue May 12, 2024 · 4 comments · Fixed by #341
Closed

Add client timeout setting to overcome timeout errors. #335

homer6 opened this issue May 12, 2024 · 4 comments · Fixed by #341
Assignees
Labels
component:python sdk Issue/PR related to Python SDK type:feature request New feature request/enhancement

Comments

@homer6
Copy link

homer6 commented May 12, 2024

Description of the feature request:

Add client timeout setting to overcome timeout errors.

What problem are you trying to solve with this feature?

I'm encountering this error where I can't configure the client's timeout.

Any other information you'd like to share?

  File "/app/ai.py", line 97, in predict
    response = chat.send_message(
  File "/opt/venv/lib/python3.10/site-packages/google/generativeai/generative_models.py", line 474, in send_message
    response = self.model.generate_content(
  File "/opt/venv/lib/python3.10/site-packages/google/generativeai/generative_models.py", line 262, in generate_content
    response = self._client.generate_content(
  File "/opt/venv/lib/python3.10/site-packages/google/ai/generativelanguage_v1beta/services/generative_service/client.py", line 791, in generate_content
    response = rpc(
  File "/opt/venv/lib/python3.10/site-packages/google/api_core/gapic_v1/method.py", line 131, in __call__
    return wrapped_func(*args, **kwargs)
  File "/opt/venv/lib/python3.10/site-packages/google/api_core/retry/retry_unary.py", line 293, in retry_wrapped_func
    return retry_target(
  File "/opt/venv/lib/python3.10/site-packages/google/api_core/retry/retry_unary.py", line 153, in retry_target
    _retry_error_helper(
  File "/opt/venv/lib/python3.10/site-packages/google/api_core/retry/retry_base.py", line 212, in _retry_error_helper
    raise final_exc from source_exc
  File "/opt/venv/lib/python3.10/site-packages/google/api_core/retry/retry_unary.py", line 144, in retry_target
    result = target()
  File "/opt/venv/lib/python3.10/site-packages/google/api_core/timeout.py", line 120, in func_with_timeout
    return func(*args, **kwargs)
  File "/opt/venv/lib/python3.10/site-packages/google/api_core/grpc_helpers.py", line 78, in error_remapped_callable
    raise exceptions.from_grpc_error(exc) from exc

Exception Type: DeadlineExceeded 
Exception Value: 504 Deadline Exceeded
@homer6 homer6 added component:python sdk Issue/PR related to Python SDK type:feature request New feature request/enhancement labels May 12, 2024
@singhniraj08 singhniraj08 added the status:triaged Issue/PR triaged to the corresponding sub-team label May 14, 2024
@MarkDaoust
Copy link
Collaborator

response = chat.send_message(

The SDK supports this, but that was never wired into chat

#204
#290

That should be an easy fix.

#341

@github-actions github-actions bot removed the status:triaged Issue/PR triaged to the corresponding sub-team label May 22, 2024
@homer6
Copy link
Author

homer6 commented May 24, 2024

Thank you @markmcd !

@homer6
Copy link
Author

homer6 commented May 24, 2024

Oh, it looks like helper_types is not included in the types file:

cannot import name 'helper_types' from 'google.generativeai.types' (/opt/venv/lib/python3.10/site-packages/google/generativeai/types/__init__.py)

@markmcd

@homer6
Copy link
Author

homer6 commented May 24, 2024

It exists in the main branch, but not the v0.5.4 tag.

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