fromTemplateFile static method
Future<ChatPromptTemplate>
fromTemplateFile(
- String templateFile, {
- ChatMessageType type = ChatMessageType.human,
- String? customRole,
- PartialValues? partialVariables,
- bool validateTemplate = true,
Creates a ChatPromptTemplate with a single message from a file.
templateFile
the path to the file containing the prompt template.type
the type of chat message prompt template (HumanChatMessagePromptTemplate by default).customRole
the role of the message iftype
is ChatMessageType.custom.partialVariables
the partial variables to use for the template.validateTemplate
whether to validate the template.
Implementation
static Future<ChatPromptTemplate> fromTemplateFile(
final String templateFile, {
final ChatMessageType type = ChatMessageType.human,
final String? customRole,
final PartialValues? partialVariables,
final bool validateTemplate = true,
}) async {
final file = XFile(templateFile);
final template = await file.readAsString();
return ChatPromptTemplate.fromTemplate(
template,
type: type,
customRole: customRole,
partialVariables: partialVariables,
validateTemplate: validateTemplate,
);
}