@nine-lab/nine-ai 0.1.2 → 0.1.4
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.
- package/dist/{few_shot-CsdUyb-S.js → few_shot-BRgFY2uB.js} +2 -2
- package/dist/{few_shot-CsdUyb-S.js.map → few_shot-BRgFY2uB.js.map} +1 -1
- package/dist/{index-bkxU1yQC.js → index-tIkLfn75.js} +12 -12
- package/dist/{index-bkxU1yQC.js.map → index-tIkLfn75.js.map} +1 -1
- package/dist/nine-ai.js +1 -1
- package/dist/nine-ai.umd.cjs +2 -2
- package/dist/nine-ai.umd.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BaseStringPromptTemplate, c as checkValidTemplate, r as renderTemplate, P as PromptTemplate } from "./index-
|
|
1
|
+
import { B as BaseStringPromptTemplate, c as checkValidTemplate, r as renderTemplate, P as PromptTemplate } from "./index-tIkLfn75.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-
|
|
158
|
+
//# sourceMappingURL=few_shot-BRgFY2uB.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"few_shot-CsdUyb-S.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,UA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,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-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;A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AiB,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]}
|
|
@@ -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-
|
|
23108
|
+
const { FewShotPromptTemplate } = await import("./few_shot-BRgFY2uB.js");
|
|
23109
23109
|
return FewShotPromptTemplate.deserialize(data);
|
|
23110
23110
|
}
|
|
23111
23111
|
default:
|
|
@@ -23941,7 +23941,7 @@ __privateAdd(_IdeFetch, _request2, (method, url, data = {}) => {
|
|
|
23941
23941
|
options.body = JSON.stringify(data);
|
|
23942
23942
|
}
|
|
23943
23943
|
return fetch(url, options).then((res) => {
|
|
23944
|
-
if (url !== "/
|
|
23944
|
+
if (url !== "/nine-ai/source/query") ninegrid.loading.hide();
|
|
23945
23945
|
if (!res.ok) {
|
|
23946
23946
|
return res.text().then((text) => {
|
|
23947
23947
|
throw new Error(`API 오류 (${res.status}): ${text}`);
|
|
@@ -39752,7 +39752,7 @@ class IdeAi {
|
|
|
39752
39752
|
return arr2;
|
|
39753
39753
|
});
|
|
39754
39754
|
__privateAdd(this, _getTableList, async () => {
|
|
39755
|
-
const response = await fetch("/
|
|
39755
|
+
const response = await fetch("/nine-ai/meta/selectTableList", {
|
|
39756
39756
|
method: "POST",
|
|
39757
39757
|
headers: { "Content-Type": "application/json" },
|
|
39758
39758
|
body: JSON.stringify({
|
|
@@ -39762,7 +39762,7 @@ class IdeAi {
|
|
|
39762
39762
|
return await response.json();
|
|
39763
39763
|
});
|
|
39764
39764
|
__privateAdd(this, _getColumnInfo, async (tables) => {
|
|
39765
|
-
const response = await fetch("/
|
|
39765
|
+
const response = await fetch("/nine-ai/meta/selectColumnInfo", {
|
|
39766
39766
|
method: "POST",
|
|
39767
39767
|
headers: { "Content-Type": "application/json" },
|
|
39768
39768
|
body: JSON.stringify({
|
|
@@ -39818,7 +39818,7 @@ class IdeAi {
|
|
|
39818
39818
|
if (src.endsWith("```")) {
|
|
39819
39819
|
src = src.slice(0, -3);
|
|
39820
39820
|
}
|
|
39821
|
-
await api$1.post(`/
|
|
39821
|
+
await api$1.post(`/nine-ai/source/generateTmplFile`, {
|
|
39822
39822
|
basePath: `${__privateGet(this, _parent).settings.beProjectName}/tmpl`,
|
|
39823
39823
|
fileNm: generateFileName,
|
|
39824
39824
|
contents: src
|
|
@@ -39905,7 +39905,7 @@ class IdeAi {
|
|
|
39905
39905
|
}
|
|
39906
39906
|
const srcPath = __privateGet(this, _getSourcePath).call(this, href);
|
|
39907
39907
|
console.log(where, srcPath);
|
|
39908
|
-
const src = await api$1.post("/
|
|
39908
|
+
const src = await api$1.post("/nine-ai/source/read", srcPath);
|
|
39909
39909
|
console.log(src);
|
|
39910
39910
|
progressMessageInstance.updateProgress("prepare2", "completed");
|
|
39911
39911
|
const columnInfo = await __privateGet(this, _getColumnInfo).call(this, where.table);
|
|
@@ -40074,7 +40074,7 @@ class IdeAi {
|
|
|
40074
40074
|
const title = el.getAttribute("title");
|
|
40075
40075
|
const srcPath = __privateGet(this, _getSourcePath).call(this, href);
|
|
40076
40076
|
console.log(srcPath);
|
|
40077
|
-
const src = await api$1.post("/
|
|
40077
|
+
const src = await api$1.post("/nine-ai/source/read", srcPath);
|
|
40078
40078
|
const where = await __privateGet(this, _where).call(this, `${title}에서 ${userPrompt}`, [{ url: href, title }], await __privateGet(this, _getTableList).call(this));
|
|
40079
40079
|
progressMessageInstance.updateProgress("prepare2", "completed");
|
|
40080
40080
|
console.log(where);
|
|
@@ -40209,7 +40209,7 @@ class IdeAi {
|
|
|
40209
40209
|
const title = el.getAttribute("title");
|
|
40210
40210
|
const srcPath = __privateGet(this, _getSourcePath).call(this, href);
|
|
40211
40211
|
console.log(srcPath);
|
|
40212
|
-
const src = await api$1.post("/
|
|
40212
|
+
const src = await api$1.post("/nine-ai/source/read", srcPath);
|
|
40213
40213
|
const where = await __privateGet(this, _where).call(this, `${title}에서 ${userPrompt}`, [{ url: href, title }], await __privateGet(this, _getTableList).call(this));
|
|
40214
40214
|
progressMessageInstance.updateProgress("prepare2", "completed");
|
|
40215
40215
|
console.log(where);
|
|
@@ -40387,7 +40387,7 @@ __publicField(IdeAi, "generateWhereCause", async (xmlPath, queryId, userPrompt,
|
|
|
40387
40387
|
throw error;
|
|
40388
40388
|
}
|
|
40389
40389
|
};
|
|
40390
|
-
const res = await api$1.post("/
|
|
40390
|
+
const res = await api$1.post("/nine-ai/source/query", {
|
|
40391
40391
|
xmlPath,
|
|
40392
40392
|
queryId
|
|
40393
40393
|
});
|
|
@@ -40584,7 +40584,7 @@ class IdeAssi extends HTMLElement {
|
|
|
40584
40584
|
this.shadowRoot.querySelector(".collapse-icon").addEventListener("click", __privateGet(this, _toggleCollapseHandler));
|
|
40585
40585
|
this.shadowRoot.querySelectorAll(".menu-icon").forEach((el) => el.addEventListener("click", __privateGet(this, _menuClickHandler)));
|
|
40586
40586
|
setTimeout(() => {
|
|
40587
|
-
api.post(`/
|
|
40587
|
+
api.post(`/nine-ai/prompt/dir`, {
|
|
40588
40588
|
feProjectName: this.settings.feProjectName
|
|
40589
40589
|
}).then((res) => {
|
|
40590
40590
|
__privateGet(this, _ai).prompt = res;
|
|
@@ -41139,7 +41139,7 @@ class IdeDiffPopup extends HTMLElement {
|
|
|
41139
41139
|
contents: diff.getContents()
|
|
41140
41140
|
});
|
|
41141
41141
|
}
|
|
41142
|
-
api$1.post(`/
|
|
41142
|
+
api$1.post(`/nine-ai/source/generateRealFile`, { list: params }).then((res) => {
|
|
41143
41143
|
ninegrid.alert("소스를 변경하였습니다.");
|
|
41144
41144
|
});
|
|
41145
41145
|
});
|
|
@@ -67458,4 +67458,4 @@ export {
|
|
|
67458
67458
|
defineCustomElements as d,
|
|
67459
67459
|
renderTemplate as r
|
|
67460
67460
|
};
|
|
67461
|
-
//# sourceMappingURL=index-
|
|
67461
|
+
//# sourceMappingURL=index-tIkLfn75.js.map
|