klyn.genai.llm.inference.LocalLLMProvider.completeStreaming
method
public completeStreaming(request as LLMRequest, observer as LocalGenerationObserver) as LLMResponse throws Exception
Description

Generates incrementally on the calling thread, with cooperative stopping. Text callbacks contain only new complete Unicode scalars. At cancellation or an output-length boundary, an incomplete trailing scalar is withheld. Model loading is separate and not interruptible. Concurrent calls/close remain unsupported. All generation buffers are freed on stop or exception.

Parameters
ParameterDescription
requestSame typed text/tool contract as complete(). Generated tool markup is withheld from onText and returned as validated ToolCalls.
observerRequired synchronous observer, including during prefill.
Returns

Partial or full response; finishReason is stop, tool_calls, length or cancelled. Incomplete/stopped calls are never returned for execution. Token counts include a generated EOS, but not unprocessed prompt tokens.

Throws
  • ValueException for unsupported content, bounds or malformed text.
  • Exception for observer/device failures; resources are still released.
Example

response = provider.completeStreaming(LLMRequest(messages), observer)