AIChatMessagePromptTemplate.fromTemplate constructor

AIChatMessagePromptTemplate.fromTemplate(
  1. String template, {
  2. PartialValues? partialVariables,
  3. 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,
    ),
  );
}