CustomChatMessagePromptTemplate.fromTemplate constructor
CustomChatMessagePromptTemplate.fromTemplate(
- String template, {
- required String role,
- PartialValues? partialVariables,
- bool validateTemplate = true,
Creates a CustomChatMessagePromptTemplate from a string template. It considers the prompt a CustomChatMessage.
Example:
final msgTemplate = CustomChatMessagePromptTemplate.fromTemplate(
"I'm an assistant. I'm {foo}. I'm {bar}.",
role: 'assistant',
);
Alternatively, you can use ChatMessagePromptTemplate.custom to achieve the same result.
final msgTemplate = ChatMessagePromptTemplate.custom(
"I'm an assistant. I'm {foo}. I'm {bar}.",
role: 'assistant',
);
templatethe template string.rolethe role of the message.partialVariablesthe partial variables to use for the template.validateTemplatewhether to validate the template.
Implementation
factory CustomChatMessagePromptTemplate.fromTemplate(
final String template, {
required final String role,
final PartialValues? partialVariables,
final bool validateTemplate = true,
}) {
return CustomChatMessagePromptTemplate(
prompt: PromptTemplate.fromTemplate(
template,
partialVariables: partialVariables,
validateTemplate: validateTemplate,
),
role: role,
);
}