@jeliq/app-sdk-llm 1.2.2 → 1.2.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/lib/commonjs/controllers/genStructuredOutputs.js +128 -16
- package/lib/commonjs/controllers/genStructuredOutputs.js.map +1 -1
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/templates/ShouldMustTemplate.js +21 -24
- package/lib/commonjs/templates/ShouldMustTemplate.js.map +1 -1
- package/lib/commonjs/utils/createGetLLM.js +79 -8
- package/lib/commonjs/utils/createGetLLM.js.map +1 -1
- package/lib/module/controllers/genStructuredOutputs.js +130 -18
- package/lib/module/controllers/genStructuredOutputs.js.map +1 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/templates/ShouldMustTemplate.js +21 -24
- package/lib/module/templates/ShouldMustTemplate.js.map +1 -1
- package/lib/module/utils/createGetLLM.js +79 -8
- package/lib/module/utils/createGetLLM.js.map +1 -1
- package/lib/typescript/src/controllers/genStructuredOutputs.d.ts +3 -2
- package/lib/typescript/src/controllers/genStructuredOutputs.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/templates/ShouldMustTemplate.d.ts.map +1 -1
- package/lib/typescript/src/utils/createGetLLM.d.ts.map +1 -1
- package/package.json +3 -2
|
@@ -5,8 +5,52 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = genStructuredOutputs;
|
|
7
7
|
var _ai = require("ai");
|
|
8
|
+
var _zodToJsonSchema = require("zod-to-json-schema");
|
|
8
9
|
var _ShouldMustTemplate = _interopRequireDefault(require("../templates/ShouldMustTemplate"));
|
|
9
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
const zodToJsonSchema = schema => (0, _zodToJsonSchema.zodToJsonSchema)(schema);
|
|
12
|
+
const tryParseJson = text => {
|
|
13
|
+
try {
|
|
14
|
+
return {
|
|
15
|
+
value: JSON.parse(text),
|
|
16
|
+
raw: text
|
|
17
|
+
};
|
|
18
|
+
} catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const parseJsonFromText = text => {
|
|
23
|
+
var _tryParseJson;
|
|
24
|
+
const lines = text.replace(/\r\n/g, "\n").replace(/\r/g, "\n").split("\n");
|
|
25
|
+
|
|
26
|
+
// 1) 最初の ```json 行を探す(行頭にあることを要求)
|
|
27
|
+
let startLine = -1;
|
|
28
|
+
for (let i = 0; i < lines.length; i++) {
|
|
29
|
+
const line = lines[i];
|
|
30
|
+
// 例: ```json, ```JSON, ```json , ```json something
|
|
31
|
+
if (/^\s*```json\b/i.test(line)) {
|
|
32
|
+
startLine = i;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (startLine === -1) throw new Error("Failed to parse JSON from model output.");
|
|
37
|
+
|
|
38
|
+
// 2) 最後の 行頭 ``` 行を探す(最後に出てくるやつ)
|
|
39
|
+
let endLine = -1;
|
|
40
|
+
for (let i = lines.length - 1; i > startLine; i--) {
|
|
41
|
+
if (/^\s*```/.test(lines[i])) {
|
|
42
|
+
endLine = i;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (endLine === -1) throw new Error("Failed to parse JSON from model output.");
|
|
47
|
+
const blockLines = lines.slice(startLine, endLine + 1);
|
|
48
|
+
const innerLines = lines.slice(startLine + 1, endLine);
|
|
49
|
+
return {
|
|
50
|
+
value: ((_tryParseJson = tryParseJson(innerLines.join("\n"))) === null || _tryParseJson === void 0 ? void 0 : _tryParseJson.value) ?? null,
|
|
51
|
+
raw: blockLines.join("\n")
|
|
52
|
+
};
|
|
53
|
+
};
|
|
10
54
|
async function genStructuredOutputs(context, taskName, template, args, options) {
|
|
11
55
|
if (!context) {
|
|
12
56
|
throw new Error("context is not set");
|
|
@@ -14,33 +58,101 @@ async function genStructuredOutputs(context, taskName, template, args, options)
|
|
|
14
58
|
if (!(context !== null && context !== void 0 && context.getLLM)) {
|
|
15
59
|
throw new Error("getLLM is not set");
|
|
16
60
|
}
|
|
17
|
-
const
|
|
61
|
+
const inputDefs = Object.keys(template.inputDef).map(key => ({
|
|
18
62
|
name: key,
|
|
19
63
|
type: template.inputDef[key].type,
|
|
20
64
|
description: template.inputDef[key].description
|
|
21
|
-
}))
|
|
65
|
+
}));
|
|
22
66
|
const promptArgs = Object.entries(args).reduce((acc, [key, value]) => {
|
|
23
67
|
acc[key] = value ?? "";
|
|
24
68
|
return acc;
|
|
25
69
|
}, {});
|
|
26
|
-
|
|
27
|
-
|
|
70
|
+
let outputSchemaJson = "";
|
|
71
|
+
try {
|
|
72
|
+
outputSchemaJson = JSON.stringify(zodToJsonSchema(template.outputSchema));
|
|
73
|
+
} catch (e) {
|
|
74
|
+
throw new Error(`Failed to convert output schema to JSON Schema: ${e instanceof Error ? e.message : String(e)}`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Add outputFormat input definition
|
|
78
|
+
const mustSection = [...(template.mustSection ?? [])];
|
|
79
|
+
mustSection.push({
|
|
80
|
+
no: mustSection.length + 1,
|
|
81
|
+
title: "outputFormat",
|
|
82
|
+
content: `You must format your output as a JSON value that adheres to a given "JSON Schema" instance with a markdown code block.
|
|
83
|
+
|
|
84
|
+
For example, the output format is:
|
|
85
|
+
\`\`\`json
|
|
86
|
+
{"properties": {"foo": {"description": "a list of test words", "type": "array", "items": {"type": "string"}}}, "required": ["foo"]}
|
|
87
|
+
\`\`\`
|
|
88
|
+
|
|
89
|
+
Then, you must return the following:
|
|
90
|
+
----- Begin of Output Example -----
|
|
91
|
+
\`\`\`json
|
|
92
|
+
{
|
|
93
|
+
"foo": ["bar", "baz"]
|
|
94
|
+
}
|
|
95
|
+
\`\`\`
|
|
96
|
+
----- End of Output Example -----
|
|
97
|
+
|
|
98
|
+
Do NOT ouput anything other than the JSON value with markdown code block.
|
|
99
|
+
Your output will be parsed and type-checked according to the provided schema instance, so make sure all fields in your output match the schema exactly and there are no trailing commas!
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
Here is the JSON Schema instance your output must adhere to. Include the enclosing markdown codeblock:
|
|
103
|
+
|
|
104
|
+
\`\`\`json
|
|
105
|
+
${outputSchemaJson}
|
|
106
|
+
\`\`\``
|
|
107
|
+
});
|
|
108
|
+
const promptTemplate = await (0, _ShouldMustTemplate.default)(inputDefs, template.summary, template.shouldSection, mustSection, template.example, template.partialVars);
|
|
109
|
+
const model = context.getLLM(taskName, {
|
|
28
110
|
model: options === null || options === void 0 ? void 0 : options.model,
|
|
29
111
|
temperature: options === null || options === void 0 ? void 0 : options.temperature,
|
|
30
112
|
reasoningEffort: options === null || options === void 0 ? void 0 : options.reasoningEffort,
|
|
113
|
+
verbosityLevel: options === null || options === void 0 ? void 0 : options.verbosityLevel,
|
|
31
114
|
timeout: options === null || options === void 0 ? void 0 : options.timeout
|
|
32
115
|
});
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
116
|
+
const maxParseRetries = (options === null || options === void 0 ? void 0 : options.maxRetries) ?? 3;
|
|
117
|
+
const buildCorrectionPrompt = errorMessage => ["The previous output could not be parsed or validated.", `Error: ${errorMessage}`, "Please return only a JSON value wrapped in a markdown ```json code block that matches the schema.", "Do not include any other text."].join("\n");
|
|
118
|
+
let lastErrorMessage = null;
|
|
119
|
+
let lastText = "";
|
|
120
|
+
for (let attempt = 0; attempt <= maxParseRetries; attempt++) {
|
|
121
|
+
const messages = await promptTemplate.formatMessages(promptArgs);
|
|
122
|
+
|
|
123
|
+
// Add correction prompt if this is a retry
|
|
124
|
+
if (attempt > 0) {
|
|
125
|
+
messages.push({
|
|
126
|
+
role: "assistant",
|
|
127
|
+
content: lastText
|
|
128
|
+
});
|
|
129
|
+
messages.push({
|
|
130
|
+
role: "user",
|
|
131
|
+
content: buildCorrectionPrompt(lastErrorMessage ?? "Unknown error")
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
const {
|
|
135
|
+
text
|
|
136
|
+
} = await (0, _ai.generateText)({
|
|
137
|
+
model,
|
|
138
|
+
messages,
|
|
139
|
+
maxRetries: options !== null && options !== void 0 && options.maxRetries ? Math.max(0, options.maxRetries - attempt) : undefined
|
|
140
|
+
});
|
|
141
|
+
try {
|
|
142
|
+
const parsed = parseJsonFromText(text);
|
|
143
|
+
const parsedResult = template.outputSchema.safeParse(parsed.value);
|
|
144
|
+
if (parsedResult.success) {
|
|
145
|
+
return parsedResult.data;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// ✅ ここは「JSONは正しいが schema 違反」
|
|
149
|
+
lastErrorMessage = parsedResult.error.message;
|
|
150
|
+
} catch (e) {
|
|
151
|
+
// ✅ ここは「JSON抽出/JSON構文がダメ」
|
|
152
|
+
lastErrorMessage = e instanceof Error ? e.message : String(e);
|
|
153
|
+
}
|
|
154
|
+
lastText = text;
|
|
155
|
+
}
|
|
156
|
+
throw new Error(`Structured output validation failed after ${maxParseRetries + 1} attempts: ${lastErrorMessage ?? "Unknown error"}`);
|
|
45
157
|
}
|
|
46
158
|
//# sourceMappingURL=genStructuredOutputs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_ai","require","_ShouldMustTemplate","_interopRequireDefault","e","__esModule","default","genStructuredOutputs","context","taskName","template","args","options","
|
|
1
|
+
{"version":3,"names":["_ai","require","_zodToJsonSchema","_ShouldMustTemplate","_interopRequireDefault","e","__esModule","default","zodToJsonSchema","schema","zodToJsonSchemaRaw","tryParseJson","text","value","JSON","parse","raw","parseJsonFromText","_tryParseJson","lines","replace","split","startLine","i","length","line","test","Error","endLine","blockLines","slice","innerLines","join","genStructuredOutputs","context","taskName","template","args","options","getLLM","inputDefs","Object","keys","inputDef","map","key","name","type","description","promptArgs","entries","reduce","acc","outputSchemaJson","stringify","outputSchema","message","String","mustSection","push","no","title","content","promptTemplate","createShouldMustTemplate","summary","shouldSection","example","partialVars","model","temperature","reasoningEffort","verbosityLevel","timeout","maxParseRetries","maxRetries","buildCorrectionPrompt","errorMessage","lastErrorMessage","lastText","attempt","messages","formatMessages","role","generateText","Math","max","undefined","parsed","parsedResult","safeParse","success","data","error"],"sourceRoot":"../../../src","sources":["controllers/genStructuredOutputs.ts"],"mappings":";;;;;;AACA,IAAAA,GAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAGA,IAAAE,mBAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAuE,SAAAG,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AA4BvE,MAAMG,eAAe,GAAIC,MAAkB,IACvC,IAACC,gCAAkB,EAA+CD,MAAM,CAAC;AAE7E,MAAME,YAAY,GAAIC,IAAY,IAAwB;EACtD,IAAI;IACA,OAAO;MAAEC,KAAK,EAAEC,IAAI,CAACC,KAAK,CAACH,IAAI,CAAC;MAAEI,GAAG,EAAEJ;IAAK,CAAC;EACjD,CAAC,CAAC,MAAM;IACJ,OAAO,IAAI;EACf;AACJ,CAAC;AAED,MAAMK,iBAAiB,GAAIL,IAAY,IAAiB;EAAA,IAAAM,aAAA;EACpD,MAAMC,KAAK,GAAGP,IAAI,CAACQ,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAACA,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAACC,KAAK,CAAC,IAAI,CAAC;;EAE1E;EACA,IAAIC,SAAS,GAAG,CAAC,CAAC;EAClB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGJ,KAAK,CAACK,MAAM,EAAED,CAAC,EAAE,EAAE;IACn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Object.defineProperty(exports, "ModelNameAlias", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _types.ModelNameAlias;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "createGetLLM", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function () {
|
|
@@ -31,5 +37,6 @@ var _ShouldMustTemplate = _interopRequireDefault(require("./templates/ShouldMust
|
|
|
31
37
|
var _createGetLLM = _interopRequireDefault(require("./utils/createGetLLM"));
|
|
32
38
|
var _genJSON = _interopRequireDefault(require("./controllers/genJSON"));
|
|
33
39
|
var _genStructuredOutputs = _interopRequireDefault(require("./controllers/genStructuredOutputs"));
|
|
40
|
+
var _types = require("./types");
|
|
34
41
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
35
42
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_ShouldMustTemplate","_interopRequireDefault","require","_createGetLLM","_genJSON","_genStructuredOutputs","e","__esModule","default"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_ShouldMustTemplate","_interopRequireDefault","require","_createGetLLM","_genJSON","_genStructuredOutputs","_types","e","__esModule","default"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,QAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,qBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAAyC,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
|
|
@@ -34,7 +34,12 @@ async function resolvePartialVars(partialVars) {
|
|
|
34
34
|
return Object.fromEntries(entries);
|
|
35
35
|
}
|
|
36
36
|
function replaceTemplateVariables(template, values) {
|
|
37
|
-
return template.replace(getVariableRegex(), (_, variable) =>
|
|
37
|
+
return template.replace(getVariableRegex(), (_, variable) => {
|
|
38
|
+
if (Object.prototype.hasOwnProperty.call(values, variable)) {
|
|
39
|
+
return values[variable] ?? "";
|
|
40
|
+
}
|
|
41
|
+
return `[${variable}](#${variable})`;
|
|
42
|
+
});
|
|
38
43
|
}
|
|
39
44
|
async function createShouldMustTemplate(inputDef, summary, shouldSection, mustSection, example, partialVars) {
|
|
40
45
|
const shouldSectionPrompt = (() => {
|
|
@@ -62,49 +67,41 @@ async function createShouldMustTemplate(inputDef, summary, shouldSection, mustSe
|
|
|
62
67
|
const exampleSectionBody = example.map(elem => `## (c${elem.no}) ${elem.title}\n${elem.content}`).join("\n\n");
|
|
63
68
|
return `# Example\n\n${exampleSectionBody}`;
|
|
64
69
|
})();
|
|
65
|
-
const allSectionContent = [(shouldSection === null || shouldSection === void 0 ? void 0 : shouldSection.map(s => s.content || "").join(" ")) || "", (mustSection === null || mustSection === void 0 ? void 0 : mustSection.map(s => s.content || "").join(" ")) || "", (example === null || example === void 0 ? void 0 : example.map(s => s.content || "").join(" ")) || "", summary].join(" ");
|
|
66
|
-
const usedVariables = extractVariables(allSectionContent);
|
|
67
|
-
const definedInputVariables = inputDef.map(elem => elem.name);
|
|
68
|
-
const definedPartialVariables = Object.keys(partialVars || {});
|
|
69
|
-
const definedVariables = [...definedInputVariables, ...definedPartialVariables, "outputFormat"];
|
|
70
|
-
const undefinedVariables = usedVariables.filter(variable => !definedVariables.includes(variable));
|
|
71
|
-
if (undefinedVariables.length > 0) {
|
|
72
|
-
console.warn(`[ShouldMustTemplate] Warning: Found ${undefinedVariables.length} undefined variable(s) in template sections: [${undefinedVariables.join(", ")}]. These variables have been automatically added to the template.`);
|
|
73
|
-
}
|
|
74
|
-
const autoGeneratedVariablesSection = undefinedVariables.length > 0 ? `\n\n# Auto-Generated Variables\n\n${undefinedVariables.map(variable => `## ${variable}\n{${variable}}`).join("\n\n")}` : "";
|
|
75
70
|
const systemPrompt = [summary, shouldSectionPrompt, mustSectionPrompt, exampleSectionPrompt].filter(Boolean).join("\n\n");
|
|
76
|
-
const
|
|
77
|
-
const imageInputDefs = inputDef.filter(elem => elem.type === "imageDataURL");
|
|
78
|
-
const systemTemplate = [systemPrompt, "{outputFormat}"].filter(Boolean).join("\n\n").trim();
|
|
79
|
-
const userTextTemplate = [stringInputPromptTemplate, autoGeneratedVariablesSection].filter(Boolean).join("\n\n").trim();
|
|
71
|
+
const systemTemplate = [systemPrompt].filter(Boolean).join("\n\n").trim();
|
|
80
72
|
return {
|
|
81
73
|
async formatMessages(args) {
|
|
82
|
-
const resolvedPartialVars = await resolvePartialVars(partialVars || {});
|
|
83
74
|
const mergedArgs = Object.entries(args || {}).reduce((acc, [key, value]) => {
|
|
84
75
|
acc[key] = value ?? "";
|
|
85
76
|
return acc;
|
|
86
77
|
}, {});
|
|
78
|
+
const resolvedPartialVars = await resolvePartialVars(partialVars || {});
|
|
87
79
|
const templateValues = {
|
|
88
80
|
...mergedArgs,
|
|
89
81
|
...resolvedPartialVars
|
|
90
82
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
templateValues[variable] = "";
|
|
94
|
-
}
|
|
95
|
-
});
|
|
83
|
+
|
|
84
|
+
// Create system message content
|
|
96
85
|
const systemMessage = {
|
|
97
86
|
role: "system",
|
|
98
87
|
content: replaceTemplateVariables(systemTemplate, templateValues)
|
|
99
88
|
};
|
|
100
|
-
|
|
89
|
+
|
|
90
|
+
// Create user message content
|
|
101
91
|
const userContentParts = [];
|
|
102
|
-
|
|
92
|
+
const argsText = inputDef.filter(elem => elem.type === "string").map(elem => `# ${elem.name}${elem.description ? `\n${elem.description}` : ""}
|
|
93
|
+
${templateValues === null || templateValues === void 0 ? void 0 : templateValues[elem.name]}
|
|
94
|
+
`).join("\n\n");
|
|
95
|
+
const partialVarsText = Object.entries(resolvedPartialVars).map(([key, value]) => `# ${key}
|
|
96
|
+
${value}
|
|
97
|
+
`).join("\n\n");
|
|
98
|
+
if (argsText.trim().length > 0 || partialVarsText.trim().length > 0) {
|
|
103
99
|
userContentParts.push({
|
|
104
100
|
type: "text",
|
|
105
|
-
text:
|
|
101
|
+
text: argsText + "\n\n" + partialVarsText
|
|
106
102
|
});
|
|
107
103
|
}
|
|
104
|
+
const imageInputDefs = inputDef.filter(elem => elem.type === "imageDataURL");
|
|
108
105
|
imageInputDefs.forEach(elem => {
|
|
109
106
|
const imageValue = templateValues[elem.name];
|
|
110
107
|
if (imageValue && imageValue.trim().length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getVariableRegex","RegExp","extractVariables","content","variableRegex","variables","match","exec","includes","push","resolvePartialVars","partialVars","entries","Promise","all","Object","map","key","value","result","fromEntries","replaceTemplateVariables","template","values","replace","_","variable","createShouldMustTemplate","inputDef","summary","shouldSection","mustSection","example","shouldSectionPrompt","length","shouldSectionCount","shouldSectionHeader","shouldSectionBody","elem","baseBody","no","title","join","mustSectionPrompt","mustSectionCount","mustSectionHeader","mustSectionBody","exampleSectionPrompt","exampleSectionBody","
|
|
1
|
+
{"version":3,"names":["getVariableRegex","RegExp","extractVariables","content","variableRegex","variables","match","exec","includes","push","resolvePartialVars","partialVars","entries","Promise","all","Object","map","key","value","result","fromEntries","replaceTemplateVariables","template","values","replace","_","variable","prototype","hasOwnProperty","call","createShouldMustTemplate","inputDef","summary","shouldSection","mustSection","example","shouldSectionPrompt","length","shouldSectionCount","shouldSectionHeader","shouldSectionBody","elem","baseBody","no","title","join","mustSectionPrompt","mustSectionCount","mustSectionHeader","mustSectionBody","exampleSectionPrompt","exampleSectionBody","systemPrompt","filter","Boolean","systemTemplate","trim","formatMessages","args","mergedArgs","reduce","acc","resolvedPartialVars","templateValues","systemMessage","role","userContentParts","argsText","type","name","description","partialVarsText","text","imageInputDefs","forEach","imageValue","image","userMessage"],"sourceRoot":"../../../src","sources":["templates/ShouldMustTemplate.ts"],"mappings":";;;;;;AAWA,SAASA,gBAAgBA,CAAA,EAAW;EAChC,IAAI;IACA,OAAO,IAAIC,MAAM,CAAC,sBAAsB,EAAE,IAAI,CAAC;EACnD,CAAC,CAAC,MAAM;IACJ,OAAO,6LAA6L;EACxM;AACJ;AAEA,SAASC,gBAAgBA,CAACC,OAAe,EAAY;EACjD,MAAMC,aAAa,GAAGJ,gBAAgB,CAAC,CAAC;EACxC,MAAMK,SAAmB,GAAG,EAAE;EAC9B,IAAIC,KAA6B,GAAG,IAAI;EACxC,OAAO,CAACA,KAAK,GAAGF,aAAa,CAACG,IAAI,CAACJ,OAAO,CAAC,MAAM,IAAI,EAAE;IACnD,IAAI,CAACE,SAAS,CAACG,QAAQ,CAACF,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;MAC/BD,SAAS,CAACI,IAAI,CAACH,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5B;EACJ;EACA,OAAOD,SAAS;AACpB;AAEA,eAAeK,kBAAkBA,CAACC,WAA+E,EAAmC;EAChJ,IAAI,CAACA,WAAW,EAAE,OAAO,CAAC,CAAC;EAE3B,MAAMC,OAAO,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC7BC,MAAM,CAACH,OAAO,CAACD,WAAW,CAAC,CAACK,GAAG,CAAC,OAAO,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAK;IACpD,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;MAC7B,MAAMC,MAAM,GAAGD,KAAK,CAAC,CAAC;MACtB,OAAO,CAACD,GAAG,EAAE,OAAOE,MAAM,KAAK,QAAQ,GAAGA,MAAM,GAAG,MAAMA,MAAM,CAAC;IACpE;IACA,OAAO,CAACF,GAAG,EAAEC,KAAK,CAAC;EACvB,CAAC,CACL,CAAC;EAED,OAAOH,MAAM,CAACK,WAAW,CAACR,OAAO,CAAC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AI,CAAC,CAAC,CAACnB,MAAM,GAAG,CAAC,EAAE;QACjE6B,gBAAgB,CAACzD,IAAI,CAAC;UAClB2D,IAAI,EAAE,MAAM;UACZI,IAAI,EAAEL,QAAQ,GAAG,MAAM,GAAGI;QAC9B,CAAC,CAAC;MACN;MAEA,MAAME,cAAc,GAAG1C,QAAQ,CAACsB,MAAM,CAAEZ,IAAI,IAAKA,IAAI,CAAC2B,IAAI,KAAK,cAAc,CAAC;MAC9EK,cAAc,CAACC,OAAO,CAAEjC,IAAI,IAAK;QAC7B,MAAMkC,UAAU,GAAGZ,cAAc,CAACtB,IAAI,CAAC4B,IAAI,CAAC;QAC5C,IAAIM,UAAU,IAAIA,UAAU,CAACnB,IAAI,CAAC,CAAC,CAACnB,MAAM,GAAG,CAAC,EAAE;UAC5C6B,gBAAgB,CAACzD,IAAI,CAAC;YAClB2D,IAAI,EAAE,OAAO;YACbQ,KAAK,EAAED;UACX,CAAC,CAAC;QACN;MACJ,CAAC,CAAC;MAEF,MAAME,WAA6B,GAAG;QAClCZ,IAAI,EAAE,MAAM;QACZ9D,OAAO,EAAE+D,gBAAgB,CAAC7B,MAAM,GAAG,CAAC,GAAG6B,gBAAgB,GAAG;MAC9D,CAAC;MAED,OAAO,CAACF,aAAa,EAAEa,WAAW,CAAC;IACvC;EACJ,CAAC;AACL","ignoreList":[]}
|
|
@@ -5,19 +5,89 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = createGetLLM;
|
|
7
7
|
var _ai = require("ai");
|
|
8
|
+
var _types = require("../types");
|
|
8
9
|
var _openai = require("@ai-sdk/openai");
|
|
9
10
|
var _openaiCompatible = require("@ai-sdk/openai-compatible");
|
|
10
11
|
var _anthropic = require("@ai-sdk/anthropic");
|
|
11
12
|
var _google = require("@ai-sdk/google");
|
|
12
13
|
var _azure = require("@ai-sdk/azure");
|
|
14
|
+
const REVPROXY_JSON_INSTRUCTION = "Return a valid JSON object only. Do not include any extra text.";
|
|
15
|
+
const isRevproxyEnabled = () => Boolean(process.env.JELIQ_LLM_REVPROXY_KEY && process.env.JELIQ_LLM_REVPROXY_CONTAINER_ID && process.env.JELIQ_LLM_REVPROXY_ENDPOINT);
|
|
16
|
+
const addJsonInstructionToPrompt = prompt => {
|
|
17
|
+
if (!Array.isArray(prompt) || prompt.length === 0) {
|
|
18
|
+
return prompt;
|
|
19
|
+
}
|
|
20
|
+
const hasInstruction = prompt.some(message => (message === null || message === void 0 ? void 0 : message.role) === "system" && typeof message.content === "string" && message.content.includes(REVPROXY_JSON_INSTRUCTION));
|
|
21
|
+
if (hasInstruction) {
|
|
22
|
+
return prompt;
|
|
23
|
+
}
|
|
24
|
+
const instructionMessage = {
|
|
25
|
+
role: "system",
|
|
26
|
+
content: REVPROXY_JSON_INSTRUCTION
|
|
27
|
+
};
|
|
28
|
+
const insertIndex = prompt.findIndex(message => (message === null || message === void 0 ? void 0 : message.role) !== "system");
|
|
29
|
+
if (insertIndex === -1) {
|
|
30
|
+
return [...prompt, instructionMessage];
|
|
31
|
+
}
|
|
32
|
+
return [...prompt.slice(0, insertIndex), instructionMessage, ...prompt.slice(insertIndex)];
|
|
33
|
+
};
|
|
34
|
+
const normalizeJsonContent = content => {
|
|
35
|
+
if (!Array.isArray(content)) {
|
|
36
|
+
return content;
|
|
37
|
+
}
|
|
38
|
+
let text = "";
|
|
39
|
+
for (const part of content) {
|
|
40
|
+
if ((part === null || part === void 0 ? void 0 : part.type) === "text" && typeof part.text === "string") {
|
|
41
|
+
text += part.text;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (!text) {
|
|
45
|
+
return content;
|
|
46
|
+
}
|
|
47
|
+
let parsed;
|
|
48
|
+
try {
|
|
49
|
+
parsed = JSON.parse(text);
|
|
50
|
+
} catch {
|
|
51
|
+
return content;
|
|
52
|
+
}
|
|
53
|
+
const normalizedText = JSON.stringify(parsed);
|
|
54
|
+
let inserted = false;
|
|
55
|
+
return content.flatMap(part => {
|
|
56
|
+
if ((part === null || part === void 0 ? void 0 : part.type) !== "text" || typeof part.text !== "string") {
|
|
57
|
+
return [part];
|
|
58
|
+
}
|
|
59
|
+
if (inserted) {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
inserted = true;
|
|
63
|
+
return [{
|
|
64
|
+
...part,
|
|
65
|
+
text: normalizedText
|
|
66
|
+
}];
|
|
67
|
+
});
|
|
68
|
+
};
|
|
13
69
|
function createProviderModel(vendor, modelName) {
|
|
14
|
-
|
|
70
|
+
var _ModelNameAlias;
|
|
71
|
+
const actualModelName = (_types.ModelNameAlias === null || _types.ModelNameAlias === void 0 || (_ModelNameAlias = _types.ModelNameAlias[modelName]) === null || _ModelNameAlias === void 0 ? void 0 : _ModelNameAlias.model) || modelName;
|
|
72
|
+
if (isRevproxyEnabled()) {
|
|
15
73
|
const provider = (0, _openaiCompatible.createOpenAICompatible)({
|
|
16
74
|
name: "jeliq-llm-revproxy",
|
|
17
|
-
apiKey: process.env.JELIQ_LLM_REVPROXY_KEY,
|
|
18
|
-
baseURL: process.env.JELIQ_LLM_REVPROXY_ENDPOINT
|
|
75
|
+
apiKey: process.env.JELIQ_LLM_REVPROXY_KEY || "",
|
|
76
|
+
baseURL: process.env.JELIQ_LLM_REVPROXY_ENDPOINT || "",
|
|
77
|
+
headers: {
|
|
78
|
+
'X-Container-ID': process.env.JELIQ_LLM_REVPROXY_CONTAINER_ID || ""
|
|
79
|
+
}
|
|
80
|
+
// supportsStructuredOutputs: true,
|
|
81
|
+
/*
|
|
82
|
+
fetch: async (input, init) => {
|
|
83
|
+
if (init?.body) {
|
|
84
|
+
console.log("REQUEST BODY:", init.body.toString());
|
|
85
|
+
}
|
|
86
|
+
return fetch(input, init);
|
|
87
|
+
},
|
|
88
|
+
*/
|
|
19
89
|
});
|
|
20
|
-
return provider(
|
|
90
|
+
return provider(actualModelName);
|
|
21
91
|
}
|
|
22
92
|
if (vendor.type === "anthropic") {
|
|
23
93
|
const provider = vendor.apiKey || vendor.endpoint ? (0, _anthropic.createAnthropic)({
|
|
@@ -26,7 +96,7 @@ function createProviderModel(vendor, modelName) {
|
|
|
26
96
|
baseURL: vendor.endpoint
|
|
27
97
|
} : {})
|
|
28
98
|
}) : _anthropic.anthropic;
|
|
29
|
-
return provider(
|
|
99
|
+
return provider(actualModelName);
|
|
30
100
|
}
|
|
31
101
|
if (vendor.type === "google") {
|
|
32
102
|
const provider = vendor.apiKey || vendor.endpoint ? (0, _google.createGoogleGenerativeAI)({
|
|
@@ -35,7 +105,7 @@ function createProviderModel(vendor, modelName) {
|
|
|
35
105
|
baseURL: vendor.endpoint
|
|
36
106
|
} : {})
|
|
37
107
|
}) : _google.google;
|
|
38
|
-
return provider(
|
|
108
|
+
return provider(actualModelName);
|
|
39
109
|
}
|
|
40
110
|
if (vendor.type === "azure") {
|
|
41
111
|
const provider = vendor.apiKey || vendor.instanceName ? (0, _azure.createAzure)({
|
|
@@ -46,9 +116,9 @@ function createProviderModel(vendor, modelName) {
|
|
|
46
116
|
apiVersion: vendor.apiVersion,
|
|
47
117
|
useDeploymentBasedUrls: true
|
|
48
118
|
}) : _azure.azure;
|
|
49
|
-
return provider(vendor.deploymentName ||
|
|
119
|
+
return provider(vendor.deploymentName || actualModelName);
|
|
50
120
|
}
|
|
51
|
-
return (0, _openai.openai)(
|
|
121
|
+
return (0, _openai.openai)(actualModelName);
|
|
52
122
|
}
|
|
53
123
|
function createGetLLM(tasksModelsMap, defaultModel) {
|
|
54
124
|
function getModelAndTemperature(taskName) {
|
|
@@ -74,6 +144,7 @@ function createGetLLM(tasksModelsMap, defaultModel) {
|
|
|
74
144
|
const actualReasoningEffort = (options === null || options === void 0 ? void 0 : options.reasoningEffort) !== undefined ? options.reasoningEffort : reasoningEffort;
|
|
75
145
|
const actualVerbosityLevel = (options === null || options === void 0 ? void 0 : options.verbosityLevel) !== undefined ? options.verbosityLevel : verbosityLevel;
|
|
76
146
|
const actualTimeout = (options === null || options === void 0 ? void 0 : options.timeout) !== undefined ? options.timeout : timeout !== undefined ? timeout : undefined;
|
|
147
|
+
const usesRevproxy = isRevproxyEnabled();
|
|
77
148
|
const model = createProviderModel(resolvedVendor, actualModelName);
|
|
78
149
|
|
|
79
150
|
// 直前に CallOptions を変形するミドルウェア
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_ai","require","_openai","_openaiCompatible","_anthropic","_google","_azure","
|
|
1
|
+
{"version":3,"names":["_ai","require","_types","_openai","_openaiCompatible","_anthropic","_google","_azure","REVPROXY_JSON_INSTRUCTION","isRevproxyEnabled","Boolean","process","env","JELIQ_LLM_REVPROXY_KEY","JELIQ_LLM_REVPROXY_CONTAINER_ID","JELIQ_LLM_REVPROXY_ENDPOINT","addJsonInstructionToPrompt","prompt","Array","isArray","length","hasInstruction","some","message","role","content","includes","instructionMessage","insertIndex","findIndex","slice","normalizeJsonContent","text","part","type","parsed","JSON","parse","normalizedText","stringify","inserted","flatMap","createProviderModel","vendor","modelName","_ModelNameAlias","actualModelName","ModelNameAlias","model","provider","createOpenAICompatible","name","apiKey","baseURL","headers","endpoint","createAnthropic","anthropic","createGoogleGenerativeAI","google","instanceName","createAzure","resourceName","apiVersion","useDeploymentBasedUrls","azure","deploymentName","openai","createGetLLM","tasksModelsMap","defaultModel","getModelAndTemperature","taskName","Error","reasoningEffort","undefined","verbosityLevel","temperature","timeout","getLLM","options","_loggingInfo","resolvedVendor","actualTemperature","actualReasoningEffort","actualVerbosityLevel","actualTimeout","usesRevproxy","mutateCallOptionsMiddleware","specificationVersion","transformParams","params","_next$providerOptions","next","Math","min","max","providerOptions","textVerbosity","wrapLanguageModel","middleware"],"sourceRoot":"../../../src","sources":["utils/createGetLLM.ts"],"mappings":";;;;;;AAAA,IAAAA,GAAA,GAAAC,OAAA;AAIA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;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,EAAE,IAAI;MAC1B,MAAMC,eAAeA,CAAC;QAAExD,IAAI;QAAEyD;MAAsC,CAAC,EAAE;QAAA,IAAAC,qBAAA;QACnE,MAAMC,IAAI,GAAG;UAAE,GAAGF;QAAO,CAAC;;QAE1B;AAChB;AACA;AACA;AACA;;QAEgB,IAAI,OAAOE,IAAI,CAAChB,WAAW,KAAK,QAAQ,IAAI,OAAOM,iBAAiB,KAAK,QAAQ,EAAE;UAC/EU,IAAI,CAAChB,WAAW,GAAGiB,IAAI,CAACC,GAAG,CAAC,CAAC,EAAED,IAAI,CAACE,GAAG,CAAC,CAAC,EAAEH,IAAI,CAAChB,WAAW,IAAIM,iBAAiB,IAAI,CAAC,CAAC,CAAC;QAC3F;QAEAU,IAAI,CAACI,eAAe,GAAG;UACnB,IAAIJ,IAAI,CAACI,eAAe,IAAI,CAAC,CAAC,CAAC;UAC/B9B,MAAM,EAAE;YACJ,IAAI,EAAAyB,qBAAA,GAACC,IAAI,CAACI,eAAe,cAAAL,qBAAA,uBAArBA,qBAAA,CAA+BzB,MAAM,KAAI,CAAC,CAAC,CAAC;YAChDO,eAAe,EAAEU,qBAAqB;YACtCc,aAAa,EAAEb;UACnB;QACJ,CAAC;QAED,OAAOQ,IAAI;MACf;IACJ,CAAC;IAED,OAAO,IAAAM,qBAAiB,EAAC;MACrBnD,KAAK,EAAEA,KAAY;MACnBoD,UAAU,EAAEZ;IAChB,CAAC,CAAC;EACN,CAAC;EAED,OAAOT,MAAM;AACjB","ignoreList":[]}
|
|
@@ -1,5 +1,49 @@
|
|
|
1
|
-
import { generateText
|
|
2
|
-
import
|
|
1
|
+
import { generateText } from "ai";
|
|
2
|
+
import { zodToJsonSchema as zodToJsonSchemaRaw } from "zod-to-json-schema";
|
|
3
|
+
import createShouldMustTemplate from "../templates/ShouldMustTemplate";
|
|
4
|
+
const zodToJsonSchema = schema => zodToJsonSchemaRaw(schema);
|
|
5
|
+
const tryParseJson = text => {
|
|
6
|
+
try {
|
|
7
|
+
return {
|
|
8
|
+
value: JSON.parse(text),
|
|
9
|
+
raw: text
|
|
10
|
+
};
|
|
11
|
+
} catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const parseJsonFromText = text => {
|
|
16
|
+
var _tryParseJson;
|
|
17
|
+
const lines = text.replace(/\r\n/g, "\n").replace(/\r/g, "\n").split("\n");
|
|
18
|
+
|
|
19
|
+
// 1) 最初の ```json 行を探す(行頭にあることを要求)
|
|
20
|
+
let startLine = -1;
|
|
21
|
+
for (let i = 0; i < lines.length; i++) {
|
|
22
|
+
const line = lines[i];
|
|
23
|
+
// 例: ```json, ```JSON, ```json , ```json something
|
|
24
|
+
if (/^\s*```json\b/i.test(line)) {
|
|
25
|
+
startLine = i;
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (startLine === -1) throw new Error("Failed to parse JSON from model output.");
|
|
30
|
+
|
|
31
|
+
// 2) 最後の 行頭 ``` 行を探す(最後に出てくるやつ)
|
|
32
|
+
let endLine = -1;
|
|
33
|
+
for (let i = lines.length - 1; i > startLine; i--) {
|
|
34
|
+
if (/^\s*```/.test(lines[i])) {
|
|
35
|
+
endLine = i;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (endLine === -1) throw new Error("Failed to parse JSON from model output.");
|
|
40
|
+
const blockLines = lines.slice(startLine, endLine + 1);
|
|
41
|
+
const innerLines = lines.slice(startLine + 1, endLine);
|
|
42
|
+
return {
|
|
43
|
+
value: ((_tryParseJson = tryParseJson(innerLines.join("\n"))) === null || _tryParseJson === void 0 ? void 0 : _tryParseJson.value) ?? null,
|
|
44
|
+
raw: blockLines.join("\n")
|
|
45
|
+
};
|
|
46
|
+
};
|
|
3
47
|
export default async function genStructuredOutputs(context, taskName, template, args, options) {
|
|
4
48
|
if (!context) {
|
|
5
49
|
throw new Error("context is not set");
|
|
@@ -7,33 +51,101 @@ export default async function genStructuredOutputs(context, taskName, template,
|
|
|
7
51
|
if (!(context !== null && context !== void 0 && context.getLLM)) {
|
|
8
52
|
throw new Error("getLLM is not set");
|
|
9
53
|
}
|
|
10
|
-
const
|
|
54
|
+
const inputDefs = Object.keys(template.inputDef).map(key => ({
|
|
11
55
|
name: key,
|
|
12
56
|
type: template.inputDef[key].type,
|
|
13
57
|
description: template.inputDef[key].description
|
|
14
|
-
}))
|
|
58
|
+
}));
|
|
15
59
|
const promptArgs = Object.entries(args).reduce((acc, [key, value]) => {
|
|
16
60
|
acc[key] = value ?? "";
|
|
17
61
|
return acc;
|
|
18
62
|
}, {});
|
|
19
|
-
|
|
20
|
-
|
|
63
|
+
let outputSchemaJson = "";
|
|
64
|
+
try {
|
|
65
|
+
outputSchemaJson = JSON.stringify(zodToJsonSchema(template.outputSchema));
|
|
66
|
+
} catch (e) {
|
|
67
|
+
throw new Error(`Failed to convert output schema to JSON Schema: ${e instanceof Error ? e.message : String(e)}`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Add outputFormat input definition
|
|
71
|
+
const mustSection = [...(template.mustSection ?? [])];
|
|
72
|
+
mustSection.push({
|
|
73
|
+
no: mustSection.length + 1,
|
|
74
|
+
title: "outputFormat",
|
|
75
|
+
content: `You must format your output as a JSON value that adheres to a given "JSON Schema" instance with a markdown code block.
|
|
76
|
+
|
|
77
|
+
For example, the output format is:
|
|
78
|
+
\`\`\`json
|
|
79
|
+
{"properties": {"foo": {"description": "a list of test words", "type": "array", "items": {"type": "string"}}}, "required": ["foo"]}
|
|
80
|
+
\`\`\`
|
|
81
|
+
|
|
82
|
+
Then, you must return the following:
|
|
83
|
+
----- Begin of Output Example -----
|
|
84
|
+
\`\`\`json
|
|
85
|
+
{
|
|
86
|
+
"foo": ["bar", "baz"]
|
|
87
|
+
}
|
|
88
|
+
\`\`\`
|
|
89
|
+
----- End of Output Example -----
|
|
90
|
+
|
|
91
|
+
Do NOT ouput anything other than the JSON value with markdown code block.
|
|
92
|
+
Your output will be parsed and type-checked according to the provided schema instance, so make sure all fields in your output match the schema exactly and there are no trailing commas!
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
Here is the JSON Schema instance your output must adhere to. Include the enclosing markdown codeblock:
|
|
96
|
+
|
|
97
|
+
\`\`\`json
|
|
98
|
+
${outputSchemaJson}
|
|
99
|
+
\`\`\``
|
|
100
|
+
});
|
|
101
|
+
const promptTemplate = await createShouldMustTemplate(inputDefs, template.summary, template.shouldSection, mustSection, template.example, template.partialVars);
|
|
102
|
+
const model = context.getLLM(taskName, {
|
|
21
103
|
model: options === null || options === void 0 ? void 0 : options.model,
|
|
22
104
|
temperature: options === null || options === void 0 ? void 0 : options.temperature,
|
|
23
105
|
reasoningEffort: options === null || options === void 0 ? void 0 : options.reasoningEffort,
|
|
106
|
+
verbosityLevel: options === null || options === void 0 ? void 0 : options.verbosityLevel,
|
|
24
107
|
timeout: options === null || options === void 0 ? void 0 : options.timeout
|
|
25
108
|
});
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
109
|
+
const maxParseRetries = (options === null || options === void 0 ? void 0 : options.maxRetries) ?? 3;
|
|
110
|
+
const buildCorrectionPrompt = errorMessage => ["The previous output could not be parsed or validated.", `Error: ${errorMessage}`, "Please return only a JSON value wrapped in a markdown ```json code block that matches the schema.", "Do not include any other text."].join("\n");
|
|
111
|
+
let lastErrorMessage = null;
|
|
112
|
+
let lastText = "";
|
|
113
|
+
for (let attempt = 0; attempt <= maxParseRetries; attempt++) {
|
|
114
|
+
const messages = await promptTemplate.formatMessages(promptArgs);
|
|
115
|
+
|
|
116
|
+
// Add correction prompt if this is a retry
|
|
117
|
+
if (attempt > 0) {
|
|
118
|
+
messages.push({
|
|
119
|
+
role: "assistant",
|
|
120
|
+
content: lastText
|
|
121
|
+
});
|
|
122
|
+
messages.push({
|
|
123
|
+
role: "user",
|
|
124
|
+
content: buildCorrectionPrompt(lastErrorMessage ?? "Unknown error")
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
const {
|
|
128
|
+
text
|
|
129
|
+
} = await generateText({
|
|
130
|
+
model,
|
|
131
|
+
messages,
|
|
132
|
+
maxRetries: options !== null && options !== void 0 && options.maxRetries ? Math.max(0, options.maxRetries - attempt) : undefined
|
|
133
|
+
});
|
|
134
|
+
try {
|
|
135
|
+
const parsed = parseJsonFromText(text);
|
|
136
|
+
const parsedResult = template.outputSchema.safeParse(parsed.value);
|
|
137
|
+
if (parsedResult.success) {
|
|
138
|
+
return parsedResult.data;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// ✅ ここは「JSONは正しいが schema 違反」
|
|
142
|
+
lastErrorMessage = parsedResult.error.message;
|
|
143
|
+
} catch (e) {
|
|
144
|
+
// ✅ ここは「JSON抽出/JSON構文がダメ」
|
|
145
|
+
lastErrorMessage = e instanceof Error ? e.message : String(e);
|
|
146
|
+
}
|
|
147
|
+
lastText = text;
|
|
148
|
+
}
|
|
149
|
+
throw new Error(`Structured output validation failed after ${maxParseRetries + 1} attempts: ${lastErrorMessage ?? "Unknown error"}`);
|
|
38
150
|
}
|
|
39
151
|
//# sourceMappingURL=genStructuredOutputs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["generateText","
|
|
1
|
+
{"version":3,"names":["generateText","zodToJsonSchema","zodToJsonSchemaRaw","createShouldMustTemplate","schema","tryParseJson","text","value","JSON","parse","raw","parseJsonFromText","_tryParseJson","lines","replace","split","startLine","i","length","line","test","Error","endLine","blockLines","slice","innerLines","join","genStructuredOutputs","context","taskName","template","args","options","getLLM","inputDefs","Object","keys","inputDef","map","key","name","type","description","promptArgs","entries","reduce","acc","outputSchemaJson","stringify","outputSchema","e","message","String","mustSection","push","no","title","content","promptTemplate","summary","shouldSection","example","partialVars","model","temperature","reasoningEffort","verbosityLevel","timeout","maxParseRetries","maxRetries","buildCorrectionPrompt","errorMessage","lastErrorMessage","lastText","attempt","messages","formatMessages","role","Math","max","undefined","parsed","parsedResult","safeParse","success","data","error"],"sourceRoot":"../../../src","sources":["controllers/genStructuredOutputs.ts"],"mappings":"AACA,SAASA,YAAY,QAAsB,IAAI;AAC/C,SAASC,eAAe,IAAIC,kBAAkB,QAAQ,oBAAoB;AAG1E,OAAOC,wBAAwB,MAAM,iCAAiC;AA4BtE,MAAMF,eAAe,GAAIG,MAAkB,IACtCF,kBAAkB,CAA+CE,MAAM,CAAC;AAE7E,MAAMC,YAAY,GAAIC,IAAY,IAAwB;EACtD,IAAI;IACA,OAAO;MAAEC,KAAK,EAAEC,IAAI,CAACC,KAAK,CAACH,IAAI,CAAC;MAAEI,GAAG,EAAEJ;IAAK,CAAC;EACjD,CAAC,CAAC,MAAM;IACJ,OAAO,IAAI;EACf;AACJ,CAAC;AAED,MAAMK,iBAAiB,GAAIL,IAAY,IAAiB;EAAA,IAAAM,aAAA;EACpD,MAAMC,KAAK,GAAGP,IAAI,CAACQ,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAACA,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAACC,KAAK,CAAC,IAAI,CAAC;;EAE1E;EACA,IAAIC,SAAS,GAAG,CAAC,CAAC;EAClB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGJ,KAAK,CAACK,MAAM,EAAED,CAAC,EAAE,EAAE;IACnC,MAAME,IAAI,GAAGN,KAAK,CAACI,CAAC,CAAC;IACrB;IACA,IAAI,gBAAgB,CAACG,IAAI,CAACD,IAAI,CAAC,EAAE;MAC7BH,SAAS,GAAGC,CAAC;MACb;IACJ;EACJ;EACA,IAAID,SAAS,KAAK,CAAC,CAAC,EAAE,MAAM,IAAIK,KAAK,CAAC,yCAAyC,CAAC;;EAEhF;EACA,IAAIC,OAAO,GAAG,CAAC,CAAC;EAChB,KAAK,IAAIL,CAAC,GAAGJ,KA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Q;MACRN,UAAU,EAAErC,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEqC,UAAU,GAAGS,IAAI,CAACC,GAAG,CAAC,CAAC,EAAE/C,OAAO,CAACqC,UAAU,GAAGK,OAAO,CAAC,GAAGM;IAClF,CAAC,CAAC;IAEF,IAAI;MACA,MAAMC,MAAM,GAAGtE,iBAAiB,CAACL,IAAI,CAAC;MACtC,MAAM4E,YAAY,GAAGpD,QAAQ,CAACmB,YAAY,CAACkC,SAAS,CAACF,MAAM,CAAC1E,KAAK,CAAC;MAElE,IAAI2E,YAAY,CAACE,OAAO,EAAE;QACtB,OAAOF,YAAY,CAACG,IAAI;MAC5B;;MAEA;MACAb,gBAAgB,GAAGU,YAAY,CAACI,KAAK,CAACnC,OAAO;IACjD,CAAC,CAAC,OAAOD,CAAC,EAAE;MACR;MACAsB,gBAAgB,GAAGtB,CAAC,YAAY7B,KAAK,GAAG6B,CAAC,CAACC,OAAO,GAAGC,MAAM,CAACF,CAAC,CAAC;IACjE;IAEAuB,QAAQ,GAAGnE,IAAI;EACnB;EAEA,MAAM,IAAIe,KAAK,CACX,6CAA6C+C,eAAe,GAAG,CAAC,cAAcI,gBAAgB,IAAI,eAAe,EACrH,CAAC;AACL","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -2,5 +2,6 @@ import createShouldMustTemplate from "./templates/ShouldMustTemplate";
|
|
|
2
2
|
import createGetLLM from "./utils/createGetLLM";
|
|
3
3
|
import genJSON from "./controllers/genJSON";
|
|
4
4
|
import genStructuredOutputs from "./controllers/genStructuredOutputs";
|
|
5
|
-
|
|
5
|
+
import { ModelNameAlias } from "./types";
|
|
6
|
+
export { genJSON, genStructuredOutputs, createShouldMustTemplate, createGetLLM, ModelNameAlias };
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createShouldMustTemplate","createGetLLM","genJSON","genStructuredOutputs"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAUA,OAAOA,wBAAwB,MAAM,gCAAgC;AACrE,OAAOC,YAAY,MAAM,sBAAsB;AAC/C,OAAOC,OAAO,MAAM,uBAAuB;AAC3C,OAAOC,oBAAoB,MAAM,oCAAoC;
|
|
1
|
+
{"version":3,"names":["createShouldMustTemplate","createGetLLM","genJSON","genStructuredOutputs","ModelNameAlias"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAUA,OAAOA,wBAAwB,MAAM,gCAAgC;AACrE,OAAOC,YAAY,MAAM,sBAAsB;AAC/C,OAAOC,OAAO,MAAM,uBAAuB;AAC3C,OAAOC,oBAAoB,MAAM,oCAAoC;AACrE,SAASC,cAAc,QAAQ,SAAS;AAExC,SACIF,OAAO,EACPC,oBAAoB,EACpBH,wBAAwB,EACxBC,YAAY,EACZG,cAAc","ignoreList":[]}
|
|
@@ -28,7 +28,12 @@ async function resolvePartialVars(partialVars) {
|
|
|
28
28
|
return Object.fromEntries(entries);
|
|
29
29
|
}
|
|
30
30
|
function replaceTemplateVariables(template, values) {
|
|
31
|
-
return template.replace(getVariableRegex(), (_, variable) =>
|
|
31
|
+
return template.replace(getVariableRegex(), (_, variable) => {
|
|
32
|
+
if (Object.prototype.hasOwnProperty.call(values, variable)) {
|
|
33
|
+
return values[variable] ?? "";
|
|
34
|
+
}
|
|
35
|
+
return `[${variable}](#${variable})`;
|
|
36
|
+
});
|
|
32
37
|
}
|
|
33
38
|
export default async function createShouldMustTemplate(inputDef, summary, shouldSection, mustSection, example, partialVars) {
|
|
34
39
|
const shouldSectionPrompt = (() => {
|
|
@@ -56,49 +61,41 @@ export default async function createShouldMustTemplate(inputDef, summary, should
|
|
|
56
61
|
const exampleSectionBody = example.map(elem => `## (c${elem.no}) ${elem.title}\n${elem.content}`).join("\n\n");
|
|
57
62
|
return `# Example\n\n${exampleSectionBody}`;
|
|
58
63
|
})();
|
|
59
|
-
const allSectionContent = [(shouldSection === null || shouldSection === void 0 ? void 0 : shouldSection.map(s => s.content || "").join(" ")) || "", (mustSection === null || mustSection === void 0 ? void 0 : mustSection.map(s => s.content || "").join(" ")) || "", (example === null || example === void 0 ? void 0 : example.map(s => s.content || "").join(" ")) || "", summary].join(" ");
|
|
60
|
-
const usedVariables = extractVariables(allSectionContent);
|
|
61
|
-
const definedInputVariables = inputDef.map(elem => elem.name);
|
|
62
|
-
const definedPartialVariables = Object.keys(partialVars || {});
|
|
63
|
-
const definedVariables = [...definedInputVariables, ...definedPartialVariables, "outputFormat"];
|
|
64
|
-
const undefinedVariables = usedVariables.filter(variable => !definedVariables.includes(variable));
|
|
65
|
-
if (undefinedVariables.length > 0) {
|
|
66
|
-
console.warn(`[ShouldMustTemplate] Warning: Found ${undefinedVariables.length} undefined variable(s) in template sections: [${undefinedVariables.join(", ")}]. These variables have been automatically added to the template.`);
|
|
67
|
-
}
|
|
68
|
-
const autoGeneratedVariablesSection = undefinedVariables.length > 0 ? `\n\n# Auto-Generated Variables\n\n${undefinedVariables.map(variable => `## ${variable}\n{${variable}}`).join("\n\n")}` : "";
|
|
69
64
|
const systemPrompt = [summary, shouldSectionPrompt, mustSectionPrompt, exampleSectionPrompt].filter(Boolean).join("\n\n");
|
|
70
|
-
const
|
|
71
|
-
const imageInputDefs = inputDef.filter(elem => elem.type === "imageDataURL");
|
|
72
|
-
const systemTemplate = [systemPrompt, "{outputFormat}"].filter(Boolean).join("\n\n").trim();
|
|
73
|
-
const userTextTemplate = [stringInputPromptTemplate, autoGeneratedVariablesSection].filter(Boolean).join("\n\n").trim();
|
|
65
|
+
const systemTemplate = [systemPrompt].filter(Boolean).join("\n\n").trim();
|
|
74
66
|
return {
|
|
75
67
|
async formatMessages(args) {
|
|
76
|
-
const resolvedPartialVars = await resolvePartialVars(partialVars || {});
|
|
77
68
|
const mergedArgs = Object.entries(args || {}).reduce((acc, [key, value]) => {
|
|
78
69
|
acc[key] = value ?? "";
|
|
79
70
|
return acc;
|
|
80
71
|
}, {});
|
|
72
|
+
const resolvedPartialVars = await resolvePartialVars(partialVars || {});
|
|
81
73
|
const templateValues = {
|
|
82
74
|
...mergedArgs,
|
|
83
75
|
...resolvedPartialVars
|
|
84
76
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
templateValues[variable] = "";
|
|
88
|
-
}
|
|
89
|
-
});
|
|
77
|
+
|
|
78
|
+
// Create system message content
|
|
90
79
|
const systemMessage = {
|
|
91
80
|
role: "system",
|
|
92
81
|
content: replaceTemplateVariables(systemTemplate, templateValues)
|
|
93
82
|
};
|
|
94
|
-
|
|
83
|
+
|
|
84
|
+
// Create user message content
|
|
95
85
|
const userContentParts = [];
|
|
96
|
-
|
|
86
|
+
const argsText = inputDef.filter(elem => elem.type === "string").map(elem => `# ${elem.name}${elem.description ? `\n${elem.description}` : ""}
|
|
87
|
+
${templateValues === null || templateValues === void 0 ? void 0 : templateValues[elem.name]}
|
|
88
|
+
`).join("\n\n");
|
|
89
|
+
const partialVarsText = Object.entries(resolvedPartialVars).map(([key, value]) => `# ${key}
|
|
90
|
+
${value}
|
|
91
|
+
`).join("\n\n");
|
|
92
|
+
if (argsText.trim().length > 0 || partialVarsText.trim().length > 0) {
|
|
97
93
|
userContentParts.push({
|
|
98
94
|
type: "text",
|
|
99
|
-
text:
|
|
95
|
+
text: argsText + "\n\n" + partialVarsText
|
|
100
96
|
});
|
|
101
97
|
}
|
|
98
|
+
const imageInputDefs = inputDef.filter(elem => elem.type === "imageDataURL");
|
|
102
99
|
imageInputDefs.forEach(elem => {
|
|
103
100
|
const imageValue = templateValues[elem.name];
|
|
104
101
|
if (imageValue && imageValue.trim().length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getVariableRegex","RegExp","extractVariables","content","variableRegex","variables","match","exec","includes","push","resolvePartialVars","partialVars","entries","Promise","all","Object","map","key","value","result","fromEntries","replaceTemplateVariables","template","values","replace","_","variable","createShouldMustTemplate","inputDef","summary","shouldSection","mustSection","example","shouldSectionPrompt","length","shouldSectionCount","shouldSectionHeader","shouldSectionBody","elem","baseBody","no","title","join","mustSectionPrompt","mustSectionCount","mustSectionHeader","mustSectionBody","exampleSectionPrompt","exampleSectionBody","
|
|
1
|
+
{"version":3,"names":["getVariableRegex","RegExp","extractVariables","content","variableRegex","variables","match","exec","includes","push","resolvePartialVars","partialVars","entries","Promise","all","Object","map","key","value","result","fromEntries","replaceTemplateVariables","template","values","replace","_","variable","prototype","hasOwnProperty","call","createShouldMustTemplate","inputDef","summary","shouldSection","mustSection","example","shouldSectionPrompt","length","shouldSectionCount","shouldSectionHeader","shouldSectionBody","elem","baseBody","no","title","join","mustSectionPrompt","mustSectionCount","mustSectionHeader","mustSectionBody","exampleSectionPrompt","exampleSectionBody","systemPrompt","filter","Boolean","systemTemplate","trim","formatMessages","args","mergedArgs","reduce","acc","resolvedPartialVars","templateValues","systemMessage","role","userContentParts","argsText","type","name","description","partialVarsText","text","imageInputDefs","forEach","imageValue","image","userMessage"],"sourceRoot":"../../../src","sources":["templates/ShouldMustTemplate.ts"],"mappings":"AAWA,SAASA,gBAAgBA,CAAA,EAAW;EAChC,IAAI;IACA,OAAO,IAAIC,MAAM,CAAC,sBAAsB,EAAE,IAAI,CAAC;EACnD,CAAC,CAAC,MAAM;IACJ,OAAO,6LAA6L;EACxM;AACJ;AAEA,SAASC,gBAAgBA,CAACC,OAAe,EAAY;EACjD,MAAMC,aAAa,GAAGJ,gBAAgB,CAAC,CAAC;EACxC,MAAMK,SAAmB,GAAG,EAAE;EAC9B,IAAIC,KAA6B,GAAG,IAAI;EACxC,OAAO,CAACA,KAAK,GAAGF,aAAa,CAACG,IAAI,CAACJ,OAAO,CAAC,MAAM,IAAI,EAAE;IACnD,IAAI,CAACE,SAAS,CAACG,QAAQ,CAACF,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;MAC/BD,SAAS,CAACI,IAAI,CAACH,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5B;EACJ;EACA,OAAOD,SAAS;AACpB;AAEA,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O,EAAE+D,gBAAgB,CAAC7B,MAAM,GAAG,CAAC,GAAG6B,gBAAgB,GAAG;MAC9D,CAAC;MAED,OAAO,CAACF,aAAa,EAAEa,WAAW,CAAC;IACvC;EACJ,CAAC;AACL","ignoreList":[]}
|
|
@@ -1,17 +1,87 @@
|
|
|
1
1
|
import { wrapLanguageModel } from "ai";
|
|
2
|
+
import { ModelNameAlias } from "../types";
|
|
2
3
|
import { openai } from "@ai-sdk/openai";
|
|
3
4
|
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
|
4
5
|
import { anthropic, createAnthropic } from "@ai-sdk/anthropic";
|
|
5
6
|
import { google, createGoogleGenerativeAI } from "@ai-sdk/google";
|
|
6
7
|
import { azure, createAzure } from "@ai-sdk/azure";
|
|
8
|
+
const REVPROXY_JSON_INSTRUCTION = "Return a valid JSON object only. Do not include any extra text.";
|
|
9
|
+
const isRevproxyEnabled = () => Boolean(process.env.JELIQ_LLM_REVPROXY_KEY && process.env.JELIQ_LLM_REVPROXY_CONTAINER_ID && process.env.JELIQ_LLM_REVPROXY_ENDPOINT);
|
|
10
|
+
const addJsonInstructionToPrompt = prompt => {
|
|
11
|
+
if (!Array.isArray(prompt) || prompt.length === 0) {
|
|
12
|
+
return prompt;
|
|
13
|
+
}
|
|
14
|
+
const hasInstruction = prompt.some(message => (message === null || message === void 0 ? void 0 : message.role) === "system" && typeof message.content === "string" && message.content.includes(REVPROXY_JSON_INSTRUCTION));
|
|
15
|
+
if (hasInstruction) {
|
|
16
|
+
return prompt;
|
|
17
|
+
}
|
|
18
|
+
const instructionMessage = {
|
|
19
|
+
role: "system",
|
|
20
|
+
content: REVPROXY_JSON_INSTRUCTION
|
|
21
|
+
};
|
|
22
|
+
const insertIndex = prompt.findIndex(message => (message === null || message === void 0 ? void 0 : message.role) !== "system");
|
|
23
|
+
if (insertIndex === -1) {
|
|
24
|
+
return [...prompt, instructionMessage];
|
|
25
|
+
}
|
|
26
|
+
return [...prompt.slice(0, insertIndex), instructionMessage, ...prompt.slice(insertIndex)];
|
|
27
|
+
};
|
|
28
|
+
const normalizeJsonContent = content => {
|
|
29
|
+
if (!Array.isArray(content)) {
|
|
30
|
+
return content;
|
|
31
|
+
}
|
|
32
|
+
let text = "";
|
|
33
|
+
for (const part of content) {
|
|
34
|
+
if ((part === null || part === void 0 ? void 0 : part.type) === "text" && typeof part.text === "string") {
|
|
35
|
+
text += part.text;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (!text) {
|
|
39
|
+
return content;
|
|
40
|
+
}
|
|
41
|
+
let parsed;
|
|
42
|
+
try {
|
|
43
|
+
parsed = JSON.parse(text);
|
|
44
|
+
} catch {
|
|
45
|
+
return content;
|
|
46
|
+
}
|
|
47
|
+
const normalizedText = JSON.stringify(parsed);
|
|
48
|
+
let inserted = false;
|
|
49
|
+
return content.flatMap(part => {
|
|
50
|
+
if ((part === null || part === void 0 ? void 0 : part.type) !== "text" || typeof part.text !== "string") {
|
|
51
|
+
return [part];
|
|
52
|
+
}
|
|
53
|
+
if (inserted) {
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
inserted = true;
|
|
57
|
+
return [{
|
|
58
|
+
...part,
|
|
59
|
+
text: normalizedText
|
|
60
|
+
}];
|
|
61
|
+
});
|
|
62
|
+
};
|
|
7
63
|
function createProviderModel(vendor, modelName) {
|
|
8
|
-
|
|
64
|
+
var _ModelNameAlias;
|
|
65
|
+
const actualModelName = (ModelNameAlias === null || ModelNameAlias === void 0 || (_ModelNameAlias = ModelNameAlias[modelName]) === null || _ModelNameAlias === void 0 ? void 0 : _ModelNameAlias.model) || modelName;
|
|
66
|
+
if (isRevproxyEnabled()) {
|
|
9
67
|
const provider = createOpenAICompatible({
|
|
10
68
|
name: "jeliq-llm-revproxy",
|
|
11
|
-
apiKey: process.env.JELIQ_LLM_REVPROXY_KEY,
|
|
12
|
-
baseURL: process.env.JELIQ_LLM_REVPROXY_ENDPOINT
|
|
69
|
+
apiKey: process.env.JELIQ_LLM_REVPROXY_KEY || "",
|
|
70
|
+
baseURL: process.env.JELIQ_LLM_REVPROXY_ENDPOINT || "",
|
|
71
|
+
headers: {
|
|
72
|
+
'X-Container-ID': process.env.JELIQ_LLM_REVPROXY_CONTAINER_ID || ""
|
|
73
|
+
}
|
|
74
|
+
// supportsStructuredOutputs: true,
|
|
75
|
+
/*
|
|
76
|
+
fetch: async (input, init) => {
|
|
77
|
+
if (init?.body) {
|
|
78
|
+
console.log("REQUEST BODY:", init.body.toString());
|
|
79
|
+
}
|
|
80
|
+
return fetch(input, init);
|
|
81
|
+
},
|
|
82
|
+
*/
|
|
13
83
|
});
|
|
14
|
-
return provider(
|
|
84
|
+
return provider(actualModelName);
|
|
15
85
|
}
|
|
16
86
|
if (vendor.type === "anthropic") {
|
|
17
87
|
const provider = vendor.apiKey || vendor.endpoint ? createAnthropic({
|
|
@@ -20,7 +90,7 @@ function createProviderModel(vendor, modelName) {
|
|
|
20
90
|
baseURL: vendor.endpoint
|
|
21
91
|
} : {})
|
|
22
92
|
}) : anthropic;
|
|
23
|
-
return provider(
|
|
93
|
+
return provider(actualModelName);
|
|
24
94
|
}
|
|
25
95
|
if (vendor.type === "google") {
|
|
26
96
|
const provider = vendor.apiKey || vendor.endpoint ? createGoogleGenerativeAI({
|
|
@@ -29,7 +99,7 @@ function createProviderModel(vendor, modelName) {
|
|
|
29
99
|
baseURL: vendor.endpoint
|
|
30
100
|
} : {})
|
|
31
101
|
}) : google;
|
|
32
|
-
return provider(
|
|
102
|
+
return provider(actualModelName);
|
|
33
103
|
}
|
|
34
104
|
if (vendor.type === "azure") {
|
|
35
105
|
const provider = vendor.apiKey || vendor.instanceName ? createAzure({
|
|
@@ -40,9 +110,9 @@ function createProviderModel(vendor, modelName) {
|
|
|
40
110
|
apiVersion: vendor.apiVersion,
|
|
41
111
|
useDeploymentBasedUrls: true
|
|
42
112
|
}) : azure;
|
|
43
|
-
return provider(vendor.deploymentName ||
|
|
113
|
+
return provider(vendor.deploymentName || actualModelName);
|
|
44
114
|
}
|
|
45
|
-
return openai(
|
|
115
|
+
return openai(actualModelName);
|
|
46
116
|
}
|
|
47
117
|
export default function createGetLLM(tasksModelsMap, defaultModel) {
|
|
48
118
|
function getModelAndTemperature(taskName) {
|
|
@@ -68,6 +138,7 @@ export default function createGetLLM(tasksModelsMap, defaultModel) {
|
|
|
68
138
|
const actualReasoningEffort = (options === null || options === void 0 ? void 0 : options.reasoningEffort) !== undefined ? options.reasoningEffort : reasoningEffort;
|
|
69
139
|
const actualVerbosityLevel = (options === null || options === void 0 ? void 0 : options.verbosityLevel) !== undefined ? options.verbosityLevel : verbosityLevel;
|
|
70
140
|
const actualTimeout = (options === null || options === void 0 ? void 0 : options.timeout) !== undefined ? options.timeout : timeout !== undefined ? timeout : undefined;
|
|
141
|
+
const usesRevproxy = isRevproxyEnabled();
|
|
71
142
|
const model = createProviderModel(resolvedVendor, actualModelName);
|
|
72
143
|
|
|
73
144
|
// 直前に CallOptions を変形するミドルウェア
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["wrapLanguageModel","openai","createOpenAICompatible","anthropic","createAnthropic","google","createGoogleGenerativeAI","azure","createAzure","
|
|
1
|
+
{"version":3,"names":["wrapLanguageModel","ModelNameAlias","openai","createOpenAICompatible","anthropic","createAnthropic","google","createGoogleGenerativeAI","azure","createAzure","REVPROXY_JSON_INSTRUCTION","isRevproxyEnabled","Boolean","process","env","JELIQ_LLM_REVPROXY_KEY","JELIQ_LLM_REVPROXY_CONTAINER_ID","JELIQ_LLM_REVPROXY_ENDPOINT","addJsonInstructionToPrompt","prompt","Array","isArray","length","hasInstruction","some","message","role","content","includes","instructionMessage","insertIndex","findIndex","slice","normalizeJsonContent","text","part","type","parsed","JSON","parse","normalizedText","stringify","inserted","flatMap","createProviderModel","vendor","modelName","_ModelNameAlias","actualModelName","model","provider","name","apiKey","baseURL","headers","endpoint","instanceName","resourceName","apiVersion","useDeploymentBasedUrls","deploymentName","createGetLLM","tasksModelsMap","defaultModel","getModelAndTemperature","taskName","Error","reasoningEffort","undefined","verbosityLevel","temperature","timeout","getLLM","options","_loggingInfo","resolvedVendor","actualTemperature","actualReasoningEffort","actualVerbosityLevel","actualTimeout","usesRevproxy","mutateCallOptionsMiddleware","specificationVersion","transformParams","params","_next$providerOptions","next","Math","min","max","providerOptions","textVerbosity","middleware"],"sourceRoot":"../../../src","sources":["utils/createGetLLM.ts"],"mappings":"AAAA,SACIA,iBAAiB,QAEd,IAAI;AACX,SAAyGC,cAAc,QAAQ,UAAU;AAEzI,SAASC,MAAM,QAAQ,gBAAgB;AACvC,SAASC,sBAAsB,QAAQ,2BAA2B;AAClE,SAASC,SAAS,EAAEC,eAAe,QAAQ,mBAAmB;AAC9D,SAASC,MAAM,EAAEC,wBAAwB,QAAQ,gBAAgB;AACjE,SAASC,KAAK,EAAEC,WAAW,QAAQ,eAAe;AAElD,MAAMC,yBAAyB,GAC3B,iEAAiE;AAErE,MAAMC,iBAAiB,GAAGA,CAAA,KACtBC,OAAO,CACHC,OAAO,CAACC,GAAG,CAACC,sBAAsB,IAClCF,OAAO,CAACC,GAAG,CAACE,+BAA+B,IAC3CH,OAAO,CAACC,GAAG,CAACG,2BAChB,CAAC;AAEL,MAAMC,0BAA0B,GAAIC,MAAW,IAAK;EAChD,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,IAAIA,MAAM,CAACG,MAAM,KAAK,CAAC,EAAE;IAC/C,OAAOH,MAAM;EACjB;EAEA,MAAMI,cAAc,GAAGJ,MAAM,CAACK,IAAI,CAC7BC,OAAO,IACJ,CAAAA,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,IAAI,MAAK,QAAQ,IAC1B,OAAOD,OAAO,CAACE,OAAO,KAAK,QAAQ,IACnCF,OAAO,CAACE,OAAO,CAACC,QAAQ,CAAClB,yBAAyB,CAC1D,CAAC;EAED,IAAIa,cAAc,EAAE;IAChB,OAAOJ,MAAM;EACjB;EAEA,MAAMU,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MACf;IACJ,CAAC;IAED,OAAOtF,iBAAiB,CAAC;MACrBiD,KAAK,EAAEA,KAAY;MACnB2C,UAAU,EAAEX;IAChB,CAAC,CAAC;EACN,CAAC;EAED,OAAOT,MAAM;AACjB","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BackendContext } from "@jeliq/app-sdk-core";
|
|
2
2
|
import { ZodSchema } from "zod";
|
|
3
|
-
import { InputDefObj, PromptElement } from "../types";
|
|
3
|
+
import { InputDefObj, PromptElement, REASONING_EFFORT, VERBOSITY_LEVEL } from "../types";
|
|
4
4
|
type StructuredTemplate<InputKeys extends string | number | symbol, Output> = {
|
|
5
5
|
type: "ShouldMust";
|
|
6
6
|
inputDef: InputDefObj<InputKeys>;
|
|
@@ -14,7 +14,8 @@ type StructuredTemplate<InputKeys extends string | number | symbol, Output> = {
|
|
|
14
14
|
export type GenStructuredOutputsOptions = {
|
|
15
15
|
model?: string;
|
|
16
16
|
temperature?: number;
|
|
17
|
-
reasoningEffort?:
|
|
17
|
+
reasoningEffort?: REASONING_EFFORT;
|
|
18
|
+
verbosityLevel?: VERBOSITY_LEVEL;
|
|
18
19
|
timeout?: number;
|
|
19
20
|
maxRetries?: number;
|
|
20
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genStructuredOutputs.d.ts","sourceRoot":"","sources":["../../../../src/controllers/genStructuredOutputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"genStructuredOutputs.d.ts","sourceRoot":"","sources":["../../../../src/controllers/genStructuredOutputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAGhC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,UAAU,CAA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
|
import createGetLLM from "./utils/createGetLLM";
|
|
4
4
|
import genJSON from "./controllers/genJSON";
|
|
5
5
|
import genStructuredOutputs from "./controllers/genStructuredOutputs";
|
|
6
|
-
|
|
6
|
+
import { ModelNameAlias } from "./types";
|
|
7
|
+
export { genJSON, genStructuredOutputs, createShouldMustTemplate, createGetLLM, ModelNameAlias, };
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACR,MAAM,EACN,UAAU,EACV,YAAY,EACZ,4BAA4B,EAC5B,WAAW,IAAI,QAAQ,EACvB,aAAa,EACb,gBAAgB,GACnB,MAAM,SAAS,CAAC;AAEjB,OAAO,wBAAwB,MAAM,gCAAgC,CAAC;AACtE,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAChD,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,oBAAoB,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACR,MAAM,EACN,UAAU,EACV,YAAY,EACZ,4BAA4B,EAC5B,WAAW,IAAI,QAAQ,EACvB,aAAa,EACb,gBAAgB,GACnB,MAAM,SAAS,CAAC;AAEjB,OAAO,wBAAwB,MAAM,gCAAgC,CAAC;AACtE,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAChD,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,oBAAoB,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,OAAO,EACH,OAAO,EACP,oBAAoB,EACpB,wBAAwB,EACxB,YAAY,EACZ,cAAc,GACjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShouldMustTemplate.d.ts","sourceRoot":"","sources":["../../../../src/templates/ShouldMustTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,kBAAkB,EAAY,gBAAgB,EAAE,MAAM,IAAI,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEnD,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC;AAE9D,KAAK,aAAa,GAAG,KAAK,CAAC,kBAAkB,GAAG,gBAAgB,CAAC,CAAC;AAElE,KAAK,wBAAwB,GAAG;IAC5B,cAAc,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;CAClE,CAAC;
|
|
1
|
+
{"version":3,"file":"ShouldMustTemplate.d.ts","sourceRoot":"","sources":["../../../../src/templates/ShouldMustTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,kBAAkB,EAAY,gBAAgB,EAAE,MAAM,IAAI,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEnD,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC;AAE9D,KAAK,aAAa,GAAG,KAAK,CAAC,kBAAkB,GAAG,gBAAgB,CAAC,CAAC;AAElE,KAAK,wBAAwB,GAAG;IAC5B,cAAc,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;CAClE,CAAC;AA+CF,wBAA8B,wBAAwB,CAClD,QAAQ,EAAE,QAAQ,EAAE,EACpB,OAAO,EAAE,MAAM,EACf,aAAa,CAAC,EAAE,aAAa,EAAE,EAC/B,WAAW,CAAC,EAAE,aAAa,EAAE,EAC7B,OAAO,CAAC,EAAE,aAAa,EAAE,EACzB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC,CAAC,GAChF,OAAO,CAAC,wBAAwB,CAAC,CAmHnC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createGetLLM.d.ts","sourceRoot":"","sources":["../../../../src/utils/createGetLLM.ts"],"names":[],"mappings":"AAIA,OAAO,EAAc,MAAM,EAAE,UAAU,EAAqC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"createGetLLM.d.ts","sourceRoot":"","sources":["../../../../src/utils/createGetLLM.ts"],"names":[],"mappings":"AAIA,OAAO,EAAc,MAAM,EAAE,UAAU,EAAqC,gBAAgB,EAA6B,MAAM,UAAU,CAAC;AAqJ1I,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,SAAS,SAAS,MAAM,EAAE,SAAS,SAAS,gBAAgB,EAC7F,cAAc,EAAE,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,EACxD,YAAY,EAAE,UAAU,CAAC,SAAS,CAAC,GACpC,MAAM,CAAC,SAAS,CAAC,CAqGnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jeliq/app-sdk-llm",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"homepage": "https://jeliq.ai/",
|
|
5
5
|
"author": "Jeliq.ai",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"@ai-sdk/openai-compatible": "^2.0.4",
|
|
25
25
|
"ai": "^6.0.11",
|
|
26
26
|
"lodash": "^4.17.21",
|
|
27
|
-
"ts-node": "^10.9.2"
|
|
27
|
+
"ts-node": "^10.9.2",
|
|
28
|
+
"zod-to-json-schema": "^3.25.0"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"@types/jest": "^30.0.0",
|