provide-messages
type ProvideMessagesData = {
id: TID; // chat id
data: Message[];
}
chat.exec("provide-messages", {
id, data
} as ProvideMessagesData);
chat.intercept("provide-messages", (data: ProvideMessagesData) => {
return false;
});
Data Format for Messages
type Message = {
id: TID;
role: "agent" | "user";
content: string;
typing?: number;
}
where typing
- 0 - without typing animation (default)
- 1 - with typing animation, streaming mode
- -1 - with typing animation, finishing
Use Cases
Detecting New Data Provisioning
type ProvideMessagesData = {
id: TID; // chat id
data: Message[];
}
chat.exec("provide-messages", {
id, data
} as ProvideMessagesData);
This use-case is implemented to detect when new messages are provided for a chat session. This event should be used to trigger UI updates or to process incoming messages. It is crucial for rendering new data in the chat interface.
Blocking New Data Provisioning
type ProvideMessagesData = {
id: TID; // chat id
data: Message[];
}
chat.intercept("provide-messages", (data: ProvideMessagesData) => {
return false;
});
This use-case is implemented to block new messages from being added to the chat session. This can be used for scenarios where message validation fails, or specific conditions are not met for processing incoming data. This helps in ensuring that only valid and necessary data is rendered in the chat interface.