useCopilotReadable
The useCopilotReadable hook allows you to provide knowledge to your copilot (e.g. application state).
useCopilotReadable
is a React hook that provides app-state and other information
to the Copilot. Optionally, the hook can also handle hierarchical state within your
application, passing these parent-child relationships to the Copilot.
Usage
Simple Usage
In its most basic usage, useCopilotReadable accepts a single string argument representing any piece of app state, making it available for the Copilot to use as context when responding to user input.
Nested Components
Optionally, you can maintain the hierarchical structure of information by passing
parentId
. This allows you to use useCopilotReadable
in nested components:
Parameters
The description of the information to be added to the Copilot context.
The value to be added to the Copilot context. Object values are automatically stringified.
The ID of the parent context, if any.
An array of categories to control which context are visible where. Particularly useful
with CopilotTextarea (see useMakeAutosuggestionFunction
)
A custom conversion function to use to serialize the value to a string. If not provided, the value
will be serialized using JSON.stringify
.