@@ -27,7 +27,7 @@ use crate::protocols::openai::chat_completions::{
2727} ;
2828use crate :: protocols:: Annotated ;
2929use dynamo_runtime:: engine:: {
30- AsyncEngineContext , AsyncEngineContextProvider , AsyncEngineStream , Data ,
30+ AsyncEngineContext , AsyncEngineContextProvider , AsyncEngineStream , Data , DataStream ,
3131} ;
3232
3333/// Configuration for HTTP clients
@@ -226,43 +226,29 @@ impl BaseHttpClient {
226226}
227227
228228/// Type alias for NV chat response stream
229- pub type NvChatResponseStream = Pin <
230- Box <
231- dyn Stream < Item = Result < Annotated < NvCreateChatCompletionStreamResponse > , OpenAIError > >
232- + Send
233- + Sync ,
234- > ,
235- > ;
229+ pub type NvChatResponseStream =
230+ DataStream < Result < Annotated < NvCreateChatCompletionStreamResponse > , OpenAIError > > ;
236231
237232/// Type alias for generic BYOT response stream
238- pub type ByotResponseStream = Pin < Box < dyn Stream < Item = Result < Value , OpenAIError > > + Send + Sync > > ;
233+ pub type ByotResponseStream = DataStream < Result < Value , OpenAIError > > ;
239234
240235/// Type alias for pure OpenAI chat response stream
241- pub type OpenAIChatResponseStream = Pin <
242- Box <
243- dyn Stream <
244- Item = Result < async_openai:: types:: CreateChatCompletionStreamResponse , OpenAIError > ,
245- > + Send
246- + Sync ,
247- > ,
248- > ;
236+ pub type OpenAIChatResponseStream =
237+ DataStream < Result < async_openai:: types:: CreateChatCompletionStreamResponse , OpenAIError > > ;
249238
250239/// A wrapped HTTP response stream that combines a stream with its context
251240/// This provides a unified interface for HTTP client responses
252241#[ derive( Dissolve ) ]
253242pub struct HttpResponseStream < T > {
254243 /// The underlying stream of responses
255- pub stream : Pin < Box < dyn Stream < Item = T > + Send > > ,
244+ pub stream : DataStream < T > ,
256245 /// The context for this request
257246 pub context : Arc < dyn AsyncEngineContext > ,
258247}
259248
260249impl < T > HttpResponseStream < T > {
261250 /// Create a new HttpResponseStream
262- pub fn new (
263- stream : Pin < Box < dyn Stream < Item = T > + Send > > ,
264- context : Arc < dyn AsyncEngineContext > ,
265- ) -> Self {
251+ pub fn new ( stream : DataStream < T > , context : Arc < dyn AsyncEngineContext > ) -> Self {
266252 Self { stream, context }
267253 }
268254}
@@ -299,7 +285,7 @@ impl<T: Data> HttpResponseStream<T> {
299285
300286/// A wrapper that implements AsyncEngineStream for streams that are Send + Sync
301287struct AsyncEngineStreamWrapper < T > {
302- stream : Pin < Box < dyn Stream < Item = T > + Send > > ,
288+ stream : DataStream < T > ,
303289 context : Arc < dyn AsyncEngineContext > ,
304290}
305291
@@ -317,9 +303,9 @@ impl<T: Data> AsyncEngineContextProvider for AsyncEngineStreamWrapper<T> {
317303 }
318304}
319305
320- // This is unsafe because we're claiming the stream is Sync when it might not be
321- // But this is needed for the AsyncEngineStream trait
322- unsafe impl < T > Sync for AsyncEngineStreamWrapper < T > { }
306+ // // This is unsafe because we're claiming the stream is Sync when it might not be
307+ // // But this is needed for the AsyncEngineStream trait
308+ // unsafe impl<T> Sync for AsyncEngineStreamWrapper<T> {}
323309
324310impl < T : Data > AsyncEngineStream < T > for AsyncEngineStreamWrapper < T > { }
325311
0 commit comments