@jeliq/app-sdk-llm 1.1.24 → 1.2.2

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.
Files changed (36) hide show
  1. package/lib/commonjs/controllers/genJSON.js +2 -22
  2. package/lib/commonjs/controllers/genJSON.js.map +1 -1
  3. package/lib/commonjs/controllers/genStructuredOutputs.js +46 -0
  4. package/lib/commonjs/controllers/genStructuredOutputs.js.map +1 -0
  5. package/lib/commonjs/index.js +7 -0
  6. package/lib/commonjs/index.js.map +1 -1
  7. package/lib/commonjs/templates/ShouldMustTemplate.js +86 -71
  8. package/lib/commonjs/templates/ShouldMustTemplate.js.map +1 -1
  9. package/lib/commonjs/types.js +128 -0
  10. package/lib/commonjs/types.js.map +1 -1
  11. package/lib/commonjs/utils/createGetLLM.js +97 -79
  12. package/lib/commonjs/utils/createGetLLM.js.map +1 -1
  13. package/lib/module/controllers/genJSON.js +2 -22
  14. package/lib/module/controllers/genJSON.js.map +1 -1
  15. package/lib/module/controllers/genStructuredOutputs.js +39 -0
  16. package/lib/module/controllers/genStructuredOutputs.js.map +1 -0
  17. package/lib/module/index.js +2 -1
  18. package/lib/module/index.js.map +1 -1
  19. package/lib/module/templates/ShouldMustTemplate.js +86 -71
  20. package/lib/module/templates/ShouldMustTemplate.js.map +1 -1
  21. package/lib/module/types.js +127 -1
  22. package/lib/module/types.js.map +1 -1
  23. package/lib/module/utils/createGetLLM.js +97 -79
  24. package/lib/module/utils/createGetLLM.js.map +1 -1
  25. package/lib/typescript/src/controllers/genJSON.d.ts.map +1 -1
  26. package/lib/typescript/src/controllers/genStructuredOutputs.d.ts +23 -0
  27. package/lib/typescript/src/controllers/genStructuredOutputs.d.ts.map +1 -0
  28. package/lib/typescript/src/index.d.ts +2 -1
  29. package/lib/typescript/src/index.d.ts.map +1 -1
  30. package/lib/typescript/src/templates/ShouldMustTemplate.d.ts +9 -5
  31. package/lib/typescript/src/templates/ShouldMustTemplate.d.ts.map +1 -1
  32. package/lib/typescript/src/types.d.ts +53 -18
  33. package/lib/typescript/src/types.d.ts.map +1 -1
  34. package/lib/typescript/src/utils/createGetLLM.d.ts +2 -2
  35. package/lib/typescript/src/utils/createGetLLM.d.ts.map +1 -1
  36. package/package.json +8 -8
@@ -4,96 +4,114 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = createGetLLM;
7
- var _openai = require("@langchain/openai");
8
- var _anthropic = require("@langchain/anthropic");
9
- var _googleGenai = require("@langchain/google-genai");
7
+ var _ai = require("ai");
8
+ var _openai = require("@ai-sdk/openai");
9
+ var _openaiCompatible = require("@ai-sdk/openai-compatible");
10
+ var _anthropic = require("@ai-sdk/anthropic");
11
+ var _google = require("@ai-sdk/google");
12
+ var _azure = require("@ai-sdk/azure");
13
+ function createProviderModel(vendor, modelName) {
14
+ if (process.env.JELIQ_LLM_REVPROXY_KEY && process.env.JELIQ_LLM_REVPROXY_ENDPOINT) {
15
+ const provider = (0, _openaiCompatible.createOpenAICompatible)({
16
+ name: "jeliq-llm-revproxy",
17
+ apiKey: process.env.JELIQ_LLM_REVPROXY_KEY,
18
+ baseURL: process.env.JELIQ_LLM_REVPROXY_ENDPOINT
19
+ });
20
+ return provider(modelName);
21
+ }
22
+ if (vendor.type === "anthropic") {
23
+ const provider = vendor.apiKey || vendor.endpoint ? (0, _anthropic.createAnthropic)({
24
+ apiKey: vendor.apiKey,
25
+ ...(vendor.endpoint ? {
26
+ baseURL: vendor.endpoint
27
+ } : {})
28
+ }) : _anthropic.anthropic;
29
+ return provider(modelName);
30
+ }
31
+ if (vendor.type === "google") {
32
+ const provider = vendor.apiKey || vendor.endpoint ? (0, _google.createGoogleGenerativeAI)({
33
+ apiKey: vendor.apiKey,
34
+ ...(vendor.endpoint ? {
35
+ baseURL: vendor.endpoint
36
+ } : {})
37
+ }) : _google.google;
38
+ return provider(modelName);
39
+ }
40
+ if (vendor.type === "azure") {
41
+ const provider = vendor.apiKey || vendor.instanceName ? (0, _azure.createAzure)({
42
+ apiKey: vendor.apiKey,
43
+ ...(vendor.instanceName ? {
44
+ resourceName: vendor.instanceName
45
+ } : {}),
46
+ apiVersion: vendor.apiVersion,
47
+ useDeploymentBasedUrls: true
48
+ }) : _azure.azure;
49
+ return provider(vendor.deploymentName || modelName);
50
+ }
51
+ return (0, _openai.openai)(modelName);
52
+ }
10
53
  function createGetLLM(tasksModelsMap, defaultModel) {
11
54
  function getModelAndTemperature(taskName) {
12
55
  const model = taskName in tasksModelsMap ? tasksModelsMap[taskName] : defaultModel;
13
56
  if (!model) {
14
57
  throw new Error(`Model not found for task ${taskName}`);
15
58
  }
16
- return [model.model, model.vendor, model.temperature, model.reasoningEffort, model.timeout];
59
+ const reasoningEffort = "reasoningEffort" in model ? model.reasoningEffort : undefined;
60
+ const verbosityLevel = "verbosityLevel" in model ? model.verbosityLevel : undefined;
61
+ return [model.model, model.vendor, model.temperature, reasoningEffort, verbosityLevel, model.timeout];
17
62
  }
18
- const getLLM = (taskName, usedTemplate, options, loggingInfo) => {
19
- const [modelName, vendor, temperature, reasoningEffort, timeout] = getModelAndTemperature(taskName);
20
- const argsImageURLs = [];
21
- let imageNum = 0;
22
- if (usedTemplate instanceof Array) {
23
- usedTemplate = usedTemplate.map(message => {
24
- if (typeof message.content === "string") return message.content;
25
- if (message.content instanceof Array) return message.content /*.filter((content) => content.type === "text")*/.map(content => {
26
- if (content.type === "text") {
27
- return content.text;
28
- } else {
29
- argsImageURLs.push(content.image_url);
30
- return `\n[AttachedImage(${content.type}):${imageNum++}]`;
31
- }
32
- }).join("\n\n");
33
- }).join("\n\n");
34
- }
35
- const thinkingModel = modelName === "o1-mini" || modelName === "o1-preview" || modelName === "o1" || modelName === "o3-mini";
36
- let inputPrompts = [];
37
- const llmConfig = {
38
- timeout: (options === null || options === void 0 ? void 0 : options.timeout) || timeout || (thinkingModel ? 60 * 3 * 1000 : undefined),
39
- modelName,
40
- temperature: (options === null || options === void 0 ? void 0 : options.temperature) || temperature || 0.5,
41
- reasoningEffort: thinkingModel ? (options === null || options === void 0 ? void 0 : options.reasoningEffort) || reasoningEffort || "low" : undefined,
42
- callbacks: [{
43
- handleLLMStart: async (llm, prompts) => {
44
- inputPrompts = prompts;
45
- },
46
- handleLLMEnd: async output => {
47
- var _output$llmOutput, _output$llmOutput2, _output$llmOutput3, _output$llmOutput4, _output$llmOutput5, _output$llmOutput6;
48
- const promptTokens = (output === null || output === void 0 || (_output$llmOutput = output.llmOutput) === null || _output$llmOutput === void 0 || (_output$llmOutput = _output$llmOutput.usage_metadata) === null || _output$llmOutput === void 0 ? void 0 : _output$llmOutput.prompt_token_count) || (output === null || output === void 0 || (_output$llmOutput2 = output.llmOutput) === null || _output$llmOutput2 === void 0 || (_output$llmOutput2 = _output$llmOutput2.usage) === null || _output$llmOutput2 === void 0 ? void 0 : _output$llmOutput2.input_tokens) || (output === null || output === void 0 || (_output$llmOutput3 = output.llmOutput) === null || _output$llmOutput3 === void 0 || (_output$llmOutput3 = _output$llmOutput3.tokenUsage) === null || _output$llmOutput3 === void 0 ? void 0 : _output$llmOutput3.promptTokens) || 0;
49
- const completionTokens = (output === null || output === void 0 || (_output$llmOutput4 = output.llmOutput) === null || _output$llmOutput4 === void 0 || (_output$llmOutput4 = _output$llmOutput4.usage_metadata) === null || _output$llmOutput4 === void 0 ? void 0 : _output$llmOutput4.candidates_token_count) || (output === null || output === void 0 || (_output$llmOutput5 = output.llmOutput) === null || _output$llmOutput5 === void 0 || (_output$llmOutput5 = _output$llmOutput5.usage) === null || _output$llmOutput5 === void 0 ? void 0 : _output$llmOutput5.output_tokens) || (output === null || output === void 0 || (_output$llmOutput6 = output.llmOutput) === null || _output$llmOutput6 === void 0 || (_output$llmOutput6 = _output$llmOutput6.tokenUsage) === null || _output$llmOutput6 === void 0 ? void 0 : _output$llmOutput6.completionTokens) || 0;
50
- inputPrompts = [];
51
- },
52
- handleLLMError: error => {}
53
- }]
54
- };
55
-
56
- // Anthropic models
57
- if (vendor.type === "anthropic") {
58
- return new _anthropic.ChatAnthropic({
59
- ...llmConfig,
60
- maxTokens: vendor.maxTokens || 7000,
61
- invocationKwargs: {
62
- top_p: undefined
63
- }
64
- });
63
+ const getLLM = (taskName, options, _loggingInfo) => {
64
+ const [modelName, vendor, temperature, reasoningEffort, verbosityLevel, timeout] = getModelAndTemperature(taskName);
65
+ let resolvedVendor = vendor;
66
+ if (vendor.type !== "openai" && vendor.type !== "anthropic" && vendor.type !== "google" && vendor.type !== "azure") {
67
+ resolvedVendor = {
68
+ ...vendor,
69
+ type: "openai"
70
+ };
65
71
  }
72
+ const actualModelName = (options === null || options === void 0 ? void 0 : options.model) || modelName;
73
+ const actualTemperature = (options === null || options === void 0 ? void 0 : options.temperature) !== undefined ? options.temperature : temperature;
74
+ const actualReasoningEffort = (options === null || options === void 0 ? void 0 : options.reasoningEffort) !== undefined ? options.reasoningEffort : reasoningEffort;
75
+ const actualVerbosityLevel = (options === null || options === void 0 ? void 0 : options.verbosityLevel) !== undefined ? options.verbosityLevel : verbosityLevel;
76
+ const actualTimeout = (options === null || options === void 0 ? void 0 : options.timeout) !== undefined ? options.timeout : timeout !== undefined ? timeout : undefined;
77
+ const model = createProviderModel(resolvedVendor, actualModelName);
66
78
 
67
- // Google Generative AI models
68
- if (vendor.type === "google") {
69
- return new _googleGenai.ChatGoogleGenerativeAI({
70
- model: modelName,
71
- maxOutputTokens: vendor.maxTokens || 7000,
72
- callbacks: llmConfig.callbacks
73
- });
74
- }
79
+ // 直前に CallOptions を変形するミドルウェア
80
+ const mutateCallOptionsMiddleware = {
81
+ specificationVersion: "v3",
82
+ async transformParams({
83
+ type,
84
+ params
85
+ }) {
86
+ var _next$providerOptions;
87
+ const next = {
88
+ ...params
89
+ };
75
90
 
76
- // Azure OpenAI models
77
- if (vendor.type === "azure") {
78
- return new _openai.AzureChatOpenAI({
79
- timeout: llmConfig.timeout,
80
- deploymentName: (vendor === null || vendor === void 0 ? void 0 : vendor.deploymentName) || modelName,
81
- azureOpenAIApiDeploymentName: (vendor === null || vendor === void 0 ? void 0 : vendor.deploymentName) || modelName,
82
- openAIBasePath: vendor.endpoint,
83
- openAIApiKey: vendor.apiKey,
84
- openAIApiVersion: vendor.apiVersion,
85
- temperature: llmConfig.temperature,
86
- modelName: modelName,
87
- callbacks: llmConfig.callbacks,
88
- reasoning: {
89
- effort: llmConfig.reasoningEffort
90
- },
91
- azureOpenAIApiInstanceName: vendor.instanceName
92
- });
93
- }
91
+ /*
92
+ if (type === "stream") {
93
+ next.maxOutputTokens = next.maxOutputTokens ?? 800;
94
+ }
95
+ */
94
96
 
95
- // OpenAI models (default)
96
- return new _openai.ChatOpenAI(llmConfig);
97
+ if (typeof next.temperature === "number" || typeof actualTemperature === "number") {
98
+ next.temperature = Math.min(2, Math.max(0, next.temperature || actualTemperature || 0));
99
+ }
100
+ next.providerOptions = {
101
+ ...(next.providerOptions ?? {}),
102
+ openai: {
103
+ ...(((_next$providerOptions = next.providerOptions) === null || _next$providerOptions === void 0 ? void 0 : _next$providerOptions.openai) ?? {}),
104
+ reasoningEffort: actualReasoningEffort,
105
+ textVerbosity: actualVerbosityLevel
106
+ }
107
+ };
108
+ return next;
109
+ }
110
+ };
111
+ return (0, _ai.wrapLanguageModel)({
112
+ model: model,
113
+ middleware: mutateCallOptionsMiddleware
114
+ });
97
115
  };
98
116
  return getLLM;
99
117
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_openai","require","_anthropic","_googleGenai","createGetLLM","tasksModelsMap","defaultModel","getModelAndTemperature","taskName","model","Error","vendor","temperature","reasoningEffort","timeout","getLLM","usedTemplate","options","loggingInfo","modelName","argsImageURLs","imageNum","Array","map","message","content","type","text","push","image_url","join","thinkingModel","inputPrompts","llmConfig","undefined","callbacks","handleLLMStart","llm","prompts","handleLLMEnd","output","_output$llmOutput","_output$llmOutput2","_output$llmOutput3","_output$llmOutput4","_output$llmOutput5","_output$llmOutput6","promptTokens","llmOutput","usage_metadata","prompt_token_count","usage","input_tokens","tokenUsage","completionTokens","candidates_token_count","output_tokens","handleLLMError","error","ChatAnthropic","maxTokens","invocationKwargs","top_p","ChatGoogleGenerativeAI","maxOutputTokens","AzureChatOpenAI","deploymentName","azureOpenAIApiDeploymentName","openAIBasePath","endpoint","openAIApiKey","apiKey","openAIApiVersion","apiVersion","reasoning","effort","azureOpenAIApiInstanceName","instanceName","ChatOpenAI"],"sourceRoot":"../../../src","sources":["utils/createGetLLM.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAOe,SAASG,YAAYA,CAChCC,cAAwD,EACxDC,YAAmC,EAClB;EAEjB,SAASC,sBAAsBA,CAACC,QAA4B,EAA4G;IACpK,MAAMC,KAAK,GAAGD,QAAQ,IAAIH,cAAc,GAAGA,cAAc,CAACG,QAAQ,CAAc,GAAGF,YAAY;IAC/F,IAAI,CAACG,KAAK,EAAE;MACR,MAAM,IAAIC,KAAK,CAAC,4BAA4BF,QAAQ,EAAE,CAAC;IAC3D;IACA,OAAO,CAAEC,KAAK,CAACA,KAAK,EAAEA,KAAK,CAACE,MAAM,EAAEF,KAAK,CAACG,WAAW,EAAEH,KAAK,CAACI,eAAe,EAAEJ,KAAK,CAACK,OAAO,CAAE;EACjG;EAEA,MAAMC,MAAyB,GAAGA,CAC9BP,QAA4B,EAC5BQ,YAAoC,EACpCC,OAIC,EACDC,WAAiB,KACuD;IACxE,MAAM,CAAEC,SAAS,EAAER,MAAM,EAAEC,WAAW,EAAEC,eAAe,EAAEC,OAAO,CAAE,GAAGP,sBAAsB,CAACC,QAAQ,CAAC;IAErG,MAAMY,aAAuB,GAAG,EAAE;IAClC,IAAIC,QAAQ,GAAG,CAAC;IAChB,IAAIL,YAAY,YAAYM,KAAK,EAAE;MAC/BN,YAAY,GAAIA,YAAY,CAAmBO,GAAG,CAAEC,OAAO,IAAK;QAChE,IAAI,OAAOA,OAAO,CAACC,OAAO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CAAC,CAAC;IACN;;IAEA;IACA,OAAO,IAAIC,kBAAU,CAAC7C,SAAS,CAAC;EACpC,CAAC;EAED,OAAOlB,MAAM;AACjB","ignoreList":[]}
1
+ {"version":3,"names":["_ai","require","_openai","_openaiCompatible","_anthropic","_google","_azure","createProviderModel","vendor","modelName","process","env","JELIQ_LLM_REVPROXY_KEY","JELIQ_LLM_REVPROXY_ENDPOINT","provider","createOpenAICompatible","name","apiKey","baseURL","type","endpoint","createAnthropic","anthropic","createGoogleGenerativeAI","google","instanceName","createAzure","resourceName","apiVersion","useDeploymentBasedUrls","azure","deploymentName","openai","createGetLLM","tasksModelsMap","defaultModel","getModelAndTemperature","taskName","model","Error","reasoningEffort","undefined","verbosityLevel","temperature","timeout","getLLM","options","_loggingInfo","resolvedVendor","actualModelName","actualTemperature","actualReasoningEffort","actualVerbosityLevel","actualTimeout","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;AAMA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAEA,SAASM,mBAAmBA,CAACC,MAAkB,EAAEC,SAAiB,EAAiB;EAC/E,IAAIC,OAAO,CAACC,GAAG,CAACC,sBAAsB,IAAIF,OAAO,CAACC,GAAG,CAACE,2BAA2B,EAAE;IAC/E,MAAMC,QAAQ,GAAG,IAAAC,wCAAsB,EAAC;MACpCC,IAAI,EAAE,oBAAoB;MAC1BC,MAAM,EAAEP,OAAO,CAACC,GAAG,CAACC,sBAAsB;MAC1CM,OAAO,EAAER,OAAO,CAACC,GAAG,CAACE;IACzB,CAAC,CAAC;IACF,OAAOC,QAA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;UAC/B/B,MAAM,EAAE;YACJ,IAAI,EAAA0B,qBAAA,GAACC,IAAI,CAACI,eAAe,cAAAL,qBAAA,uBAArBA,qBAAA,CAA+B1B,MAAM,KAAI,CAAC,CAAC,CAAC;YAChDQ,eAAe,EAAEW,qBAAqB;YACtCa,aAAa,EAAEZ;UACnB;QACJ,CAAC;QAED,OAAOO,IAAI;MACf;IACJ,CAAC;IAED,OAAO,IAAAM,qBAAiB,EAAC;MACrB3B,KAAK,EAAEA,KAAY;MACnB4B,UAAU,EAAEZ;IAChB,CAAC,CAAC;EACN,CAAC;EAED,OAAOT,MAAM;AACjB","ignoreList":[]}
@@ -1,25 +1,5 @@
1
- import { OutputFixingParser, StructuredOutputParser } from "langchain/output_parsers";
2
- import createShouldMustTemplate from "../templates/ShouldMustTemplate";
3
- import { retryWithBackoff } from "../utils/retryWithBackoff";
1
+ import genStructuredOutputs from "./genStructuredOutputs";
4
2
  export default async function genJSON(context, taskName, template, args, options) {
5
- if (!(context !== null && context !== void 0 && context.getLLM)) {
6
- throw new Error("getLLM is not set");
7
- }
8
- const outputParser = StructuredOutputParser.fromZodSchema(template.outputSchema);
9
- const promptTemplate = await createShouldMustTemplate(Object.keys(template.inputDef).map(key => ({
10
- name: key,
11
- type: template.inputDef[key].type,
12
- description: template.inputDef[key].description
13
- })), outputParser, template.summary, template.shouldSection, template.mustSection, template.example, template.partialVars);
14
- const parser = outputParser;
15
- if (!parser) {
16
- throw new Error("outputParser is not set");
17
- }
18
- const llm = context.getLLM(taskName, await promptTemplate.format(args));
19
- const fixParser = OutputFixingParser.fromLLM(llm, parser).withRetry({
20
- stopAfterAttempt: 5
21
- });
22
- const chain = promptTemplate.pipe(llm).pipe(fixParser);
23
- return await retryWithBackoff(() => chain.invoke(args), (options === null || options === void 0 ? void 0 : options.maxRetries) ?? 5, options === null || options === void 0 ? void 0 : options.initialDelayMs, options === null || options === void 0 ? void 0 : options.maxDelayMs);
3
+ return genStructuredOutputs(context, taskName, template, args);
24
4
  }
25
5
  //# sourceMappingURL=genJSON.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["OutputFixingParser","StructuredOutputParser","createShouldMustTemplate","retryWithBackoff","genJSON","context","taskName","template","args","options","getLLM","Error","outputParser","fromZodSchema","outputSchema","promptTemplate","Object","keys","inputDef","map","key","name","type","description","summary","shouldSection","mustSection","example","partialVars","parser","llm","format","fixParser","fromLLM","withRetry","stopAfterAttempt","chain","pipe","invoke","maxRetries","initialDelayMs","maxDelayMs"],"sourceRoot":"../../../src","sources":["controllers/genJSON.ts"],"mappings":"AACA,SAASA,kBAAkB,EAAEC,sBAAsB,QAAQ,0BAA0B;AAGrF,OAAOC,wBAAwB,MAAM,iCAAiC;AAEtE,SAASC,gBAAgB,QAAQ,2BAA2B;AAE5D,eAAe,eAAeC,OAAOA,CACjCC,OAA4B,EAC5BC,QAAgB,EAChBC,QASC,EACDC,IAAkD,EAClDC,OAIC,EACc;EAEf,IAAI,EAACJ,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEK,MAAM,GAAE;IAClB,MAAM,IAAIC,KAAK,CAAC,mBAAmB,CAAC;EACxC;EAEA,MAAMC,YAAY,GAAGX,sBAAsB,CAACY,aAAa,CAACN,QAAQ,CAACO,YAAmB,CAA6B;EAEnH,MAAMC,cAAc,GAAG,MAAMb,wBAAwB,CACjDc,MAAM,CAACC,IAAI,CAACV,QAAQ,CAACW,QAAQ,CAAC,CAACC,GAAG,CAAEC,GAAG,KAAM;IACzCC,IAAI,EAAED,GAAG;IACTE,IAAI,EAAEf,QAAQ,CAACW,QAAQ,CAACE,GAAG,CAAc,CAACE,IAAI;IAC9CC,WAAW,EAAEhB,QAAQ,CAACW,QAAQ,CAACE,GAAG,CAAc,CAACG;EACrD,CAAC,CAAC,CAAC,EACHX,YAAY,EACZL,QAAQ,CAACiB,OAAO,EAChBjB,QAAQ,CAACkB,aAAa,EACtBlB,QAAQ,CAACmB,WAAW,EACpBnB,QAAQ,CAACoB,OAAO,EAChBpB,QAAQ,CAACqB,WACb,CAAC;EAED,MAAMC,MAAM,GAAGjB,YAAwC;EACvD,IAAI,CAACiB,MAAM,EAAE;IACT,MAAM,IAAIlB,KAAK,CAAC,yBAAyB,CAAC;EAC9C;EAEA,MAAMmB,GAAG,GAAGzB,OAAO,CAACK,MAAM,CACtBJ,QAAQ,EACR,MAAMS,cAAc,CAACgB,MAAM,CAACvB,IAAI,CACpC,CAAC;EAED,MAAMwB,SAAS,GAAGhC,kBAAkB,CAACiC,OAAO,CACxCH,GAAG,EACHD,MACJ,CAAC,CAACK,SAAS,CAAC;IAAEC,gBAAgB,EAAE;EAAE,CAAC,CAAC;EAEpC,MAAMC,KAAK,GAAGrB,cAAc,CAACsB,IAAI,CAACP,GAAG,CAAC,CAACO,IAAI,CAACL,SAAS,CAAC;EAEtD,OAAO,MAAM7B,gBAAgB,CACzB,MAAMiC,KAAK,CAACE,MAAM,CAAC9B,IAAI,CAAC,EACxB,CAAAC,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAE8B,UAAU,KAAI,CAAC,EACxB9B,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAE+B,cAAc,EAAE/B,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEgC,UACtC,CAAC;AACL","ignoreList":[]}
1
+ {"version":3,"names":["genStructuredOutputs","genJSON","context","taskName","template","args","options"],"sourceRoot":"../../../src","sources":["controllers/genJSON.ts"],"mappings":"AAGA,OAAOA,oBAAoB,MAAM,wBAAwB;AAIzD,eAAe,eAAeC,OAAOA,CACjCC,OAA4B,EAC5BC,QAAgB,EAChBC,QASC,EACDC,IAAkD,EAClDC,OAIC,EACc;EACf,OAAON,oBAAoB,CACvBE,OAAO,EACPC,QAAQ,EACRC,QAAQ,EACRC,IACJ,CAAC;AACL","ignoreList":[]}
@@ -0,0 +1,39 @@
1
+ import { generateText, Output as AIOutput } from "ai";
2
+ import createShouldMustTemplateAI from "../templates/ShouldMustTemplate";
3
+ export default async function genStructuredOutputs(context, taskName, template, args, options) {
4
+ if (!context) {
5
+ throw new Error("context is not set");
6
+ }
7
+ if (!(context !== null && context !== void 0 && context.getLLM)) {
8
+ throw new Error("getLLM is not set");
9
+ }
10
+ const promptTemplate = await createShouldMustTemplateAI(Object.keys(template.inputDef).map(key => ({
11
+ name: key,
12
+ type: template.inputDef[key].type,
13
+ description: template.inputDef[key].description
14
+ })), template.summary, template.shouldSection, template.mustSection, template.example, template.partialVars);
15
+ const promptArgs = Object.entries(args).reduce((acc, [key, value]) => {
16
+ acc[key] = value ?? "";
17
+ return acc;
18
+ }, {});
19
+ const messages = await promptTemplate.formatMessages(promptArgs);
20
+ const model = context.getLLM(taskName, undefined, {
21
+ model: options === null || options === void 0 ? void 0 : options.model,
22
+ temperature: options === null || options === void 0 ? void 0 : options.temperature,
23
+ reasoningEffort: options === null || options === void 0 ? void 0 : options.reasoningEffort,
24
+ timeout: options === null || options === void 0 ? void 0 : options.timeout
25
+ });
26
+ const {
27
+ output
28
+ } = await generateText({
29
+ model,
30
+ messages,
31
+ temperature: options === null || options === void 0 ? void 0 : options.temperature,
32
+ maxRetries: options === null || options === void 0 ? void 0 : options.maxRetries,
33
+ output: AIOutput.object({
34
+ schema: template.outputSchema
35
+ })
36
+ });
37
+ return output;
38
+ }
39
+ //# sourceMappingURL=genStructuredOutputs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["generateText","Output","AIOutput","createShouldMustTemplateAI","genStructuredOutputs","context","taskName","template","args","options","Error","getLLM","promptTemplate","Object","keys","inputDef","map","key","name","type","description","summary","shouldSection","mustSection","example","partialVars","promptArgs","entries","reduce","acc","value","messages","formatMessages","model","undefined","temperature","reasoningEffort","timeout","output","maxRetries","object","schema","outputSchema"],"sourceRoot":"../../../src","sources":["controllers/genStructuredOutputs.ts"],"mappings":"AACA,SAASA,YAAY,EAAEC,MAAM,IAAIC,QAAQ,QAAQ,IAAI;AAErD,OAAOC,0BAA0B,MAAM,iCAAiC;AAsBxE,eAAe,eAAeC,oBAAo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,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAE0B,WAAW;IACjCC,eAAe,EAAE3B,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAE2B,eAAe;IACzCC,OAAO,EAAE5B,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAE4B;EACtB,CACJ,CAAC;EAED,MAAM;IAAEC;EAAO,CAAC,GAAG,MAAMtC,YAAY,CAAC;IAClCiC,KAAK;IACLF,QAAQ;IACRI,WAAW,EAAE1B,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAE0B,WAAW;IACjCI,UAAU,EAAE9B,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAE8B,UAAU;IAC/BD,MAAM,EAAEpC,QAAQ,CAACsC,MAAM,CAAC;MACpBC,MAAM,EAAElC,QAAQ,CAACmC;IACrB,CAAC;EACL,CAAC,CAAC;EAEF,OAAOJ,MAAM;AACjB","ignoreList":[]}
@@ -1,5 +1,6 @@
1
1
  import createShouldMustTemplate from "./templates/ShouldMustTemplate";
2
2
  import createGetLLM from "./utils/createGetLLM";
3
3
  import genJSON from "./controllers/genJSON";
4
- export { genJSON, createShouldMustTemplate, createGetLLM };
4
+ import genStructuredOutputs from "./controllers/genStructuredOutputs";
5
+ export { genJSON, genStructuredOutputs, createShouldMustTemplate, createGetLLM };
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createShouldMustTemplate","createGetLLM","genJSON"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAUA,OAAOA,wBAAwB,MAAM,gCAAgC;AACrE,OAAOC,YAAY,MAAM,sBAAsB;AAC/C,OAAOC,OAAO,MAAM,uBAAuB;AAE3C,SACIA,OAAO,EACPF,wBAAwB,EACxBC,YAAY","ignoreList":[]}
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;AAErE,SACID,OAAO,EACPC,oBAAoB,EACpBH,wBAAwB,EACxBC,YAAY","ignoreList":[]}
@@ -1,9 +1,14 @@
1
- import { ChatPromptTemplate, HumanMessagePromptTemplate } from "@langchain/core/prompts";
2
- // Helper function to extract variable names from content
1
+ function getVariableRegex() {
2
+ try {
3
+ return new RegExp("{([\\p{L}\\p{N}_]+)}", "gu");
4
+ } catch {
5
+ return /{([0-9A-Za-z_\u00C0-\u02FF\u0370-\u03FF\u0400-\u04FF\u0590-\u05FF\u0600-\u06FF\u0900-\u097F\u0E00-\u0E7F\u3040-\u30FF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFF\uAC00-\uD7AF\uF900-\uFAFF]+)}/g;
6
+ }
7
+ }
3
8
  function extractVariables(content) {
4
- const variableRegex = /{(\w+)}/g;
9
+ const variableRegex = getVariableRegex();
5
10
  const variables = [];
6
- let match;
11
+ let match = null;
7
12
  while ((match = variableRegex.exec(content)) !== null) {
8
13
  if (!variables.includes(match[1])) {
9
14
  variables.push(match[1]);
@@ -11,94 +16,104 @@ function extractVariables(content) {
11
16
  }
12
17
  return variables;
13
18
  }
14
- export default async function createShouldMustTemplate(inputDef, outputParser, summary, shouldSection, mustSection, example, partialVars, o1) {
15
- const outputFormat = outputParser.getFormatInstructions();
16
-
17
- // create should section prompt
19
+ async function resolvePartialVars(partialVars) {
20
+ if (!partialVars) return {};
21
+ const entries = await Promise.all(Object.entries(partialVars).map(async ([key, value]) => {
22
+ if (typeof value === "function") {
23
+ const result = value();
24
+ return [key, typeof result === "string" ? result : await result];
25
+ }
26
+ return [key, value];
27
+ }));
28
+ return Object.fromEntries(entries);
29
+ }
30
+ function replaceTemplateVariables(template, values) {
31
+ return template.replace(getVariableRegex(), (_, variable) => values[variable] ?? "");
32
+ }
33
+ export default async function createShouldMustTemplate(inputDef, summary, shouldSection, mustSection, example, partialVars) {
18
34
  const shouldSectionPrompt = (() => {
19
- if (!shouldSection) return "";
35
+ if (!(shouldSection !== null && shouldSection !== void 0 && shouldSection.length)) return "";
20
36
  const shouldSectionCount = shouldSection.length;
21
- if (shouldSectionCount === 0) return "";
22
-
23
- // create should section header
24
- const shouldSectionHeader = `# You Should\n
25
- The tasks assigned to you are you are from (a1) to (a${shouldSectionCount}) below.`;
26
- // create should section
37
+ const shouldSectionHeader = `# You Should\n\nThe tasks assigned to you are from (a1) to (a${shouldSectionCount}) below.`;
27
38
  const shouldSectionBody = shouldSection.map(elem => {
28
39
  const baseBody = `## (a${elem.no}) ${elem.title}`;
29
- if (elem.content) return `${baseBody}\n${elem.content}`;else return baseBody;
40
+ return elem.content ? `${baseBody}\n${elem.content}` : baseBody;
30
41
  }).join("\n\n");
31
- return shouldSectionHeader + shouldSectionBody;
42
+ return `${shouldSectionHeader}\n\n${shouldSectionBody}`;
32
43
  })();
33
-
34
- // create must section prompt
35
44
  const mustSectionPrompt = (() => {
36
- if (!mustSection) return "";
45
+ if (!(mustSection !== null && mustSection !== void 0 && mustSection.length)) return "";
37
46
  const mustSectionCount = mustSection.length;
38
- if (mustSectionCount === 0) return "";
39
-
40
- // create must section header
41
- const mustSectionHeader = `# You Must\n
42
- You must satisfy the following tasks from (b1) to (b${mustSectionCount}) below.\n\n`;
43
- // create must section
47
+ const mustSectionHeader = `# You Must\n\nYou must satisfy the following tasks from (b1) to (b${mustSectionCount}) below.`;
44
48
  const mustSectionBody = mustSection.map(elem => {
45
49
  const baseBody = `## (b${elem.no}) ${elem.title}`;
46
- if (elem.content) return `${baseBody}\n${elem.content}`;else return baseBody;
50
+ return elem.content ? `${baseBody}\n${elem.content}` : baseBody;
47
51
  }).join("\n\n");
48
- return mustSectionHeader + mustSectionBody;
52
+ return `${mustSectionHeader}\n\n${mustSectionBody}`;
49
53
  })();
50
-
51
- // create example section prompt
52
54
  const exampleSectionPrompt = (() => {
53
- if (!example) return "";
54
- const exampleSectionCount = example.length;
55
- if (exampleSectionCount === 0) return "";
56
-
57
- // create example section header
58
- const exampleSectionHeader = `# Example\n\n`;
59
-
60
- // create example section
55
+ if (!(example !== null && example !== void 0 && example.length)) return "";
61
56
  const exampleSectionBody = example.map(elem => `## (c${elem.no}) ${elem.title}\n${elem.content}`).join("\n\n");
62
- return exampleSectionHeader + exampleSectionBody;
57
+ return `# Example\n\n${exampleSectionBody}`;
63
58
  })();
64
-
65
- // Collect all variables used in sections
66
- 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(' ');
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(" ");
67
60
  const usedVariables = extractVariables(allSectionContent);
68
-
69
- // Get defined variables
70
61
  const definedInputVariables = inputDef.map(elem => elem.name);
71
62
  const definedPartialVariables = Object.keys(partialVars || {});
72
- const definedVariables = [...definedInputVariables, ...definedPartialVariables, 'outputFormat'];
73
-
74
- // Find undefined variables
63
+ const definedVariables = [...definedInputVariables, ...definedPartialVariables, "outputFormat"];
75
64
  const undefinedVariables = usedVariables.filter(variable => !definedVariables.includes(variable));
76
-
77
- // Output warning if undefined variables are found
78
65
  if (undefinedVariables.length > 0) {
79
- console.warn(`[ShouldMustTemplate] Warning: Found ${undefinedVariables.length} undefined variable(s) in template sections: [${undefinedVariables.join(', ')}]. These variables have been automatically added to the template.`);
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.`);
80
67
  }
81
-
82
- // Create auto-generated variables section for undefined variables
83
- const autoGeneratedVariablesSection = undefinedVariables.length > 0 ? `\n\n# Auto-Generated Variables\n\n${undefinedVariables.map(variable => `## ${variable}\n{${variable}}`).join('\n\n')}` : '';
84
- const systemPrompt = `${summary}\n\n${shouldSectionPrompt}\n\n${mustSectionPrompt}\n\n${exampleSectionPrompt}`;
85
- const humanPrompt = [inputDef.filter(elem => elem.type === "string").map(elem => `# ${elem.name}${elem.description ? "\n" + elem.description : ""}
86
- {${elem.name}}`).join("\n\n") + autoGeneratedVariablesSection].concat(inputDef.filter(elem => elem.type === "imageDataURL" && !o1).map(elem => {
87
- return {
88
- type: "image_url",
89
- image_url: `{${elem.name}}`
90
- };
91
- }));
92
-
93
- // Add undefined variables to input variables list
94
- const allInputVariables = inputDef.filter(elem => elem.type === "string" || elem.type === "imageDataURL" && !o1).map(elem => elem.name).concat(undefinedVariables);
95
- return new ChatPromptTemplate({
96
- promptMessages: [HumanMessagePromptTemplate.fromTemplate([systemPrompt + "\n\n{outputFormat}"].concat(humanPrompt))],
97
- inputVariables: allInputVariables,
98
- partialVariables: {
99
- outputFormat,
100
- ...partialVars
68
+ const autoGeneratedVariablesSection = undefinedVariables.length > 0 ? `\n\n# Auto-Generated Variables\n\n${undefinedVariables.map(variable => `## ${variable}\n{${variable}}`).join("\n\n")}` : "";
69
+ const systemPrompt = [summary, shouldSectionPrompt, mustSectionPrompt, exampleSectionPrompt].filter(Boolean).join("\n\n");
70
+ const stringInputPromptTemplate = inputDef.filter(elem => elem.type === "string").map(elem => `# ${elem.name}${elem.description ? `\n${elem.description}` : ""}\n{${elem.name}}`).join("\n\n");
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();
74
+ return {
75
+ async formatMessages(args) {
76
+ const resolvedPartialVars = await resolvePartialVars(partialVars || {});
77
+ const mergedArgs = Object.entries(args || {}).reduce((acc, [key, value]) => {
78
+ acc[key] = value ?? "";
79
+ return acc;
80
+ }, {});
81
+ const templateValues = {
82
+ ...mergedArgs,
83
+ ...resolvedPartialVars
84
+ };
85
+ undefinedVariables.forEach(variable => {
86
+ if (!(variable in templateValues)) {
87
+ templateValues[variable] = "";
88
+ }
89
+ });
90
+ const systemMessage = {
91
+ role: "system",
92
+ content: replaceTemplateVariables(systemTemplate, templateValues)
93
+ };
94
+ const userText = replaceTemplateVariables(userTextTemplate, templateValues);
95
+ const userContentParts = [];
96
+ if (userText.trim().length > 0) {
97
+ userContentParts.push({
98
+ type: "text",
99
+ text: userText
100
+ });
101
+ }
102
+ imageInputDefs.forEach(elem => {
103
+ const imageValue = templateValues[elem.name];
104
+ if (imageValue && imageValue.trim().length > 0) {
105
+ userContentParts.push({
106
+ type: "image",
107
+ image: imageValue
108
+ });
109
+ }
110
+ });
111
+ const userMessage = {
112
+ role: "user",
113
+ content: userContentParts.length > 0 ? userContentParts : ""
114
+ };
115
+ return [systemMessage, userMessage];
101
116
  }
102
- });
117
+ };
103
118
  }
104
119
  //# sourceMappingURL=ShouldMustTemplate.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ChatPromptTemplate","HumanMessagePromptTemplate","extractVariables","content","variableRegex","variables","match","exec","includes","push","createShouldMustTemplate","inputDef","outputParser","summary","shouldSection","mustSection","example","partialVars","o1","outputFormat","getFormatInstructions","shouldSectionPrompt","shouldSectionCount","length","shouldSectionHeader","shouldSectionBody","map","elem","baseBody","no","title","join","mustSectionPrompt","mustSectionCount","mustSectionHeader","mustSectionBody","exampleSectionPrompt","exampleSectionCount","exampleSectionHeader","exampleSectionBody","allSectionContent","s","usedVariables","definedInputVariables","name","definedPartialVariables","Object","keys","definedVariables","undefinedVariables","filter","variable","console","warn","autoGeneratedVariablesSection","systemPrompt","humanPrompt","type","description","concat","image_url","allInputVariables","promptMessages","fromTemplate","inputVariables","partialVariables"],"sourceRoot":"../../../src","sources":["templates/ShouldMustTemplate.ts"],"mappings":"AACA,SAASA,kBAAkB,EAAEC,0BAA0B,QAAqC,yBAAyB;AAKrH;AACA,SAASC,gBAAgBA,CAACC,OAAe,EAAY;EACjD,MAAMC,aAAa,GAAG,UAAU;EAChC,MAAMC,SAAmB,GAAG,EAAE;EAC9B,IAAIC,KAAK;EACT,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,eAAe,eAAeK,wBAAwBA,CAClDC,QAAoB,EACpBC,YAA8B,EAC9BC,OAAe,EACfC,aAA+B,EAC/BC,WAA6B,EAC7BC,OAAyB,EACzBC,WAA+E,EAC/EC,EAAY,EACyB;EACrC,MAAMC,YAAoB,GAAGP,YAAY,CAACQ,qBAAqB,CAAC,CAAC;;EAEjE;EACA,MAAMC,mBAA2B,GAAG,CAAC,MAAM;IACvC,IAAI,CAACP,aAAa,EAAE,OAAO,EAAE;IAE7B,MAAMQ,kBAA0B,GAAGR,aAAa,CAACS,MAAM;IACvD,IAAID,kBAAkB,KAAK,CAAC,EAAE,OAAO,EAAE;;IAEvC;IACA,MAAME,mBAA2B,GAAG;AAC5C,uDAAuDF,kBAAkB,UAAU;IAC3E;IACA,MAAMG,iBAAyB,GAAGX,aAAa,CAACY,GAAG,CAAEC,IAAI,IAAK;MAC1D,MAAMC,QAAgB,GAAG,QAAQD,IAAI,CAACE,EAAE,KAAKF,IAAI,CAACG,KAAK,EAAE;MACzD,IAAIH,IAAI,CAACxB,OAAO,EAAE,OAAO,GAAGyB,QAAQ,KAAKD,IAAI,CA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ACiB,IAAI,CAAC,CACxBe,MAAM,CAACV,kBAAkB,CAAC;EAE/B,OAAO,IAAIjD,kBAAkB,CAAC;IAC1B8D,cAAc,EAAE,CACZ7D,0BAA0B,CAAC8D,YAAY,CAAC,CAACR,YAAY,GAAG,oBAAoB,CAAC,CAACI,MAAM,CAACH,WAAW,CAAC,CAAC,CACrG;IACDQ,cAAc,EAAEH,iBAAiB;IACjCI,gBAAgB,EAAE;MACd9C,YAAY;MACZ,GAAGF;IACP;EACJ,CAAC,CAAC;AACN","ignoreList":[]}
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","allSectionContent","s","usedVariables","definedInputVariables","name","definedPartialVariables","keys","definedVariables","undefinedVariables","filter","console","warn","autoGeneratedVariablesSection","systemPrompt","Boolean","stringInputPromptTemplate","type","description","imageInputDefs","systemTemplate","trim","userTextTemplate","formatMessages","args","resolvedPartialVars","mergedArgs","reduce","acc","templateValues","forEach","systemMessage","role","userText","userContentParts","text","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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