mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
feat: Expose Gemini RetryOptions to client
google.genai SDK has introduced a new retry_options. This change exposes this configuration
to ADK users
Usage:
```python
root_agent = Agent(
model=Gemini(
model='gemini-2.0-flash',
retry_options=types.HttpRetryOptions(
initial_delay=1,
attempts=2
# ... Retry options from google.genai
),
# ...
),
```
PiperOrigin-RevId: 786472564
This commit is contained in:
committed by
Copybara-Service
parent
20537e8bfa
commit
16392984c5
@@ -22,6 +22,7 @@ import os
|
||||
import sys
|
||||
from typing import AsyncGenerator
|
||||
from typing import cast
|
||||
from typing import Optional
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import Union
|
||||
|
||||
@@ -57,6 +58,23 @@ class Gemini(BaseLlm):
|
||||
|
||||
model: str = 'gemini-1.5-flash'
|
||||
|
||||
retry_options: Optional[types.HttpRetryOptions] = None
|
||||
"""Allow Gemini to retry failed responses.
|
||||
|
||||
Sample:
|
||||
```python
|
||||
from google.genai import types
|
||||
|
||||
# ...
|
||||
|
||||
agent = Agent(
|
||||
model=Gemini(
|
||||
retry_options=types.HttpRetryOptions(initial_delay=1, attempts=2),
|
||||
)
|
||||
)
|
||||
```
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
@override
|
||||
def supported_models() -> list[str]:
|
||||
@@ -191,7 +209,10 @@ class Gemini(BaseLlm):
|
||||
The api client.
|
||||
"""
|
||||
return Client(
|
||||
http_options=types.HttpOptions(headers=self._tracking_headers)
|
||||
http_options=types.HttpOptions(
|
||||
headers=self._tracking_headers,
|
||||
retry_options=self.retry_options,
|
||||
)
|
||||
)
|
||||
|
||||
@cached_property
|
||||
|
||||
Reference in New Issue
Block a user