feat: Implement Live Session Resumption

Previous implementation doesn't pass the actual handle to server. Now we cache the handle and pass it over when reconnection happens.

To enable:
    run_config = RunConfig(
        session_resumption=types.SessionResumptionConfig(transparent=True)
    )

PiperOrigin-RevId: 791308462
This commit is contained in:
Hangfei Lin
2025-08-05 11:50:54 -07:00
committed by Copybara-Service
parent 423542a43f
commit 71fbc9275b
9 changed files with 333 additions and 76 deletions
+5
View File
@@ -89,6 +89,11 @@ class LlmResponse(BaseModel):
usage_metadata: Optional[types.GenerateContentResponseUsageMetadata] = None
"""The usage metadata of the LlmResponse"""
live_session_resumption_update: Optional[
types.LiveServerSessionResumptionUpdate
] = None
"""The session resumption update of the LlmResponse"""
@staticmethod
def create(
generate_content_response: types.GenerateContentResponse,