add in Buffering..

Signed-off-by: Wang, Yi A <yi.a.wang@intel.com>
This commit is contained in:
Wang, Yi A 2025-02-09 19:28:37 -08:00
parent efeef0bed6
commit ecbd956a4c

View File

@ -1345,6 +1345,18 @@ pub(crate) async fn chat_completions(
model_id.clone(), model_id.clone(),
); );
yield Ok::<Event, Infallible>(event); yield Ok::<Event, Infallible>(event);
if stream_token.details.is_some() && stream_options
.as_ref()
.map(|s| s.include_usage)
.unwrap_or(false) {
let usage_event = create_usage_event_from_stream_token(
stream_token,
stream_options.clone(),
system_fingerprint.clone(),
model_id.clone(),
);
yield Ok::<Event, Infallible>(usage_event);
}
} }
} }
} }