@nine-lab/nine-ai 0.1.4 → 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 +1 @@
1
- {"version":3,"file":"few_shot-BRgFY2uB.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,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K,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,CAAS;AACD,WAAO,eAAe,MAAM,oBAAoB;AAAA,MAC5C,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,CAAS;AACD,WAAO,eAAe,MAAM,kBAAkB;AAAA,MAC1C,YAAY;AAAA,MACZ,cAAc;AAAA,MACd,UAAU;AAAA,MACV,OAAO;AAAA,IACnB,CAAS;AACD,WAAO,eAAe,MAAM,oBAAoB;AAAA,MAC5C,YAAY;A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KAAK;AAAA,IACjC,CAAS;AAAA,EACT;AACA;","x_google_ignoreList":[0]}
@@ -8,7 +8,7 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
8
8
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
9
9
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
10
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
- var _BASE_URL, _request2, _API_URL, _SCHEMA, _model, _parent, _createModel, _getMenuInfo, _getTableList, _getColumnInfo, _invoke, _what, _where, _generateTmplFile, _findFirstEmptyDetailWrapper, _findActiveDetailWrapperIndex, _getSourcePath, _generateSource, _generateDetailSource, _modifyDetailSource, _ing, _ai, _config, _loadLocalSettings, _saveLocalSettings, _init, _keydownHandler, _toggleCollapseHandler, _menuClickHandler, _init2, _tips, _currentTipIndex, _currentImageIndex, _tipIntervalId, _imageIntervalId, _tipDisplayDuration, _imageDisplayDuration, _ideLoadingTipsInstance, _tipsUrl, _tipCategory, _init3, _changedSource, _init4, _apply, _asisEditorView, _tobeEditorView, _asisEditorEl, _tobeEditorEl, _languageCompartment, _isScrollSyncActive, _initCodeMirror, _setupScrollSync, _applyDiffDecorations, _apiKey, _xmlPath, _queryId, _selectFunc, _target, _keyDownHandler, _init5;
11
+ var _BASE_URL, _request2, _API_URL, _SCHEMA, _model, _parent, _createModel, _getMenuInfo, _getTableList, _getColumnInfo, _invoke, _what, _where, _generateTmplFile, _findFirstEmptyDetailWrapper, _findActiveDetailWrapperIndex, _getSourcePath, _generateSource, _generateDetailSource, _modifyDetailSource, _ing, _ai, _initLayout, _config, _loadLocalSettings, _saveLocalSettings, _init, _keydownHandler, _toggleCollapseHandler, _menuClickHandler, _init2, _tips, _currentTipIndex, _currentImageIndex, _tipIntervalId, _imageIntervalId, _tipDisplayDuration, _imageDisplayDuration, _ideLoadingTipsInstance, _tipsUrl, _tipCategory, _init3, _changedSource, _init4, _apply, _asisEditorView, _tobeEditorView, _asisEditorEl, _tobeEditorEl, _languageCompartment, _isScrollSyncActive, _initCodeMirror, _setupScrollSync, _applyDiffDecorations, _apiKey, _xmlPath, _queryId, _selectFunc, _target, _keyDownHandler, _init5;
12
12
  import ninegrid from "ninegrid2";
13
13
  var util;
14
14
  (function(util2) {
@@ -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-BRgFY2uB.js");
23108
+ const { FewShotPromptTemplate } = await import("./few_shot-BzbHIKsK.js");
23109
23109
  return FewShotPromptTemplate.deserialize(data);
23110
23110
  }
23111
23111
  default:
@@ -40549,13 +40549,65 @@ __publicField2(_Fetch, "post", (url, data = {}) => {
40549
40549
  });
40550
40550
  let Fetch = _Fetch;
40551
40551
  const api = Fetch;
40552
- class IdeAssi extends HTMLElement {
40552
+ class NineAi extends HTMLElement {
40553
40553
  constructor() {
40554
40554
  super();
40555
40555
  __privateAdd(this, _ing, false);
40556
40556
  __privateAdd(this, _ai);
40557
40557
  __publicField(this, "settings");
40558
40558
  __publicField(this, "config");
40559
+ __privateAdd(this, _initLayout, () => {
40560
+ const textareaText = "나에게 무엇이든 물어봐...";
40561
+ this.shadowRoot.innerHTML = `
40562
+ <style>
40563
+ @import "https://cdn.jsdelivr.net/npm/@nine-lab/nine-ai@${"0.1.6"}/dist/css/nine-ai.css";
40564
+ ${this.cssPath ? `@import "${this.cssPath}";` : ""}
40565
+ </style>
40566
+
40567
+ <div class="wrapper">
40568
+ <ide-assi-settings></ide-assi-settings>
40569
+
40570
+ <div class="container">
40571
+ <div class="head">
40572
+ <div class="logo"><span></span></div>
40573
+ </div>
40574
+ <nx-ai-chat></nx-ai-chat>
40575
+ <div class="foot">
40576
+ <div class="apply-src">
40577
+ <div>
40578
+ <input type="checkbox" id="mybatis" name="mybatis" value="Y" checked />
40579
+ <label for="mybatis">MyBatis</label>
40580
+ </div>
40581
+ <div>
40582
+ <input type="checkbox" id="service" name="service" value="Y" checked />
40583
+ <label for="service">Service</label>
40584
+ </div>
40585
+ <div>
40586
+ <input type="checkbox" id="controller" name="controller" value="Y" checked />
40587
+ <label for="controller">Controller</label>
40588
+ </div>
40589
+ <div>
40590
+ <input type="checkbox" id="javascript" name="javascript" value="Y" checked />
40591
+ <label for="javascript">JavaScript</label>
40592
+ </div>
40593
+ </div>
40594
+ <textarea name="ask" id="q" name="q" rows="4" placeholder="${textareaText}"></textarea>
40595
+ </div>
40596
+ </div>
40597
+ <div class="menu">
40598
+ <div class="collapse-icon"></div>
40599
+ <div class="menu-icon menu-filter active"></div>
40600
+ <div class="menu-icon menu-general"></div>
40601
+ <div class="menu-icon menu-setting"></div>
40602
+ </div>
40603
+ </div>
40604
+
40605
+ <div class="expand-icon"></div>
40606
+ `;
40607
+ requestAnimationFrame(() => {
40608
+ __privateGet(this, _init).call(this);
40609
+ });
40610
+ });
40559
40611
  __privateAdd(this, _config, async () => {
40560
40612
  this.config = await api.post("/nine-ai/config/get");
40561
40613
  });
@@ -40646,60 +40698,12 @@ class IdeAssi extends HTMLElement {
40646
40698
  __privateSet(this, _ai, new IdeAi(this));
40647
40699
  }
40648
40700
  connectedCallback() {
40649
- const textareaText = "나에게 무엇이든 물어봐...";
40650
- this.shadowRoot.innerHTML = `
40651
- <style>
40652
- @import "https://cdn.jsdelivr.net/npm/ninegrid@${ninegrid.version}/dist/css/ideAssi.css";
40653
- ${ninegrid.getCustomPath(this, "ideAssi.css")}
40654
- </style>
40655
-
40656
- <div class="wrapper">
40657
- <ide-assi-settings></ide-assi-settings>
40658
-
40659
- <div class="container">
40660
- <div class="head">
40661
- <div class="logo"><span></span></div>
40662
- </div>
40663
- <nx-ai-chat></nx-ai-chat>
40664
- <div class="foot">
40665
- <div class="apply-src">
40666
- <div>
40667
- <input type="checkbox" id="mybatis" name="mybatis" value="Y" checked />
40668
- <label for="mybatis">MyBatis</label>
40669
- </div>
40670
- <div>
40671
- <input type="checkbox" id="service" name="service" value="Y" checked />
40672
- <label for="service">Service</label>
40673
- </div>
40674
- <div>
40675
- <input type="checkbox" id="controller" name="controller" value="Y" checked />
40676
- <label for="controller">Controller</label>
40677
- </div>
40678
- <div>
40679
- <input type="checkbox" id="javascript" name="javascript" value="Y" checked />
40680
- <label for="javascript">JavaScript</label>
40681
- </div>
40682
- </div>
40683
- <textarea name="ask" id="q" name="q" rows="4" placeholder="${textareaText}"></textarea>
40684
- </div>
40685
- </div>
40686
- <div class="menu">
40687
- <div class="collapse-icon"></div>
40688
- <div class="menu-icon menu-filter active"></div>
40689
- <div class="menu-icon menu-general"></div>
40690
- <div class="menu-icon menu-setting"></div>
40691
- </div>
40692
- </div>
40693
-
40694
- <div class="expand-icon"></div>
40695
- `;
40696
- requestAnimationFrame(() => {
40697
- __privateGet(this, _init).call(this);
40698
- });
40701
+ __privateGet(this, _initLayout).call(this);
40699
40702
  }
40700
40703
  }
40701
40704
  _ing = new WeakMap();
40702
40705
  _ai = new WeakMap();
40706
+ _initLayout = new WeakMap();
40703
40707
  _config = new WeakMap();
40704
40708
  _loadLocalSettings = new WeakMap();
40705
40709
  _saveLocalSettings = new WeakMap();
@@ -40707,7 +40711,7 @@ _init = new WeakMap();
40707
40711
  _keydownHandler = new WeakMap();
40708
40712
  _toggleCollapseHandler = new WeakMap();
40709
40713
  _menuClickHandler = new WeakMap();
40710
- customElements.define("nine-ai", IdeAssi);
40714
+ customElements.define("nine-ai", NineAi);
40711
40715
  class ideAssiSettings extends HTMLElement {
40712
40716
  constructor() {
40713
40717
  super();
@@ -67443,19 +67447,16 @@ _target = new WeakMap();
67443
67447
  _keyDownHandler = new WeakMap();
67444
67448
  _init5 = new WeakMap();
67445
67449
  customElements.define("ai-natual-input", aiNatualInput);
67446
- function defineCustomElements() {
67447
- if (!customElements.get("nine-ai")) {
67448
- customElements.define("nine-ai", IdeAssi);
67449
- }
67450
+ if (typeof window !== "undefined" && !customElements.get("nine-ai")) {
67451
+ customElements.define("nine-ai", NineAi);
67450
67452
  }
67451
67453
  export {
67452
67454
  BaseStringPromptTemplate as B,
67453
- IdeAssi as I,
67455
+ IdeFetch as I,
67456
+ NineAi as N,
67454
67457
  PromptTemplate as P,
67455
- IdeFetch as a,
67456
- IdeAi as b,
67458
+ IdeAi as a,
67457
67459
  checkValidTemplate as c,
67458
- defineCustomElements as d,
67459
67460
  renderTemplate as r
67460
67461
  };
67461
- //# sourceMappingURL=index-tIkLfn75.js.map
67462
+ //# sourceMappingURL=index-CHttSLGX.js.map