Struct Anthropic Messages Streaming Codec

View as Markdown

Generated from cargo doc --no-deps -p nemo-relay -p nemo-relay-adaptive -p nemo-relay-ffi.

1pub struct AnthropicMessagesStreamingCodec { /* private fields */ }

Streaming counterpart to AnthropicMessagesCodec.

Replays the Anthropic Messages SSE event sequence into the same JSON shape Anthropic returns for a non-streaming request ({id, type, role, model, content, stop_reason, stop_sequence, usage}). Once finalized, the assembled JSON can be fed back through AnthropicMessagesCodec::decode_response to produce an AnnotatedLlmResponse - meaning streaming and non-streaming Anthropic requests converge on the same observability output.

Internal state lives behind Arc<Mutex<...>> so the &self-produced collector and finalizer closures share access. Each instance is single-use because LlmFinalizerFn consumes the finalize step.

Implementations

impl AnthropicMessagesStreamingCodec

impl AnthropicMessagesStreamingCodec

new

pub fn new() -> Self

Creates a fresh streaming codec with empty accumulator state.

Trait Implementations

impl Default for AnthropicMessagesStreamingCodec

impl Default for AnthropicMessagesStreamingCodec

default

fn default() -> Self

impl StreamingCodec for AnthropicMessagesStreamingCodec

impl StreamingCodec for AnthropicMessagesStreamingCodec

collector

fn collector(&self) -> LlmCollectorFn

finalizer

fn finalizer(&self) -> LlmFinalizerFn