HumanChatMessagePromptTemplate.fromTemplate constructor

HumanChatMessagePromptTemplate.fromTemplate(
  1. String template, {
  2. PartialValues? partialVariables,
  3. bool validateTemplate = true,
})

Creates a HumanChatMessagePromptTemplate from a string template. It considers the prompt a HumanChatMessage.

Example:

final msgTemplate = HumanChatMessagePromptTemplate.fromTemplate(
  "Hello {foo}, I'm {bar}. Thanks for the {context}",
);

Alternatively, you can use ChatMessagePromptTemplate.human to achieve the same result.

final msgTemplate = ChatMessagePromptTemplate.human(
  "Hello {foo}, I'm {bar}. Thanks for the {context}",
);
  • template the template string.
  • partialVariables the partial variables to use for the template.
  • validateTemplate whether to validate the template.

Implementation

factory HumanChatMessagePromptTemplate.fromTemplate(
  final String template, {
  final PartialValues? partialVariables,
  final bool validateTemplate = true,
}) {
  return HumanChatMessagePromptTemplate(
    prompt: PromptTemplate.fromTemplate(
      template,
      partialVariables: partialVariables,
      validateTemplate: validateTemplate,
    ),
  );
}