mirror of
https://github.com/BerriAI/litellm.git
synced 2026-12-01 01:18:34 +00:00
* refactor(framer): replace Framer trait with tokio-util codecs Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * refactor(framer): port SSE and AWS event stream framing to codecs Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(rust): drop clone on Copy capabilities in messages request test Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(rust): use field init shorthand in messages request test Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Yujong Lee <yujong@berri.ai> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
21 lines
505 B
Rust
21 lines
505 B
Rust
use std::io;
|
|
|
|
use bytes::Buf;
|
|
use futures_util::{Stream, StreamExt, TryStreamExt};
|
|
use tokio_util::{
|
|
codec::{Decoder, FramedRead},
|
|
io::StreamReader,
|
|
};
|
|
|
|
pub fn frames<S, B, E, D>(
|
|
input: S,
|
|
codec: D,
|
|
) -> impl Stream<Item = Result<D::Item, D::Error>> + Send
|
|
where
|
|
S: Stream<Item = Result<B, E>> + Send,
|
|
B: Buf + Send,
|
|
E: std::error::Error + Send + Sync + 'static,
|
|
D: Decoder + Send,
|
|
{
|
|
FramedRead::new(StreamReader::new(input.map_err(io::Error::other)), codec).fuse()
|
|
}
|