googleapis / googleapis/python-genai

embed_content() raises ValueError for multiple Content objects with gemini-embedding-2 on Enterprise

Aperta
#2,567 7 commenti 0 reazioni 1 assegnatario Rivendicata da @Venkaiahbabuneelam Vedi su GitHub
priority: p2 type: bug
Lingua principale
Python
Stelle
4k
Fork
1k
Merge medio
2g 12h
PR unite (30g)
41

Descrizione

#### Environment details

* Programming language: Python
* OS: macOS Tahoe 26.5.1 (25F80)
* Language runtime version: Python 3.10.18
* Package version: google-genai 2.8.0

#### Description

When using `Models.embed_content()` with `gemini-embedding-2` on the Enterprise Agent Platform (`enterprise=True`), the Python SDK raises a client-side `ValueError` when more than one `Content` object is provided in `contents`.

However:

* The method signature accepts `ContentListUnion`.
* The docstring describes `contents` as `list[Content]`.
* The multimodal embeddings documentation states:

> Multiple entries: Sending multiple entries in the contents array returns separate embeddings for each entry.

* The Gemini Enterprise multimodal embeddings documentation also documents multiple entries and up to 6 images per request.
* The exception is raised by the SDK before any request is sent to the backend.

#### Steps to reproduce

```python
import asyncio

from google import genai
from google.genai import types

client = genai.Client(
enterprise=True,
project="PROJECT_ID",
location="global",
)

MODEL = "gemini-embedding-2"

async def main():
image_bytes = open("1.png", "rb").read()

contents = [
types.Content(
parts=[
types.Part.from_bytes(
data=image_bytes,
mime_type="image/png",
)
]
)
for _ in range(6)
]

result = await client.aio.models.embed_content(
model=MODEL,
contents=contents,
)

print(len(result.embeddings))

asyncio.run(main())

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.