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
14 changes: 14 additions & 0 deletions google/genai/batches.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,13 @@ def _Candidate_from_mldev(
getv(from_object, ['urlContextMetadata']),
)

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

return to_object


Expand Down Expand Up @@ -1146,6 +1153,13 @@ def _GenerateContentConfig_to_mldev(
getv(from_object, ['audio_transcription_config']),
)

if getv(from_object, ['continuation_token']) is not None:
setv(
parent_object,
['continuationToken'],
getv(from_object, ['continuation_token']),
)

return to_object


Expand Down
21 changes: 21 additions & 0 deletions google/genai/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ def _Candidate_from_mldev(
getv(from_object, ['urlContextMetadata']),
)

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

return to_object


Expand Down Expand Up @@ -1367,6 +1374,13 @@ def _GenerateContentConfig_to_mldev(
getv(from_object, ['audio_transcription_config']),
)

if getv(from_object, ['continuation_token']) is not None:
setv(
parent_object,
['continuationToken'],
getv(from_object, ['continuation_token']),
)

return to_object


Expand Down Expand Up @@ -1564,6 +1578,13 @@ def _GenerateContentConfig_to_vertex(
getv(from_object, ['audio_transcription_config']),
)

if getv(from_object, ['continuation_token']) is not None:
setv(
parent_object,
['continuationToken'],
getv(from_object, ['continuation_token']),
)

return to_object


Expand Down
26 changes: 26 additions & 0 deletions google/genai/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,8 @@ class FinishReason(_common.CaseInSensitiveEnum):
"""Image generation stopped because the generated image may be a recitation from a source."""
IMAGE_OTHER = 'IMAGE_OTHER'
"""Image generation stopped for a reason not otherwise specified."""
CONTINUATION = 'CONTINUATION'
"""Token generation stopped because the response reached the per-request token limit, but generation is not yet complete. The response can be continued by passing the returned `continuation_token` in a subsequent request."""


class HarmProbability(_common.CaseInSensitiveEnum):
Expand Down Expand Up @@ -6720,6 +6722,13 @@ class GenerateContentConfig(_common.BaseModel):
description="""Optional. Configuration for audio transcription (speech recognition).
""",
)
continuation_token: Optional[bytes] = Field(
default=None,
description="""An opaque continuation token used to resume generation from a
previous response that stopped with `finish_reason` set to
`CONTINUATION`.
""",
)

@pydantic.field_validator('response_schema', mode='before')
@classmethod
Expand Down Expand Up @@ -6941,6 +6950,12 @@ class GenerateContentConfigDict(TypedDict, total=False):
"""Optional. Configuration for audio transcription (speech recognition).
"""

continuation_token: Optional[bytes]
"""An opaque continuation token used to resume generation from a
previous response that stopped with `finish_reason` set to
`CONTINUATION`.
"""


GenerateContentConfigOrDict = Union[
GenerateContentConfig, GenerateContentConfigDict
Expand Down Expand Up @@ -8355,6 +8370,12 @@ class Candidate(_common.BaseModel):
default=None,
description="""Output only. Metadata returned when the model uses the `url_context` tool to get information from a user-provided URL.""",
)
continuation_token: Optional[bytes] = Field(
default=None,
description="""An opaque continuation token returned when `finish_reason` is
`CONTINUATION`. Pass it in a subsequent request to continue generation.
""",
)


class CandidateDict(TypedDict, total=False):
Expand Down Expand Up @@ -8401,6 +8422,11 @@ class CandidateDict(TypedDict, total=False):
url_context_metadata: Optional[UrlContextMetadataDict]
"""Output only. Metadata returned when the model uses the `url_context` tool to get information from a user-provided URL."""

continuation_token: Optional[bytes]
"""An opaque continuation token returned when `finish_reason` is
`CONTINUATION`. Pass it in a subsequent request to continue generation.
"""


CandidateOrDict = Union[Candidate, CandidateDict]

Expand Down
Loading