google / google/adk-python

Make _live_api_client a public, documented override point (like api_client)

Aperta
#5,862 1 commento 0 reazioni 1 assegnatario Rivendicata da @sanketpatil06 Vedi su GitHub
live needs review
Lingua principale
Python
Stelle
21.5k
Fork
4k
Merge medio
1g 14h
PR unite (30g)
37

Descrizione

## 🔴 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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.