@nine-lab/nine-ai 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { B as BaseStringPromptTemplate, c as checkValidTemplate, r as renderTemplate, P as PromptTemplate } from "./index-D4cmKbX4.js";
1
+ import { B as BaseStringPromptTemplate, c as checkValidTemplate, r as renderTemplate, P as PromptTemplate } from "./index-CHttSLGX.js";
2
2
  class FewShotPromptTemplate extends BaseStringPromptTemplate {
3
3
  constructor(input) {
4
4
  super(input);
@@ -155,4 +155,4 @@ class FewShotPromptTemplate extends BaseStringPromptTemplate {
155
155
  export {
156
156
  FewShotPromptTemplate
157
157
  };
158
- //# sourceMappingURL=few_shot-CixH1aaI.js.map
158
+ //# sourceMappingURL=few_shot-BzbHIKsK.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"few_shot-CixH1aaI.js","sources":["../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"],"names":[],"mappings":";AAwCO,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UAAM,WAAW,CAAC,KAAK,QAAQ,GAAG,gBAAgB,KAAK,MAAM,EAAE,KAAK,KAAK,gBAAgB;AACzF,WAAO,eAAe,UAAU,KAAK,gBAAgB,SAAS;AAAA,EACtE;AAAA,EACI,YAAY;AACR,QAAI,KAAK,mBAAmB,CAAC,KAAK,UAAU;AACxC,YAAM,IAAI,MAAM,4DAA4D;AAAA,IACxF;AACQ,QAAI,KAAK,iBAAiB,QAAW;AACjC,YAAM,IAAI,MAAM,yDAAyD;AAAA,IACrF;AACQ,WAAO;AAAA,MACH,OAAO,KAAK,eAAc;AAAA,MAC1B,iBAAiB,KAAK;AAAA,MACtB,gBAAgB,KAAK,cAAc,UAAS;AAAA,MAC5C,mBAAmB,KAAK;AAAA,MACxB,QAAQ,KAAK;AAAA,MACb,QAAQ,KAAK;AAAA,MACb,iBAAiB,KAAK;AAAA,MACtB,UAAU,KAAK;AAAA,IAC3B;AAAA,EACA;AAAA,EACI,aAAa,YAAY,MAAM;AAC3B,UAAM,EAAE,eAAc,IAAK;AAC3B,QAAI,CAAC,gBAAgB;AACjB,YAAM,IAAI,MAAM,wBAAwB;AAAA,IACpD;AACQ,UAAM,gBAAgB,MAAM,eAAe,YAAY,cAAc;AACrE,QAAI;AACJ,QAAI,MAAM,QAAQ,KAAK,QAAQ,GAAG;AAC9B,iBAAW,KAAK;AAAA,IAC5B,OACa;AACD,YAAM,IAAI,MAAM,6DAA6D;AAAA,IACzF;AACQ,WAAO,IAAI,sBAAsB;AAAA,MAC7B,gBAAgB,KAAK;AAAA,MACrB;AAAA,MACA;AAAA,MACA,kBAAkB,KAAK;AAAA,MACvB,QAAQ,KAAK;AAAA,MACb,QAAQ,KAAK;AAAA,MACb,gBAAgB,KAAK;AAAA,IACjC,CAAS;AAAA,EACT;AACA;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"few_shot-BzbHIKsK.js","sources":["../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"],"names":[],"mappings":";AAwCO,MAAM,8BAA8B,yBAAyB;AAAA,EAChE,YAAY,OAAO;AACf,UAAM,KAAK;AACX,WAAO,eAAe,MAAM,mBAAmB;AAAA,MAC3C,YAAY;AAAA,MACZ,cAAc;AAAA,MACd,UAAU;AAAA,MACV,OAAO;AAAA,IACnB,CAAS;AACD,WAAO,eAAe,MAAM,YAAY;AAAA,MACpC,YAAY;AAAA,MACZ,cAAc;AAAA,MACd,UAAU;AAAA,MACV,OAAO;AAAA,IACnB,CAAS;AACD,WAAO,eAAe,MAAM,mBAAmB;AAAA,MAC3C,YAAY;AAAA,MACZ,cAAc;AAAA,MACd,UAAU;AAAA,MACV,OAAO;AAAA,IACnB,CAAS;AACD,WAAO,eAAe,MAAM,iBAAiB;AAAA,MACzC,YAAY;AAAA,MACZ,cAAc;AAAA,MACd,UAAU;AAAA,MACV,OAAO;AAAA,IACnB,CAAS;AACD,WAAO,eAAe,MAAM,UAAU;AAAA,MAClC,YAAY;AAAA,MACZ,cAAc;AAAA,MACd,UAAU;AAAA,MACV,OAAO;AAAA,IACnB,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I,CAAC,gBAAgB;AACjB,YAAM,IAAI,MAAM,wBAAwB;AAAA,IACpD;AACQ,UAAM,gBAAgB,MAAM,eAAe,YAAY,cAAc;AACrE,QAAI;AACJ,QAAI,MAAM,QAAQ,KAAK,QAAQ,GAAG;AAC9B,iBAAW,KAAK;AAAA,IAC5B,OACa;AACD,YAAM,IAAI,MAAM,6DAA6D;AAAA,IACzF;AACQ,WAAO,IAAI,sBAAsB;AAAA,MAC7B,gBAAgB,KAAK;AAAA,MACrB;AAAA,MACA;AAAA,MACA,kBAAkB,KAAK;AAAA,MACvB,QAAQ,KAAK;AAAA,MACb,QAAQ,KAAK;AAAA,MACb,gBAAgB,KAAK;AAAA,IACjC,CAAS;AAAA,EACT;AACA;","x_google_ignoreList":[0]}
@@ -23105,7 +23105,7 @@ class BasePromptTemplate extends Runnable {
23105
23105
  return PromptTemplate2.deserialize({ ...data, _type: "prompt" });
23106
23106
  }
23107
23107
  case "few_shot": {
23108
- const { FewShotPromptTemplate } = await import("./few_shot-CixH1aaI.js");
23108
+ const { FewShotPromptTemplate } = await import("./few_shot-BzbHIKsK.js");
23109
23109
  return FewShotPromptTemplate.deserialize(data);
23110
23110
  }
23111
23111
  default:
@@ -40560,7 +40560,7 @@ class NineAi extends HTMLElement {
40560
40560
  const textareaText = "나에게 무엇이든 물어봐...";
40561
40561
  this.shadowRoot.innerHTML = `
40562
40562
  <style>
40563
- @import "https://cdn.jsdelivr.net/npm/@nine-lab/nine-ai@${"0.1.5"}/dist/css/nine-ai.css";
40563
+ @import "https://cdn.jsdelivr.net/npm/@nine-lab/nine-ai@${"0.1.6"}/dist/css/nine-ai.css";
40564
40564
  ${this.cssPath ? `@import "${this.cssPath}";` : ""}
40565
40565
  </style>
40566
40566
 
@@ -67450,15 +67450,13 @@ customElements.define("ai-natual-input", aiNatualInput);
67450
67450
  if (typeof window !== "undefined" && !customElements.get("nine-ai")) {
67451
67451
  customElements.define("nine-ai", NineAi);
67452
67452
  }
67453
- const IdeAssi$1 = IdeAssi;
67454
67453
  export {
67455
67454
  BaseStringPromptTemplate as B,
67456
67455
  IdeFetch as I,
67457
67456
  NineAi as N,
67458
67457
  PromptTemplate as P,
67459
67458
  IdeAi as a,
67460
- IdeAssi$1 as b,
67461
67459
  checkValidTemplate as c,
67462
67460
  renderTemplate as r
67463
67461
  };
67464
- //# sourceMappingURL=index-D4cmKbX4.js.map
67462
+ //# sourceMappingURL=index-CHttSLGX.js.map