fromTemplateFile static method

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

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

  • 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<CustomChatMessagePromptTemplate> fromTemplateFile(
  final String templateFile, {
  required final String role,
  final PartialValues? partialVariables,
  final bool validateTemplate = true,
}) async {
  final file = XFile(templateFile);
  final template = await file.readAsString();
  return CustomChatMessagePromptTemplate.fromTemplate(
    template,
    role: role,
    partialVariables: partialVariables,
    validateTemplate: validateTemplate,
  );
}