1 |
- {"ast":null,"code":"import _asyncToGenerator from \"F:/workspace/202226701027/huinongbao-app/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport { BaseStringPromptTemplate } from \"./string.js\";\nimport { checkValidTemplate, renderTemplate } from \"./template.js\";\nimport { PromptTemplate } from \"./prompt.js\";\nimport { BaseChatPromptTemplate } from \"./chat.js\";\n/**\n * Prompt template that contains few-shot examples.\n * @augments BasePromptTemplate\n * @augments FewShotPromptTemplateInput\n * @example\n * ```typescript\n * const examplePrompt = PromptTemplate.fromTemplate(\n * \"Input: {input}\\nOutput: {output}\",\n * );\n *\n * const exampleSelector = await SemanticSimilarityExampleSelector.fromExamples(\n * [\n * { input: \"happy\", output: \"sad\" },\n * { input: \"tall\", output: \"short\" },\n * { input: \"energetic\", output: \"lethargic\" },\n * { input: \"sunny\", output: \"gloomy\" },\n * { input: \"windy\", output: \"calm\" },\n * ],\n * new OpenAIEmbeddings(),\n * HNSWLib,\n * { k: 1 },\n * );\n *\n * const dynamicPrompt = new FewShotPromptTemplate({\n * exampleSelector,\n * examplePrompt,\n * prefix: \"Give the antonym of every input\",\n * suffix: \"Input: {adjective}\\nOutput:\",\n * inputVariables: [\"adjective\"],\n * });\n *\n * // Format the dynamic prompt with the input 'rainy'\n * console.log(await dynamicPrompt.format({ adjective: \"rainy\" }));\n *\n * ```\n */\nexport class FewShotPromptTemplate extends BaseStringPromptTemplate {\n constructor(input) {\n super(input);\n Object.defineProperty(this, \"lc_serializable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: false\n });\n Object.defineProperty(this, \"examples\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"exampleSelector\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"examplePrompt\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"suffix\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: \"\"\n });\n Object.defineProperty(this, \"exampleSeparator\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: \"\\n\\n\"\n });\n Object.defineProperty(this, \"prefix\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: \"\"\n });\n Object.defineProperty(this, \"templateFormat\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: \"f-string\"\n });\n Object.defineProperty(this, \"validateTemplate\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: true\n });\n Object.assign(this, input);\n if (this.examples !== undefined && this.exampleSelector !== undefined) {\n throw new Error(\"Only one of 'examples' and 'example_selector' should be provided\");\n }\n if (this.examples === undefined && this.exampleSelector === undefined) {\n throw new Error(\"One of 'examples' and 'example_selector' should be provided\");\n }\n if (this.validateTemplate) {\n let totalInputVariables = this.inputVariables;\n if (this.partialVariables) {\n totalInputVariables = totalInputVariables.concat(Object.keys(this.partialVariables));\n }\n checkValidTemplate(this.prefix + this.suffix, this.templateFormat, totalInputVariables);\n }\n }\n _getPromptType() {\n return \"few_shot\";\n }\n static lc_name() {\n return \"FewShotPromptTemplate\";\n }\n getExamples(inputVariables) {\n var _this = this;\n return _asyncToGenerator(function* () {\n if (_this.examples !== undefined) {\n return _this.examples;\n }\n if (_this.exampleSelector !== undefined) {\n return _this.exampleSelector.selectExamples(inputVariables);\n }\n throw new Error(\"One of 'examples' and 'example_selector' should be provided\");\n })();\n }\n partial(values) {\n var _this2 = this;\n return _asyncToGenerator(function* () {\n var _this2$partialVariabl;\n const newInputVariables = _this2.inputVariables.filter(iv => !(iv in values));\n const newPartialVariables = {\n ...((_this2$partialVariabl = _this2.partialVariables) !== null && _this2$partialVariabl !== void 0 ? _this2$partialVariabl : {}),\n ...values\n };\n const promptDict = {\n ..._this2,\n inputVariables: newInputVariables,\n partialVariables: newPartialVariables\n };\n return new FewShotPromptTemplate(promptDict);\n })();\n }\n /**\n * Formats the prompt with the given values.\n * @param values The values to format the prompt with.\n * @returns A promise that resolves to a string representing the formatted prompt.\n */\n format(values) {\n var _this3 = this;\n return _asyncToGenerator(function* () {\n const allValues = yield _this3.mergePartialAndUserVariables(values);\n const examples = yield _this3.getExamples(allValues);\n const exampleStrings = yield Promise.all(examples.map(example => _this3.examplePrompt.format(example)));\n const template = [_this3.prefix, ...exampleStrings, _this3.suffix].join(_this3.exampleSeparator);\n return renderTemplate(template, _this3.templateFormat, allValues);\n })();\n }\n serialize() {\n if (this.exampleSelector || !this.examples) {\n throw new Error(\"Serializing an example selector is not currently supported\");\n }\n if (this.outputParser !== undefined) {\n throw new Error(\"Serializing an output parser is not currently supported\");\n }\n return {\n _type: this._getPromptType(),\n input_variables: this.inputVariables,\n example_prompt: this.examplePrompt.serialize(),\n example_separator: this.exampleSeparator,\n suffix: this.suffix,\n prefix: this.prefix,\n template_format: this.templateFormat,\n examples: this.examples\n };\n }\n static deserialize(data) {\n return _asyncToGenerator(function* () {\n const {\n example_prompt\n } = data;\n if (!example_prompt) {\n throw new Error(\"Missing example prompt\");\n }\n const examplePrompt = yield PromptTemplate.deserialize(example_prompt);\n let examples;\n if (Array.isArray(data.examples)) {\n examples = data.examples;\n } else {\n throw new Error(\"Invalid examples format. Only list or string are supported.\");\n }\n return new FewShotPromptTemplate({\n inputVariables: data.input_variables,\n examplePrompt,\n examples,\n exampleSeparator: data.example_separator,\n prefix: data.prefix,\n suffix: data.suffix,\n templateFormat: data.template_format\n });\n })();\n }\n}\n/**\n * Chat prompt template that contains few-shot examples.\n * @augments BasePromptTemplateInput\n * @augments FewShotChatMessagePromptTemplateInput\n */\nexport class FewShotChatMessagePromptTemplate extends BaseChatPromptTemplate {\n _getPromptType() {\n return \"few_shot_chat\";\n }\n static lc_name() {\n return \"FewShotChatMessagePromptTemplate\";\n }\n constructor(fields) {\n var _fields$exampleSepara, _fields$prefix, _fields$suffix, _fields$templateForma, _fields$validateTempl;\n super(fields);\n Object.defineProperty(this, \"lc_serializable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: true\n });\n Object.defineProperty(this, \"examples\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"exampleSelector\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"examplePrompt\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"suffix\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: \"\"\n });\n Object.defineProperty(this, \"exampleSeparator\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: \"\\n\\n\"\n });\n Object.defineProperty(this, \"prefix\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: \"\"\n });\n Object.defineProperty(this, \"templateFormat\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: \"f-string\"\n });\n Object.defineProperty(this, \"validateTemplate\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: true\n });\n this.examples = fields.examples;\n this.examplePrompt = fields.examplePrompt;\n this.exampleSeparator = (_fields$exampleSepara = fields.exampleSeparator) !== null && _fields$exampleSepara !== void 0 ? _fields$exampleSepara : \"\\n\\n\";\n this.exampleSelector = fields.exampleSelector;\n this.prefix = (_fields$prefix = fields.prefix) !== null && _fields$prefix !== void 0 ? _fields$prefix : \"\";\n this.suffix = (_fields$suffix = fields.suffix) !== null && _fields$suffix !== void 0 ? _fields$suffix : \"\";\n this.templateFormat = (_fields$templateForma = fields.templateFormat) !== null && _fields$templateForma !== void 0 ? _fields$templateForma : \"f-string\";\n this.validateTemplate = (_fields$validateTempl = fields.validateTemplate) !== null && _fields$validateTempl !== void 0 ? _fields$validateTempl : true;\n if (this.examples !== undefined && this.exampleSelector !== undefined) {\n throw new Error(\"Only one of 'examples' and 'example_selector' should be provided\");\n }\n if (this.examples === undefined && this.exampleSelector === undefined) {\n throw new Error(\"One of 'examples' and 'example_selector' should be provided\");\n }\n if (this.validateTemplate) {\n let totalInputVariables = this.inputVariables;\n if (this.partialVariables) {\n totalInputVariables = totalInputVariables.concat(Object.keys(this.partialVariables));\n }\n checkValidTemplate(this.prefix + this.suffix, this.templateFormat, totalInputVariables);\n }\n }\n getExamples(inputVariables) {\n var _this4 = this;\n return _asyncToGenerator(function* () {\n if (_this4.examples !== undefined) {\n return _this4.examples;\n }\n if (_this4.exampleSelector !== undefined) {\n return _this4.exampleSelector.selectExamples(inputVariables);\n }\n throw new Error(\"One of 'examples' and 'example_selector' should be provided\");\n })();\n }\n /**\n * Formats the list of values and returns a list of formatted messages.\n * @param values The values to format the prompt with.\n * @returns A promise that resolves to a string representing the formatted prompt.\n */\n formatMessages(values) {\n var _this5 = this;\n return _asyncToGenerator(function* () {\n const allValues = yield _this5.mergePartialAndUserVariables(values);\n let examples = yield _this5.getExamples(allValues);\n examples = examples.map(example => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result = {};\n _this5.examplePrompt.inputVariables.forEach(inputVariable => {\n result[inputVariable] = example[inputVariable];\n });\n return result;\n });\n const messages = [];\n for (const example of examples) {\n const exampleMessages = yield _this5.examplePrompt.formatMessages(example);\n messages.push(...exampleMessages);\n }\n return messages;\n })();\n }\n /**\n * Formats the prompt with the given values.\n * @param values The values to format the prompt with.\n * @returns A promise that resolves to a string representing the formatted prompt.\n */\n format(values) {\n var _this6 = this;\n return _asyncToGenerator(function* () {\n const allValues = yield _this6.mergePartialAndUserVariables(values);\n const examples = yield _this6.getExamples(allValues);\n const exampleMessages = yield Promise.all(examples.map(example => _this6.examplePrompt.formatMessages(example)));\n const exampleStrings = exampleMessages.flat().map(message => message.content);\n const template = [_this6.prefix, ...exampleStrings, _this6.suffix].join(_this6.exampleSeparator);\n return renderTemplate(template, _this6.templateFormat, allValues);\n })();\n }\n /**\n * Partially formats the prompt with the given values.\n * @param values The values to partially format the prompt with.\n * @returns A promise that resolves to an instance of `FewShotChatMessagePromptTemplate` with the given values partially formatted.\n */\n partial(values) {\n var _this7 = this;\n return _asyncToGenerator(function* () {\n var _this7$partialVariabl;\n const newInputVariables = _this7.inputVariables.filter(variable => !(variable in values));\n const newPartialVariables = {\n ...((_this7$partialVariabl = _this7.partialVariables) !== null && _this7$partialVariabl !== void 0 ? _this7$partialVariabl : {}),\n ...values\n };\n const promptDict = {\n ..._this7,\n inputVariables: newInputVariables,\n partialVariables: newPartialVariables\n };\n return new FewShotChatMessagePromptTemplate(promptDict);\n })();\n }\n}","map":{"version":3,"names":["BaseStringPromptTemplate","checkValidTemplate","renderTemplate","PromptTemplate","BaseChatPromptTemplate","FewShotPromptTemplate","constructor","input","Object","defineProperty","enumerable","configurable","writable","value","assign","examples","undefined","exampleSelector","Error","validateTemplate","totalInputVariables","inputVariables","partialVariables","concat","keys","prefix","suffix","templateFormat","_getPromptType","lc_name","getExamples","_this","_asyncToGenerator","selectExamples","partial","values","_this2","_this2$partialVariabl","newInputVariables","filter","iv","newPartialVariables","promptDict","format","_this3","allValues","mergePartialAndUserVariables","exampleStrings","Promise","all","map","example","examplePrompt","template","join","exampleSeparator","serialize","outputParser","_type","input_variables","example_prompt","example_separator","template_format","deserialize","data","Array","isArray","FewShotChatMessagePromptTemplate","fields","_fields$exampleSepara","_fields$prefix","_fields$suffix","_fields$templateForma","_fields$validateTempl","_this4","formatMessages","_this5","result","forEach","inputVariable","messages","exampleMessages","push","_this6","flat","message","content","_this7","_this7$partialVariabl","variable"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@langchain/core/dist/prompts/few_shot.js"],"sourcesContent":["import { BaseStringPromptTemplate } from \"./string.js\";\nimport { checkValidTemplate, renderTemplate, } from \"./template.js\";\nimport { PromptTemplate } from \"./prompt.js\";\nimport { BaseChatPromptTemplate, } from \"./chat.js\";\n/**\n * Prompt template that contains few-shot examples.\n * @augments BasePromptTemplate\n * @augments FewShotPromptTemplateInput\n * @example\n * ```typescript\n * const examplePrompt = PromptTemplate.fromTemplate(\n * \"Input: {input}\\nOutput: {output}\",\n * );\n *\n * const exampleSelector = await SemanticSimilarityExampleSelector.fromExamples(\n * [\n * { input: \"happy\", output: \"sad\" },\n * { input: \"tall\", output: \"short\" },\n * { input: \"energetic\", output: \"lethargic\" },\n * { input: \"sunny\", output: \"gloomy\" },\n * { input: \"windy\", output: \"calm\" },\n * ],\n * new OpenAIEmbeddings(),\n * HNSWLib,\n * { k: 1 },\n * );\n *\n * const dynamicPrompt = new FewShotPromptTemplate({\n * exampleSelector,\n * examplePrompt,\n * prefix: \"Give the antonym of every input\",\n * suffix: \"Input: {adjective}\\nOutput:\",\n * inputVariables: [\"adjective\"],\n * });\n *\n * // Format the dynamic prompt with the input 'rainy'\n * console.log(await dynamicPrompt.format({ adjective: \"rainy\" }));\n *\n * ```\n */\nexport class FewShotPromptTemplate extends BaseStringPromptTemplate {\n constructor(input) {\n super(input);\n Object.defineProperty(this, \"lc_serializable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: false\n });\n Object.defineProperty(this, \"examples\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"exampleSelector\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"examplePrompt\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"suffix\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: \"\"\n });\n Object.defineProperty(this, \"exampleSeparator\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: \"\\n\\n\"\n });\n Object.defineProperty(this, \"prefix\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: \"\"\n });\n Object.defineProperty(this, \"templateFormat\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: \"f-string\"\n });\n Object.defineProperty(this, \"validateTemplate\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: true\n });\n Object.assign(this, input);\n if (this.examples !== undefined && this.exampleSelector !== undefined) {\n throw new Error(\"Only one of 'examples' and 'example_selector' should be provided\");\n }\n if (this.examples === undefined && this.exampleSelector === undefined) {\n throw new Error(\"One of 'examples' and 'example_selector' should be provided\");\n }\n if (this.validateTemplate) {\n let totalInputVariables = this.inputVariables;\n if (this.partialVariables) {\n totalInputVariables = totalInputVariables.concat(Object.keys(this.partialVariables));\n }\n checkValidTemplate(this.prefix + this.suffix, this.templateFormat, totalInputVariables);\n }\n }\n _getPromptType() {\n return \"few_shot\";\n }\n static lc_name() {\n return \"FewShotPromptTemplate\";\n }\n async getExamples(inputVariables) {\n if (this.examples !== undefined) {\n return this.examples;\n }\n if (this.exampleSelector !== undefined) {\n return this.exampleSelector.selectExamples(inputVariables);\n }\n throw new Error(\"One of 'examples' and 'example_selector' should be provided\");\n }\n async partial(values) {\n const newInputVariables = this.inputVariables.filter((iv) => !(iv in values));\n const newPartialVariables = {\n ...(this.partialVariables ?? {}),\n ...values,\n };\n const promptDict = {\n ...this,\n inputVariables: newInputVariables,\n partialVariables: newPartialVariables,\n };\n return new FewShotPromptTemplate(promptDict);\n }\n /**\n * Formats the prompt with the given values.\n * @param values The values to format the prompt with.\n * @returns A promise that resolves to a string representing the formatted prompt.\n */\n async format(values) {\n const allValues = await this.mergePartialAndUserVariables(values);\n const examples = await this.getExamples(allValues);\n const exampleStrings = await Promise.all(examples.map((example) => this.examplePrompt.format(example)));\n const template = [this.prefix, ...exampleStrings, this.suffix].join(this.exampleSeparator);\n return renderTemplate(template, this.templateFormat, allValues);\n }\n serialize() {\n if (this.exampleSelector || !this.examples) {\n throw new Error(\"Serializing an example selector is not currently supported\");\n }\n if (this.outputParser !== undefined) {\n throw new Error(\"Serializing an output parser is not currently supported\");\n }\n return {\n _type: this._getPromptType(),\n input_variables: this.inputVariables,\n example_prompt: this.examplePrompt.serialize(),\n example_separator: this.exampleSeparator,\n suffix: this.suffix,\n prefix: this.prefix,\n template_format: this.templateFormat,\n examples: this.examples,\n };\n }\n static async deserialize(data) {\n const { example_prompt } = data;\n if (!example_prompt) {\n throw new Error(\"Missing example prompt\");\n }\n const examplePrompt = await PromptTemplate.deserialize(example_prompt);\n let examples;\n if (Array.isArray(data.examples)) {\n examples = data.examples;\n }\n else {\n throw new Error(\"Invalid examples format. Only list or string are supported.\");\n }\n return new FewShotPromptTemplate({\n inputVariables: data.input_variables,\n examplePrompt,\n examples,\n exampleSeparator: data.example_separator,\n prefix: data.prefix,\n suffix: data.suffix,\n templateFormat: data.template_format,\n });\n }\n}\n/**\n * Chat prompt template that contains few-shot examples.\n * @augments BasePromptTemplateInput\n * @augments FewShotChatMessagePromptTemplateInput\n */\nexport class FewShotChatMessagePromptTemplate extends BaseChatPromptTemplate {\n _getPromptType() {\n return \"few_shot_chat\";\n }\n static lc_name() {\n return \"FewShotChatMessagePromptTemplate\";\n }\n constructor(fields) {\n super(fields);\n Object.defineProperty(this, \"lc_serializable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: true\n });\n Object.defineProperty(this, \"examples\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"exampleSelector\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"examplePrompt\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"suffix\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: \"\"\n });\n Object.defineProperty(this, \"exampleSeparator\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: \"\\n\\n\"\n });\n Object.defineProperty(this, \"prefix\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: \"\"\n });\n Object.defineProperty(this, \"templateFormat\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: \"f-string\"\n });\n Object.defineProperty(this, \"validateTemplate\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: true\n });\n this.examples = fields.examples;\n this.examplePrompt = fields.examplePrompt;\n this.exampleSeparator = fields.exampleSeparator ?? \"\\n\\n\";\n this.exampleSelector = fields.exampleSelector;\n this.prefix = fields.prefix ?? \"\";\n this.suffix = fields.suffix ?? \"\";\n this.templateFormat = fields.templateFormat ?? \"f-string\";\n this.validateTemplate = fields.validateTemplate ?? true;\n if (this.examples !== undefined && this.exampleSelector !== undefined) {\n throw new Error(\"Only one of 'examples' and 'example_selector' should be provided\");\n }\n if (this.examples === undefined && this.exampleSelector === undefined) {\n throw new Error(\"One of 'examples' and 'example_selector' should be provided\");\n }\n if (this.validateTemplate) {\n let totalInputVariables = this.inputVariables;\n if (this.partialVariables) {\n totalInputVariables = totalInputVariables.concat(Object.keys(this.partialVariables));\n }\n checkValidTemplate(this.prefix + this.suffix, this.templateFormat, totalInputVariables);\n }\n }\n async getExamples(inputVariables) {\n if (this.examples !== undefined) {\n return this.examples;\n }\n if (this.exampleSelector !== undefined) {\n return this.exampleSelector.selectExamples(inputVariables);\n }\n throw new Error(\"One of 'examples' and 'example_selector' should be provided\");\n }\n /**\n * Formats the list of values and returns a list of formatted messages.\n * @param values The values to format the prompt with.\n * @returns A promise that resolves to a string representing the formatted prompt.\n */\n async formatMessages(values) {\n const allValues = await this.mergePartialAndUserVariables(values);\n let examples = await this.getExamples(allValues);\n examples = examples.map((example) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result = {};\n this.examplePrompt.inputVariables.forEach((inputVariable) => {\n result[inputVariable] = example[inputVariable];\n });\n return result;\n });\n const messages = [];\n for (const example of examples) {\n const exampleMessages = await this.examplePrompt.formatMessages(example);\n messages.push(...exampleMessages);\n }\n return messages;\n }\n /**\n * Formats the prompt with the given values.\n * @param values The values to format the prompt with.\n * @returns A promise that resolves to a string representing the formatted prompt.\n */\n async format(values) {\n const allValues = await this.mergePartialAndUserVariables(values);\n const examples = await this.getExamples(allValues);\n const exampleMessages = await Promise.all(examples.map((example) => this.examplePrompt.formatMessages(example)));\n const exampleStrings = exampleMessages\n .flat()\n .map((message) => message.content);\n const template = [this.prefix, ...exampleStrings, this.suffix].join(this.exampleSeparator);\n return renderTemplate(template, this.templateFormat, allValues);\n }\n /**\n * Partially formats the prompt with the given values.\n * @param values The values to partially format the prompt with.\n * @returns A promise that resolves to an instance of `FewShotChatMessagePromptTemplate` with the given values partially formatted.\n */\n async partial(values) {\n const newInputVariables = this.inputVariables.filter((variable) => !(variable in values));\n const newPartialVariables = {\n ...(this.partialVariables ?? {}),\n ...values,\n };\n const promptDict = {\n ...this,\n inputVariables: newInputVariables,\n partialVariables: newPartialVariables,\n };\n return new FewShotChatMessagePromptTemplate(promptDict);\n }\n}\n"],"mappings":";AAAA,SAASA,wBAAwB,QAAQ,aAAa;AACtD,SAASC,kBAAkB,EAAEC,cAAc,QAAS,eAAe;AACnE,SAASC,cAAc,QAAQ,aAAa;AAC5C,SAASC,sBAAsB,QAAS,WAAW;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,SAASL,wBAAwB,CAAC;EAChEM,WAAWA,CAACC,KAAK,EAAE;IACf,KAAK,CAACA,KAAK,CAAC;IACZC,MAAM,CAACC,cAAc,CAAC,IAAI,EAAE,iBAAiB,EAAE;MAC3CC,UAAU,EAAE,IAAI;MAChBC,YAAY,EAAE,IAAI;MAClBC,QAAQ,EAAE,IAAI;MACdC,KAAK,EAAE;IACX,CAAC,CAAC;IACFL,MAAM,CAACC,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE;MACpCC,UAAU,EAAE,IAAI;MAChBC,YAAY,EAAE,IAAI;MAClBC,QAAQ,EAAE,IAAI;MACdC,KAAK,EAAE,KAAK;IAChB,CAAC,CAAC;IACFL,MAAM,CAACC,cAAc,CAAC,IAAI,EAAE,iBAAiB,EAAE;MAC3CC,UAAU,EAAE,IAAI;MAChBC,YAAY,EAAE,IAAI;MAClBC,QAAQ,EAAE,IAAI;MACdC,KAAK,EAAE,KAAK;IAChB,CAAC,CAAC;IACFL,MAAM,CAACC,cAAc,CAAC,IAAI,EAAE,eAAe,EAAE;MACzC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