Nous.StreamNormalizer.LlamaCpp (nous v0.21.1)

Copy Markdown View Source

Stream normalizer for LlamaCppEx %ChatCompletionChunk{} structs.

Converts NIF-produced chunk structs into normalized Nous stream events. llama.cpp speaks OpenAI's chat.completion wire shape, so both complete responses and deltas go through Nous.StreamNormalizer.OpenAI: text, reasoning_content (as {:thinking_delta, _}), OpenAI-shaped tool_calls deltas (as {:tool_call_delta, _}, which Nous.StreamNormalizer.ToolCallAccumulator assembles) and the finish reason.

LlamaCppEx ends a failed stream with a bare {:error, reason} element (an unsupported chat template, a chunk timeout); it becomes an {:error, %Nous.Errors.ProviderError{provider: :llamacpp}} event, the same error type the non-streaming path returns, rather than being dropped as unknown.

Requires optional dep: {:llama_cpp_ex, "~> 0.8.63"}