mirror of
https://github.com/BerriAI/litellm.git
synced 2026-12-02 01:28:38 +00:00
The AWS event stream framer now yields aws_smithy_types Message directly instead of copying headers and payload into a second struct, which halves its allocations (16 to 8 per frame) and cuts wall time by about 30%. It also parses from a slice and advances the buffer rather than splitting and freezing it. SSE parsing no longer goes through sse-stream. The new parser follows the WHATWG event stream grammar (unknown fields ignored, colonless lines are empty fields, last event line wins, non-digit retry and NUL ids ignored, events without data are not dispatched), caps an event at MAX_FRAME_BYTES so an unterminated upstream cannot grow memory without bound, and reports upstream body failures as Error::Body like the AWS path does. Allocations stay at two per event and wall time is within a few percent. The Framer trait had no generic consumer, so both parsers are plain functions now. MissingStreamData in litellm-core is gone because a dispatched SSE event always carries data.
28 lines
620 B
TOML
28 lines
620 B
TOML
[package]
|
|
name = "litellm-framing"
|
|
version = "0.1.0"
|
|
edition.workspace = true
|
|
license.workspace = true
|
|
repository.workspace = true
|
|
|
|
[features]
|
|
default = ["aws", "sse"]
|
|
aws = ["dep:aws-smithy-eventstream", "dep:aws-smithy-types"]
|
|
sse = []
|
|
|
|
[dependencies]
|
|
aws-smithy-eventstream = { version = "=0.61.1", optional = true }
|
|
aws-smithy-types = { version = "1.6.1", optional = true }
|
|
bytes = "1"
|
|
futures-util.workspace = true
|
|
thiserror.workspace = true
|
|
|
|
[dev-dependencies]
|
|
criterion.workspace = true
|
|
rstest.workspace = true
|
|
tokio.workspace = true
|
|
|
|
[[bench]]
|
|
name = "framing"
|
|
harness = false
|
|
required-features = ["aws", "sse"]
|