11// SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22// SPDX-License-Identifier: Apache-2.0
33
4+ use async_trait:: async_trait;
45use dynamo_async_openai:: types:: {
56 ChatCompletionRequestMessage , ChatCompletionRequestUserMessage ,
67 ChatCompletionRequestUserMessageContent , ChatCompletionStreamOptions ,
@@ -9,11 +10,10 @@ use dynamo_async_openai::types::{
910use dynamo_llm:: preprocessor:: OpenAIPreprocessor ;
1011use dynamo_llm:: protocols:: common:: llm_backend:: { BackendOutput , FinishReason } ;
1112use dynamo_llm:: protocols:: openai:: chat_completions:: NvCreateChatCompletionRequest ;
12- use async_trait:: async_trait;
1313use dynamo_runtime:: engine:: { AsyncEngineContext , AsyncEngineStream } ;
1414use dynamo_runtime:: protocols:: annotated:: Annotated ;
15- use futures:: stream;
1615use futures:: StreamExt ;
16+ use futures:: stream;
1717use std:: pin:: Pin ;
1818use std:: sync:: Arc ;
1919use std:: sync:: atomic:: { AtomicBool , Ordering } ;
@@ -115,7 +115,11 @@ fn create_mock_backend_stream(
115115 } ,
116116 ] ;
117117
118- let stream = stream:: iter ( outputs. into_iter ( ) . map ( |output| Annotated :: from_data ( output) ) ) ;
118+ let stream = stream:: iter (
119+ outputs
120+ . into_iter ( )
121+ . map ( |output| Annotated :: from_data ( output) ) ,
122+ ) ;
119123
120124 use dynamo_runtime:: engine:: ResponseStream ;
121125 ResponseStream :: new ( Box :: pin ( stream) , ctx)
@@ -244,7 +248,10 @@ async fn test_streaming_with_usage_compliance() {
244248 usage. completion_tokens, 3 ,
245249 "Should have 3 completion tokens"
246250 ) ;
247- assert_eq ! ( usage. prompt_tokens, 0 , "Should have 0 prompt tokens (not set in test)" ) ;
251+ assert_eq ! (
252+ usage. prompt_tokens, 0 ,
253+ "Should have 0 prompt tokens (not set in test)"
254+ ) ;
248255 assert_eq ! (
249256 usage. total_tokens, 3 ,
250257 "Total tokens should be prompt + completion"
@@ -289,4 +296,4 @@ async fn test_streaming_with_usage_false() {
289296 ) ;
290297 }
291298 }
292- }
299+ }
0 commit comments