Function: rebuildMessages()
rebuildMessages(
conversations
):Message
[]
Defined in: packages/core/src/utils/messages.ts:39
Rebuild the messages from the conversations, which is an array of {prompt, response}
.
The messages are in the format of the Message interface in Vercel AI SDK.
This function can be used to restore the messages from the persisted conversations.
For example:
const messages = rebuildMessages([
{
prompt: 'What is the capital of France?',
response: { text: 'Paris' },
},
]);
// create assistant
const assistant = createAssistant({
model: 'gpt-4o',
});
assistant.setMessages(messages);
Parameters
conversations
The conversations to rebuild the messages from
Returns
Message
[]
The messages used in the Vercel AI SDK