Skip to main content

process_openai_stream

Function process_openai_stream 

Source
pub async fn process_openai_stream<S, E, F>(
    byte_stream: S,
    provider_name: &'static str,
    model: String,
    on_chunk: F,
) -> Result<LLMResponse, LLMError>
where S: Stream<Item = Result<Bytes, E>> + Unpin, E: Display, F: FnMut(Value) -> Result<(), LLMError>,
Expand description

Common helper for processing OpenAI-compatible SSE streams.

This simplifies stream implementations across providers like DeepSeek, ZAI, Moonshot, etc. Especially optimized for high-performance models like Gemini 3 and GLM-5.