Skip to main content
Version: 0.10.0

Type Alias: LLMChatSession

LLMChatSession = object

Defined in: extensions/llm/tasks/llmChatSession.ts:100

Handle to an active LLM chat session.

Methods

dispose()

dispose(): void

Defined in: extensions/llm/tasks/llmChatSession.ts:109

Disposes native model weights, KV cache, and tokenizer runtime resources.

Returns

void


getHistory()

getHistory(): readonly ChatMessage[]

Defined in: extensions/llm/tasks/llmChatSession.ts:114

Returns a snapshot of the current message history in the session.

Returns

readonly ChatMessage[]


getKVCacheState()

getKVCacheState(): LLMKVCacheState

Defined in: extensions/llm/tasks/llmChatSession.ts:119

Returns current KV cache occupancy and total capacity statistics for the session runner.

Returns

LLMKVCacheState


sendMessage()

sendMessage(message, onToken?, genConfig?): Promise<LLMChatTurnResult>

Defined in: extensions/llm/tasks/llmChatSession.ts:130

Sends a user message or chat turn to the model and generates a response.

Parameters

message

ChatMessageContent

Message string or interleaved media payload array.

onToken?

(token) => void

Callback fired on the RN thread for each decoded token.

genConfig?

LLMGenerationConfig

Generation options overriding session defaults.

Returns

Promise<LLMChatTurnResult>

A promise resolving to the generated messages and turn stats.

Throws

With code INVALID_ARGUMENT if the message is malformed, or INVALID_STATE if the chat template is non-monotonic.


stop()

stop(): void

Defined in: extensions/llm/tasks/llmChatSession.ts:104

Interrupts and stops any active token generation call.

Returns

void