Skip to main content
Version: Next

Function: useLLMChatSession()

useLLMChatSession(config, options?): object

Defined in: hooks/useLLMChatSession.ts:26

React hook to load and run an LLM chat session.

This hook manages downloading (if remote URLs are provided) and loading the model assets and tokenizer files, tracking download progress and load errors, and releasing native memory when the component unmounts or the configuration changes.

For imperative usage, see createLLMChatSession.

Parameters​

config​

LLMModel

The LLM model configuration. See LLMModel.

options?​

LLMChatSessionOptions & ResourceOptions

Chat session options and load/caching options. See LLMChatSessionOptions & ResourceOptions.

Returns​

object

The same object as LLMChatSession (without dispose), combined with loading state and download progress.

downloadProgress​

downloadProgress: any

error​

error: any

getHistory​

getHistory: any = session.getHistory

getKVCacheState​

getKVCacheState: any = session.getKVCacheState

isReady​

isReady: boolean = !!session

resource​

resource: any

sendMessage​

sendMessage: any = session.sendMessage

stop​

stop: any = session.stop

See​

LLMChatSession