UNPKG

@langchain/core

Version:
1 lines 3.5 kB
{"version":3,"file":"template.d.ts","names":["MessageContent","InputValues","TemplateFormat","ParsedTemplateNode","ParsedFStringNode","parseFString","parseMustache","interpolateFString","interpolateMustache","Interpolator","Parser","DEFAULT_FORMATTER_MAPPING","Record","DEFAULT_PARSER_MAPPING","renderTemplate","parseTemplate","checkValidTemplate"],"sources":["../../src/prompts/template.d.ts"],"sourcesContent":["import { MessageContent } from \"../messages/index.js\";\nimport type { InputValues } from \"../utils/types/index.js\";\n/**\n * Type that specifies the format of a template.\n */\nexport type TemplateFormat = \"f-string\" | \"mustache\";\n/**\n * Type that represents a node in a parsed format string. It can be either\n * a literal text or a variable name.\n */\nexport type ParsedTemplateNode = {\n type: \"literal\";\n text: string;\n} | {\n type: \"variable\";\n name: string;\n};\n/**\n * Alias for `ParsedTemplateNode` since it is the same for\n * both f-string and mustache templates.\n */\nexport type ParsedFStringNode = ParsedTemplateNode;\nexport declare const parseFString: (template: string) => ParsedTemplateNode[];\nexport declare const parseMustache: (template: string) => ParsedTemplateNode[];\nexport declare const interpolateFString: (template: string, values: InputValues) => string;\nexport declare const interpolateMustache: (template: string, values: InputValues) => string;\n/**\n * Type that represents a function that takes a template string and a set\n * of input values, and returns a string where all variables in the\n * template have been replaced with their corresponding values.\n */\ntype Interpolator = (template: string, values: InputValues) => string;\n/**\n * Type that represents a function that takes a template string and\n * returns an array of `ParsedTemplateNode`.\n */\ntype Parser = (template: string) => ParsedTemplateNode[];\nexport declare const DEFAULT_FORMATTER_MAPPING: Record<TemplateFormat, Interpolator>;\nexport declare const DEFAULT_PARSER_MAPPING: Record<TemplateFormat, Parser>;\nexport declare const renderTemplate: (template: string, templateFormat: TemplateFormat, inputValues: InputValues) => string;\nexport declare const parseTemplate: (template: string, templateFormat: TemplateFormat) => ParsedTemplateNode[];\nexport declare const checkValidTemplate: (template: MessageContent, templateFormat: TemplateFormat, inputVariables: string[]) => void;\nexport {};\n"],"mappings":";;;;;;;AAKA;AAKY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