llm library

Classes

ChatCancellation
A cancellation lifetime belongs to one prompt, including its tool rounds.
ChatTool
The host explicitly registers tools and validates their business arguments.
LlmChatSession
Each instance owns independent context, cancellation and permissions. Only completed turns enter future requests. Tools execute in the host.
OpenAiChatClient
One Chat Completions stream. The client is closed on success, failure, subscription cancellation, timeout, and explicit stop; no shared connection lifetime can accidentally cancel another conversation.

Functions

decodeServerSentEvents(Stream<List<int>> bytes, {int maxEventBytes = 1024 * 1024, int maxResponseBytes = 16 * 1024 * 1024}) Stream<String>
Parses UTF-8 SSE independently of network chunk boundaries. Bounds are enforced before assembling an unbounded line or event, including comments.

Typedefs

ChatToolExecutor = Future<String> Function(Map<String, Object?> arguments, ChatCancellation cancellation)

Exceptions / Errors

ChatApiException
ChatCancelled