googleapis / googleapis/python-genai
Feature Request: Support for per-content titles in embed_content API
- Lingua principale
- Python
- Stelle
- 4k
- Fork
- 1k
- Merge medio
- 2g 12h
- PR unite (30g)
- 41
Descrizione
Thanks for stopping by to let us know something could be better!
**PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response.
**Is your feature request related to a problem? Please describe.**
When using the embed_content API to embed multiple text contents, the current implementation only allows a single title parameter to be specified for all content items. This limitation prevents using different titles for different content items in a batch request, which was previously possible in the VertexAI API using TextEmbeddingInput.
**Describe the solution you'd like**
I would like the embed_content API to support a list of titles in the EmbedContentConfig, where each title corresponds to a specific content item in the contents list. This would allow for more granular embedding control and better performance.
Current available implementation:
```python
response = client.models.embed_content(
model="text-embedding-005",
contents=[
"How do I get a driver's license/learner's permit?",
"How do I renew my driver's license?",
"How do I change my address on my driver's license?",
],
config=EmbedContentConfig(
task_type="RETRIEVAL_DOCUMENT",
output_dimensionality=768,
title="Driver's License", # Single title for all contents
),
)
```
Proposed implementation:
```python
response = client.models.embed_content(
model="text-embedding-005",
contents=[
"How do I get a driver's license/learner's permit?",
"How do I renew my driver's license?",
"How do I change my address on my driver's license?",
],
config=EmbedContentConfig(
task_type="RETRIEVAL_DOCUMENT",
output_dimensionality=768,
title=[
"Driver's License",
"Learner's Permit",
"Driver's License Renewal",
], # List of titles corresponding to each content item
),
)
```
**Describe alternatives you've considered**
I've implemented a patch workaround by modifying the EmbedContentConfig class type definition to accept either a string or a list of strings and it works.
```python
class EmbedContentConfig(_common.BaseModel):
...
title: Optional[list[str] | str] = Field(
default=None,
description="""Title for the text. Only applicable when TaskType is
`RETRIEVAL_DOCUMENT`.
""",
)
```
**Additional context**
This feature was available in the Python VertexAI API through TextEmbeddingInput, so this request is to maintain parity with the previous functionality.
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.