Make _live_api_client a public, documented override point (like api_client)
- Lenguaje dominante
- Python
- Estrellas
- 21.5k
- Forks
- 4k
- Merge medio
- 1 d 14 h
- PR fusionados (30 d)
- 37
Descripción
## 🔴 Required Information
### Is your feature request related to a specific problem?
The `Gemini` class has a private `_live_api_client` property (leading underscore) that subclasses must override to customize the `genai.Client` used for Live API connections. This is contradictory — Python convention treats `_`-prefixed names as implementation details not intended for external override, yet Live API customization requires it.
The existing docstring documents how to override `api_client` for non-Live usage, but there's no public equivalent for Live API.
### Describe the Solution You'd Like
Rename `_live_api_client` to `live_api_client` (remove leading underscore) and update the docstring to document the override pattern, similar to the existing `api_client` example:
```python
class LiveGemini(Gemini):
@cached_property
def live_api_client(self):
return genai.Client(enterprise=True, location="europe-central2")
```
Update the class docstring to include something like:
```
Customizing the underlying Live Client:
To set ``google.genai.Client`` options for the Live API connection,
subclass ``Gemini`` and override the ``live_api_client`` property::
from functools import cached_property
from google.adk.models import Gemini
from google.genai import Client
class LiveGemini(Gemini):
@cached_property
def live_api_client(self):
return Client(enterprise=True, location="europe-central2")
```
### Impact on your work
We deploy Gemini agents on Vertex AI in a specific region. Without overriding `_live_api_client`, all Live API connections default to `us-central1`. We had to discover this private property by reading source code — it's not discoverable from the public API.
### Willingness to contribute
Yes, happy to submit a PR if the change direction is approved.
---
## 🟡 Recommended Information
### Describe Alternatives You've Considered
- Overriding `api_client` only: doesn't work, Live API uses `_live_api_client`, not `api_client`.
- Setting `location` via `http_options` on the model config: ADK doesn't expose a field for this on Live API connections.
### Proposed API / Implementation
In `google_llm.py`:
1. Rename `_live_api_client` → `live_api_client` (both the `@cached_property` and its usage in `connect()`).
2. Add the docstring section shown above.
3. Keep `_live_api_client` as a deprecated alias pointing to `live_api_client` for backward compatibility.
### Additional Context
The `api_client` property already follows this public-override pattern successfully. The `_live_api_client` property was introduced later (for the Live API code path) but its usage pattern is identical — subclasses need to override it — yet it was mistakenly made private.
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.