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.
templateFilethe path to the file containing the prompt template.typethe type of chat message prompt template (HumanChatMessagePromptTemplate by default).customRolethe role of the message iftypeis ChatMessageType.custom.partialVariablesthe partial variables to use for the template.validateTemplatewhether 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,
);
}