fromTemplateFile static method

Future<AIChatMessagePromptTemplate> fromTemplateFile(
  1. String templateFile, {
  2. PartialValues? partialVariables,
  3. bool validateTemplate = true,
})

Load a prompt from a file. It considers the prompt a AIChatMessage.

  • templateFile the path to the file containing the prompt template.
  • partialVariables the partial variables to use for the template.
  • validateTemplate whether to validate the template.

Implementation

static Future<AIChatMessagePromptTemplate> fromTemplateFile(
  final String templateFile, {
  final PartialValues? partialVariables,
  final bool validateTemplate = true,
}) async {
  final file = XFile(templateFile);
  final template = await file.readAsString();
  return AIChatMessagePromptTemplate.fromTemplate(
    template,
    partialVariables: partialVariables,
    validateTemplate: validateTemplate,
  );
}