SystemChatMessagePromptTemplate.fromTemplate constructor

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

Creates a SystemChatMessagePromptTemplate from a string template. It considers the prompt a SystemChatMessage.

Example:

final msgTemplate = SystemChatMessagePromptTemplate.fromTemplate("Here's some context: {context}");

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

final msgTemplate = ChatMessagePromptTemplate.system("Here's some context: {context}");
  • template the template string.
  • partialVariables the partial variables to use for the template.
  • validateTemplate whether to validate the template.

Implementation

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