streaming-architecture
БесплатноБез исполняемых скриптовНе проверенLiteLLM-RS Streaming Architecture. Covers UnifiedSSEParser line buffering, the SSETransformer trait, UnifiedSSEStream backpressure and overflow guarding…
Об этом скилле
Streaming Architecture Guide
Overview
Provider streaming lives in src/core/providers/base/sse.rs plus per-provider
transformers under src/core/providers/base/sse/ (openai.rs, anthropic.rs,
gemini.rs, cohere.rs, databricks.rs). The layer consumes a provider's raw
SSE byte stream and yields Result<ChatChunk, ProviderError> items in an
OpenAI-compatible shape, so the server routes never see provider-specific
formats.
Streaming Flow
┌─────────────────────────────────────────────────────────────────┐
│ Provider SSE byte stream │
│ reqwest::Response::bytes_stream() │
│ (OpenAI, Anthropic, Google, ...) │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ UnifiedSSEStream<S, T> │
│ - polls upstream bytes, feeds UnifiedSSEParser │
│ - chunk_buffer: VecDeque<ChatChunk>, capped at 10_000 │
│ - Item = Result<ChatChunk, ProviderError> │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ UnifiedSSEParser<T> │
│ - String line buffer (incomplete tail retained across reads) │
│ - SSEEvent field parsing, multi-line data joining │
│ - end-marker / finish_stream dispatch │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ SSETransformer (per provider) │
│ - transform_chunk / transform_stream_chunk │
│ - normalizes wire format to ChatChunk │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Server route re-serialization │
│ ChatChunk -> SSE frames ("data: {...}\n\n") + final [DONE] │
└─────────────────────────────────────────────────────────────────┘
The parser owns its transformer: UnifiedSSEParser<T: SSETransformer> calls
back into T while parsing, so there is no separate processing stage between
parser and transformer.
Core Components
SSEEvent
// src/core/providers/base/sse.rs
#[derive(Debug, Clone)]
pub struct SSEEvent {
pub event_type: Option<String>,
pub data: String,
pub id: Option<String>,
pub retry: Option<u64>,
}
SSEEvent::from_line(&str) -> Option<SSEEvent> parses one SSE field line:
- Empty lines and
:comment lines returnNone. data,event,id, andretryset the matching field; whitespace after the colon is trimmed.retrymust parse asu64, otherwiseNone; unknown fields returnNone.
The parser accumulates multiple data lines of one event, joining them with
\n, and dispatches on the blank line that terminates the event.
SSETransformer Trait
// src/core/providers/base/sse.rs
pub trait SSETransformer: Send + Sync {
fn provider_name(&self) -> &'static str;
fn is_end_marker(&self, data: &str) -> bool {
data.trim() == "[DONE]"
}
fn transform_chunk(&self, data: &str) -> Result<Option<ChatChunk>, ProviderError>;
fn transform_stream_chunk(&self, data: &str) -> Result<Option<ChatChunk>, ProviderError> {
self.transform_chunk(data)
}
fn finish_stream(&self) -> Result<Option<ChatChunk>, ProviderError> {
Ok(None)
}
fn parse_finish_reason(&self, reason: &str) -> Option<FinishReason> { ... }
}
- Errors are
ProviderError(crate::core::providers::unified_provider::ProviderError). There is no dedicatedStreamErrorenum. - The default
parse_finish_reasonmaps case-insensitively:stop|end_turn-> Stop,length|max_tokens-> Length,tool_calls|function_call|tool_use-> ToolCalls,content_filter|safety|recitation-> ContentFilter,stop_sequence-> StopSequence,refusal-> Refusal,pause_turn-> PauseTurn; unknown strings yieldNone. - Built-in implementations:
OpenAICompatibleTransformer,AnthropicTransformer,GeminiTransformer,CohereTransformer,DatabricksTransformer(see reference/provider-transformers.md).
UnifiedSSEParser<T>
// src/core/providers/base/sse.rs
pub struct UnifiedSSEParser<T: SSETransformer> {
transformer: T,
buffer: String,
current_event: Option<SSEEvent>,
}
impl<T: SSETransformer> UnifiedSSEParser<T> {
pub fn ne
Установить streaming-architecture в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл streaming-architecture?
LiteLLM-RS Streaming Architecture. Covers UnifiedSSEParser line buffering, the SSETransformer trait, UnifiedSSEStream backpressure and overflow guarding, provider-specific transformers, and server-side SSE emission. Use when debugging SSE parsing, writing or modifying a provider stream transformer, wiring the stream processing pipeline, or tuning the stream idle timeout.
Как установить скилл streaming-architecture?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл streaming-architecture запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic