ChatMessagePromptTemplate.messagePlaceholder constructor
ChatMessagePromptTemplate.messagePlaceholder(
- String variableName
Creates a MessagePlaceholder, a prompt template that assumes the variable is a ChatMessage.
This is useful when you want to use a single ChatMessage in the prompt.
For example, when you decide the type of message at runtime (e.g.
HumanChatMessage or FunctionChatMessage
).
This is a convenience factory equivalent to MessagePlaceholder constructor.
If you need to add multiple messages, use ChatMessagePromptTemplate.messagesPlaceholder.
Example:
final promptTemplate = ChatPromptTemplate.fromPromptMessages([
ChatMessagePromptTemplate.system('You are a helpful AI assistant'),
ChatMessagePromptTemplate.messagesPlaceholder('history'),
ChatMessagePromptTemplate.messagePlaceholder('input'),
]);
variableName
the name of the placeholder variable.
Implementation
factory ChatMessagePromptTemplate.messagePlaceholder(
final String variableName,
) {
return MessagePlaceholder(variableName: variableName);
}