google / google/adk-python

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

Đang mở
#5,862 1 bình luận 0 reaction 1 người được giao Được @sanketpatil06 nhận Xem trên GitHub
live needs review
Ngôn ngữ chính
Python
Star
21.5k
Fork
4k
Merge trung bình
1 ngày 14 giờ
Pull request đã merge (30 ngày)
37

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.