Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions google/genai/batches.py
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,9 @@ def _InlinedResponse_from_mldev(
),
)

if getv(from_object, ['metadata']) is not None:
setv(to_object, ['metadata'], getv(from_object, ['metadata']))

if getv(from_object, ['error']) is not None:
setv(to_object, ['error'], getv(from_object, ['error']))

Expand Down
46 changes: 31 additions & 15 deletions google/genai/tests/batches/test_create_with_inlined_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,36 @@
},
]

_INLINED_REQUEST = {
'contents': [{
'parts': [{
'text': 'Hello!',
_INLINED_REQUESTS = [
{
'contents': [{
'parts': [{
'text': 'what is the number after 1? return just the number.',
}],
'role': 'user',
}],
'role': 'user',
}],
'metadata': {
'key': 'request-1',
'metadata': {
'key': 'request-1',
},
'config': {
'safety_settings': _SAFETY_SETTINGS,
},
},
'config': {
'safety_settings': _SAFETY_SETTINGS,
{
'contents': [{
'parts': [{
'text': 'what is the number after 2? return just the number.',
}],
'role': 'user',
}],
'metadata': {
'key': 'request-2',
},
'config': {
'safety_settings': _SAFETY_SETTINGS,
},
},
}
]
_INLINED_TEXT_REQUEST_UNION = {
'contents': [{
'parts': [{
Expand Down Expand Up @@ -154,7 +170,7 @@
name='test_union_with_inlined_request',
parameters=types._CreateBatchJobParameters(
model=_MLDEV_GEMINI_MODEL,
src=[_INLINED_REQUEST],
src=_INLINED_REQUESTS,
config={
'display_name': _DISPLAY_NAME,
},
Expand All @@ -166,7 +182,7 @@
name='test_with_inlined_request',
parameters=types._CreateBatchJobParameters(
model=_MLDEV_GEMINI_MODEL,
src={'inlined_requests': [_INLINED_REQUEST]},
src={'inlined_requests': _INLINED_REQUESTS},
config={
'display_name': _DISPLAY_NAME,
},
Expand All @@ -177,7 +193,7 @@
name='test_with_inlined_request_config',
parameters=types._CreateBatchJobParameters(
model=_MLDEV_GEMINI_MODEL,
src={'inlined_requests': [_INLINED_TEXT_REQUEST]},
src={'inlined_requests': _INLINED_REQUESTS},
config={
'display_name': _DISPLAY_NAME,
},
Expand Down Expand Up @@ -247,7 +263,7 @@ async def test_async_create(client):
with pytest_helper.exception_if_vertex(client, ValueError):
batch_job = await client.aio.batches.create(
model=_GEMINI_MODEL,
src=[_INLINED_REQUEST],
src=_INLINED_REQUESTS,
)
assert batch_job.name.startswith('batches/')
assert (
Expand Down
2 changes: 1 addition & 1 deletion google/genai/tests/batches/test_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
f'batchPredictionJobs/{_BATCH_JOB_NAME}'
)
# MLDev batch operation name.
_MLDEV_BATCH_OPERATION_NAME = 'batches/0yew7plxupyybd7appsrq5vw7w0lp3l79lab'
_MLDEV_BATCH_OPERATION_NAME = 'batches/z2p8ksus4lyxt25rntl3fpd67p2niw4hfij5'
_INVALID_BATCH_JOB_NAME = 'invalid_name'


Expand Down
7 changes: 7 additions & 0 deletions google/genai/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -14382,6 +14382,10 @@ class InlinedResponse(_common.BaseModel):
description="""The response to the request.
""",
)
metadata: Optional[dict[str, str]] = Field(
default=None,
description="""The metadata to be associated with the request.""",
)
error: Optional[JobError] = Field(
default=None,
description="""The error encountered while processing the request.
Expand All @@ -14396,6 +14400,9 @@ class InlinedResponseDict(TypedDict, total=False):
"""The response to the request.
"""

metadata: Optional[dict[str, str]]
"""The metadata to be associated with the request."""

error: Optional[JobErrorDict]
"""The error encountered while processing the request.
"""
Expand Down