File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
server/rest_api/routers/v1 Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,10 @@ class LettaStreamingRequest(LettaRequest):
4242 default = False ,
4343 description = "Flag to determine if individual tokens should be streamed. Set to True for token streaming (requires stream_steps = True)." ,
4444 )
45+ include_pings : bool = Field (
46+ default = False ,
47+ description = "Whether to include periodic keepalive ping messages in the stream to prevent connection timeouts." ,
48+ )
4549
4650
4751class LettaAsyncRequest (LettaRequest ):
Original file line number Diff line number Diff line change @@ -1071,8 +1071,8 @@ async def send_message_streaming(
10711071 request_start_timestamp_ns = request_start_timestamp_ns ,
10721072 include_return_message_types = request .include_return_message_types ,
10731073 )
1074- # Conditionally wrap with keepalive based on settings
1075- if settings .enable_keepalive :
1074+ # Conditionally wrap with keepalive based on request parameter
1075+ if request . include_pings and settings .enable_keepalive :
10761076 stream = add_keepalive_to_stream (raw_stream , keepalive_interval = settings .keepalive_interval )
10771077 else :
10781078 stream = raw_stream
@@ -1089,8 +1089,8 @@ async def send_message_streaming(
10891089 request_start_timestamp_ns = request_start_timestamp_ns ,
10901090 include_return_message_types = request .include_return_message_types ,
10911091 )
1092- # Conditionally wrap with keepalive based on settings
1093- if settings .enable_keepalive :
1092+ # Conditionally wrap with keepalive based on request parameter
1093+ if request . include_pings and settings .enable_keepalive :
10941094 stream = add_keepalive_to_stream (raw_stream , keepalive_interval = settings .keepalive_interval )
10951095 else :
10961096 stream = raw_stream
You can’t perform that action at this time.
0 commit comments