@@ -498,6 +498,7 @@ def _get_dd_llm_obs_payload_metadata(
498
498
"guardrail_information" : standard_logging_payload .get (
499
499
"guardrail_information" , None
500
500
),
501
+ "is_streamed_request" : self ._get_stream_value_from_payload (standard_logging_payload ),
501
502
}
502
503
503
504
#########################################################
@@ -561,6 +562,31 @@ def _get_latency_metrics(
561
562
562
563
return latency_metrics
563
564
565
+ def _get_stream_value_from_payload (self , standard_logging_payload : StandardLoggingPayload ) -> bool :
566
+ """
567
+ Extract the stream value from standard logging payload.
568
+
569
+ The stream field in StandardLoggingPayload is only set to True for completed streaming responses.
570
+ For non-streaming requests, it's None. The original stream parameter is in model_parameters.
571
+
572
+ Returns:
573
+ bool: True if this was a streaming request, False otherwise
574
+ """
575
+ # Check top-level stream field first (only True for completed streaming)
576
+ stream_value = standard_logging_payload .get ("stream" )
577
+ if stream_value is True :
578
+ return True
579
+
580
+ # Fallback to model_parameters.stream for original request parameters
581
+ model_params = standard_logging_payload .get ("model_parameters" , {})
582
+ if isinstance (model_params , dict ):
583
+ stream_value = model_params .get ("stream" )
584
+ if stream_value is True :
585
+ return True
586
+
587
+ # Default to False for non-streaming requests
588
+ return False
589
+
564
590
def _get_spend_metrics (
565
591
self , standard_logging_payload : StandardLoggingPayload
566
592
) -> DDLLMObsSpendMetrics :
0 commit comments