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',
);
template
the template string.role
the role of the message.partialVariables
the partial variables to use for the template.validateTemplate
whether 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,
);
}