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.
Wrap your app in MyRuntimeProvider
Streaming
Declare the run
function as an AsyncGenerator
(async *run
). This allows you to yield
the results as they are generated.
Resuming a Run
The unstable_resumeRun
method is experimental and may change in future releases.
In some advanced scenarios, you might need to resume a run with a custom stream. The ThreadRuntime.unstable_resumeRun
method allows you to do this by providing an async generator that yields chat model run results.
This is particularly useful for:
- Implementing custom streaming logic
- Resuming conversations from external sources
- Creating demo or testing environments with predefined response patterns
For more detailed information, see the ThreadRuntime.unstable_resumeRun API reference.