Skip to content

How to make the assistant write the first message? #1293

Answered by ranst91
simpel asked this question in Help
Discussion options

You must be logged in to vote
// Define the initial state of the AI. It can be any JSON object.
const initialAIState: {
	role: 'user' | 'assistant' | 'system' | 'function';
	content: string;
	id?: string;
	name?: string;
}[] = [{
	role: 'assistant',
	content: 'Hello! How can I assist you today?',
}];

// The initial UI state that the client will keep track of, which contains the message IDs and their UI nodes.
const initialUIState: {
	id: number;
	display: React.ReactNode;
}[] = [
	{
		id: Date.now(), // Just an example of an ID here
		display: <p>{initialAIState?.[0]?.content}</p>
	}
];

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@simpel
Comment options

Answer selected by simpel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants