feat: move keepalive to an arg (#3652)

This commit is contained in:
Charles Packer
2025-07-30 16:49:45 -07:00
committed by GitHub
parent e2d8b35201
commit a13c6c78bb
2 changed files with 8 additions and 4 deletions

View File

@@ -42,6 +42,10 @@ class LettaStreamingRequest(LettaRequest):
default=False,
description="Flag to determine if individual tokens should be streamed. Set to True for token streaming (requires stream_steps = True).",
)
include_pings: bool = Field(
default=False,
description="Whether to include periodic keepalive ping messages in the stream to prevent connection timeouts.",
)
class LettaAsyncRequest(LettaRequest):

View File

@@ -1071,8 +1071,8 @@ async def send_message_streaming(
request_start_timestamp_ns=request_start_timestamp_ns,
include_return_message_types=request.include_return_message_types,
)
# Conditionally wrap with keepalive based on settings
if settings.enable_keepalive:
# Conditionally wrap with keepalive based on request parameter
if request.include_pings and settings.enable_keepalive:
stream = add_keepalive_to_stream(raw_stream, keepalive_interval=settings.keepalive_interval)
else:
stream = raw_stream
@@ -1089,8 +1089,8 @@ async def send_message_streaming(
request_start_timestamp_ns=request_start_timestamp_ns,
include_return_message_types=request.include_return_message_types,
)
# Conditionally wrap with keepalive based on settings
if settings.enable_keepalive:
# Conditionally wrap with keepalive based on request parameter
if request.include_pings and settings.enable_keepalive:
stream = add_keepalive_to_stream(raw_stream, keepalive_interval=settings.keepalive_interval)
else:
stream = raw_stream