Custom
LocalRuntime
Overview
With LocalRuntime, the chat history state is managed by assistant-ui. This gives you built-in support for thread management, message editing, reloading and branch switching.
If you need full control over the state of the messages on the frontend, use ExternalStoreRuntime instead.
assistant-ui
integrates with any custom REST API. To do so, you define a custom ChatModelAdapter
and pass it to the useLocalRuntime
hook.
Getting Started
Define a MyRuntimeProvider
component
Update the MyModelAdapter
below to integrate with your own custom API.
Streaming
Declare the run
function as an AsyncGenerator
(async *run
). This allows you to yield
the results as they are generated.