AIChatMessagePromptTemplate.fromTemplate constructor
AIChatMessagePromptTemplate.fromTemplate(
- String template, {
- PartialValues? partialVariables,
- bool validateTemplate = true,
Creates a AIChatMessagePromptTemplate from a string template. It considers the prompt a AIChatMessage.
Example:
final msgTemplate = AIChatMessagePromptTemplate.fromTemplate("I'm an AI. I'm {foo}. I'm {bar}.");
Alternatively, you can use ChatMessagePromptTemplate.ai to achieve the same result.
final msgTemplate = ChatMessagePromptTemplate.ai("I'm an AI. I'm {foo}. I'm {bar}.");
template
the template string.partialVariables
the partial variables to use for the template.validateTemplate
whether to validate the template.
Implementation
factory AIChatMessagePromptTemplate.fromTemplate(
final String template, {
final PartialValues? partialVariables,
final bool validateTemplate = true,
}) {
return AIChatMessagePromptTemplate(
prompt: PromptTemplate.fromTemplate(
template,
partialVariables: partialVariables,
validateTemplate: validateTemplate,
),
);
}