Skip to content

Commit 3bd5ba0

Browse files
MarkDaoustcopybara-github
authored andcommitted
feat: add LiveServerContent.waiting_for_input flag.
PiperOrigin-RevId: 803169639
1 parent 9f7673d commit 3bd5ba0

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

google/genai/_live_converters.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2655,6 +2655,11 @@ def _LiveServerContent_from_mldev(
26552655
),
26562656
)
26572657

2658+
if getv(from_object, ['waitingForInput']) is not None:
2659+
setv(
2660+
to_object, ['waiting_for_input'], getv(from_object, ['waitingForInput'])
2661+
)
2662+
26582663
return to_object
26592664

26602665

@@ -3331,6 +3336,11 @@ def _LiveServerContent_from_vertex(
33313336
),
33323337
)
33333338

3339+
if getv(from_object, ['waitingForInput']) is not None:
3340+
setv(
3341+
to_object, ['waiting_for_input'], getv(from_object, ['waitingForInput'])
3342+
)
3343+
33343344
return to_object
33353345

33363346

google/genai/tests/live/test_live_response.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ async def test_receive_server_content(mock_websocket, vertexai):
9797
"title": "Search results",
9898
}
9999
}]
100-
}
100+
},
101+
"waitingForInput": True,
101102
}
102103
})
103104
mock_websocket.recv.return_value = raw_response_json
@@ -118,6 +119,9 @@ async def test_receive_server_content(mock_websocket, vertexai):
118119
assert result.server_content.grounding_metadata.web_search_queries == ["test query"]
119120
assert result.server_content.grounding_metadata.grounding_chunks[0].web.domain == "google.com"
120121
assert result.server_content.grounding_metadata.grounding_chunks[0].web.title == "Search results"
122+
123+
assert result.server_content.waiting_for_input is True
124+
121125
# Verify usageMetadata was parsed
122126
assert isinstance(result.usage_metadata, types.UsageMetadata)
123127
assert result.usage_metadata.prompt_token_count == 15

google/genai/types.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13103,6 +13103,12 @@ class LiveServerContent(_common.BaseModel):
1310313103
default=None,
1310413104
description="""Metadata related to url context retrieval tool.""",
1310513105
)
13106+
waiting_for_input: Optional[bool] = Field(
13107+
default=None,
13108+
description="""If true, indicates that the model is not generating content because
13109+
it is waiting for more input from the user, e.g. because it expects the
13110+
user to continue talking.""",
13111+
)
1310613112

1310713113

1310813114
class LiveServerContentDict(TypedDict, total=False):
@@ -13148,6 +13154,11 @@ class LiveServerContentDict(TypedDict, total=False):
1314813154
url_context_metadata: Optional[UrlContextMetadataDict]
1314913155
"""Metadata related to url context retrieval tool."""
1315013156

13157+
waiting_for_input: Optional[bool]
13158+
"""If true, indicates that the model is not generating content because
13159+
it is waiting for more input from the user, e.g. because it expects the
13160+
user to continue talking."""
13161+
1315113162

1315213163
LiveServerContentOrDict = Union[LiveServerContent, LiveServerContentDict]
1315313164

0 commit comments

Comments
 (0)