@autobe/agent 0.25.3 → 0.25.5
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/AutoBeAgent.js +2 -0
- package/lib/AutoBeAgent.js.map +1 -1
- package/lib/AutoBeMockAgent.js +1 -1
- package/lib/AutoBeMockAgent.js.map +1 -1
- package/lib/factory/consentFunctionCall.js +2 -0
- package/lib/factory/consentFunctionCall.js.map +1 -1
- package/lib/factory/createAutoBeContext.js +2 -0
- package/lib/factory/createAutoBeContext.js.map +1 -1
- package/lib/factory/supportMistral.d.ts +4 -0
- package/lib/factory/supportMistral.js +112 -0
- package/lib/factory/supportMistral.js.map +1 -0
- package/lib/index.mjs +1997 -1422
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/common/orchestrateCommonCorrectCasting.d.ts +1 -0
- package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js +370 -275
- package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +1 -1
- package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js +370 -275
- package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeCorrect.js +304 -221
- package/lib/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeWrite.js +303 -220
- package/lib/orchestrate/realize/orchestrateRealizeWrite.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestCorrect.js +17 -22
- package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js +372 -277
- package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestWrite.js +322 -350
- package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
- package/lib/utils/validateEmptyCode.d.ts +8 -0
- package/lib/utils/validateEmptyCode.js +35 -0
- package/lib/utils/validateEmptyCode.js.map +1 -0
- package/package.json +5 -5
- package/src/AutoBeAgent.ts +2 -0
- package/src/AutoBeMockAgent.ts +1 -1
- package/src/factory/consentFunctionCall.ts +3 -0
- package/src/factory/createAutoBeContext.ts +2 -0
- package/src/factory/supportMistral.ts +122 -0
- package/src/orchestrate/common/orchestrateCommonCorrectCasting.ts +52 -10
- package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +1 -1
- package/src/orchestrate/realize/orchestRateRealizeCorrectCasting.ts +58 -17
- package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +51 -15
- package/src/orchestrate/realize/orchestrateRealizeWrite.ts +46 -12
- package/src/orchestrate/test/orchestrateTestCorrect.ts +17 -24
- package/src/orchestrate/test/orchestrateTestCorrectInvalidRequest.ts +57 -10
- package/src/orchestrate/test/orchestrateTestWrite.ts +41 -10
- package/src/utils/validateEmptyCode.ts +41 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrateTestWrite.js","sourceRoot":"","sources":["../../../src/orchestrate/test/orchestrateTestWrite.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"orchestrateTestWrite.js","sourceRoot":"","sources":["../../../src/orchestrate/test/orchestrateTestWrite.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,oDAwCC;;;AAvDD,kDAA0B;AAC1B,uEAAoE;AACpE,+BAA0B;AAG1B,uEAAoE;AACpE,uEAAoE;AACpE,qEAAkE;AAClE,iEAA8D;AAC9D,iFAA8E;AAC9E,yFAAsF;AAKtF,SAAsB,oBAAoB,CACxC,GAAyB,EACzB,KAGC;;QAED,MAAM,QAAQ,GAA4B;YACxC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM;YAC7B,SAAS,EAAE,CAAC;S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,WAAW;QACX,OAAO,EAAE;YACP,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE;gBACd,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACpB,CAAC;SACoC;KACxC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,GAAG;IACjB,OAAO,EAAE,CAAC,QAAmB,EAAE,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uHAC+B;YAC5D,QAAQ,EAAE;gBACR,KAAK,EAAE,QAAQ;aAChB;SACF;;QAAC;IACJ,MAAM,EAAE,CAAC,QAAmB,EAAE,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uHAC+B;YAC3D,QAAQ,EAAE;gBACR,KAAK,EAAE,QAAQ;aAChB;SACF;;QAAC;CACL,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateEmptyCode = void 0;
|
|
4
|
+
const utils_1 = require("@autobe/utils");
|
|
5
|
+
const validateEmptyCode = (props) => {
|
|
6
|
+
const errors = [];
|
|
7
|
+
if (props.draft.includes(props.functionName) === false)
|
|
8
|
+
errors.push({
|
|
9
|
+
path: "$input.draft",
|
|
10
|
+
expected: `string (including function named '${props.functionName}')`,
|
|
11
|
+
value: props.draft,
|
|
12
|
+
description: description(props.functionName),
|
|
13
|
+
});
|
|
14
|
+
if (props.revise.final !== null &&
|
|
15
|
+
props.revise.final.includes(props.functionName) === false)
|
|
16
|
+
errors.push({
|
|
17
|
+
path: "$input.revise.final",
|
|
18
|
+
expected: `string (including function named '${props.functionName}')`,
|
|
19
|
+
value: props.revise.final,
|
|
20
|
+
description: description(props.functionName),
|
|
21
|
+
});
|
|
22
|
+
return errors;
|
|
23
|
+
};
|
|
24
|
+
exports.validateEmptyCode = validateEmptyCode;
|
|
25
|
+
const description = (func) => utils_1.StringUtil.trim `
|
|
26
|
+
The function ${func} does not exist in the provided code snippet.
|
|
27
|
+
|
|
28
|
+
The first reason of the non-existence is that the code snippet is empty,
|
|
29
|
+
and the second reason is that AI has written different function name
|
|
30
|
+
by mistake.
|
|
31
|
+
|
|
32
|
+
Please make sure that the code snippet includes the function ${func}.
|
|
33
|
+
Note that, you never have to write empty code or different function name.
|
|
34
|
+
`;
|
|
35
|
+
//# sourceMappingURL=validateEmptyCode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateEmptyCode.js","sourceRoot":"","sources":["../../src/utils/validateEmptyCode.ts"],"names":[],"mappings":";;;AAAA,yCAA2C;AAGpC,MAAM,iBAAiB,GAAG,CAAC,KAMjC,EAAwB,EAAE;IACzB,MAAM,MAAM,GAAyB,EAAE,CAAC;IACxC,IAAI,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,KAAK;QACpD,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,cAAc;YACpB,QAAQ,EAAE,qCAAqC,KAAK,CAAC,YAAY,IAAI;YACrE,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,WAAW,EAAE,WAAW,CAAC,KAAK,CAAC,YAAY,CAAC;SAC7C,CAAC,CAAC;IACL,IACE,KAAK,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI;QAC3B,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,KAAK;QAEzD,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,qBAAqB;YAC3B,QAAQ,EAAE,qCAAqC,KAAK,CAAC,YAAY,IAAI;YACrE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK;YACzB,WAAW,EAAE,WAAW,CAAC,KAAK,CAAC,YAAY,CAAC;SAC7C,CAAC,CAAC;IACL,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AA1BW,QAAA,iBAAiB,qBA0B5B;AAEF,MAAM,WAAW,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,kBAAU,CAAC,IAAI,CAAA;iBAC5C,IAAI;;;;;;iEAM4C,IAAI;;CAEpE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autobe/agent",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.5",
|
|
4
4
|
"description": "AI backend server code generator",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "Wrtn Technologies",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"tstl": "^3.0.0",
|
|
28
28
|
"typia": "^9.7.2",
|
|
29
29
|
"uuid": "^11.1.0",
|
|
30
|
-
"@autobe/
|
|
31
|
-
"@autobe/
|
|
30
|
+
"@autobe/interface": "^0.25.5",
|
|
31
|
+
"@autobe/utils": "^0.25.5"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@rollup/plugin-json": "^6.1.0",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"ts-node": "^10.9.2",
|
|
41
41
|
"ts-patch": "^3.3.0",
|
|
42
42
|
"typescript": "~5.9.2",
|
|
43
|
-
"@autobe/compiler": "^0.25.
|
|
44
|
-
"@autobe/filesystem": "^0.25.
|
|
43
|
+
"@autobe/compiler": "^0.25.5",
|
|
44
|
+
"@autobe/filesystem": "^0.25.5"
|
|
45
45
|
},
|
|
46
46
|
"keywords": [
|
|
47
47
|
"ai",
|
package/src/AutoBeAgent.ts
CHANGED
|
@@ -27,6 +27,7 @@ import { createAgenticaHistory } from "./factory/createAgenticaHistory";
|
|
|
27
27
|
import { createAutoBeController } from "./factory/createAutoBeApplication";
|
|
28
28
|
import { createAutoBeContext } from "./factory/createAutoBeContext";
|
|
29
29
|
import { createAutoBeState } from "./factory/createAutoBeState";
|
|
30
|
+
import { supportMistral } from "./factory/supportMistral";
|
|
30
31
|
import { transformFacadeStateMessage } from "./orchestrate/facade/transformFacadeStateMessage";
|
|
31
32
|
import { IAutoBeProps } from "./structures/IAutoBeProps";
|
|
32
33
|
import { randomBackoffStrategy } from "./utils/backoffRetry";
|
|
@@ -162,6 +163,7 @@ export class AutoBeAgent<Model extends ILlmSchema.Model>
|
|
|
162
163
|
}),
|
|
163
164
|
],
|
|
164
165
|
});
|
|
166
|
+
supportMistral(this.agentica_, props.vendor);
|
|
165
167
|
|
|
166
168
|
// HISTORIES MANIPULATION
|
|
167
169
|
this.agentica_.getHistories().push(
|
package/src/AutoBeMockAgent.ts
CHANGED
|
@@ -193,7 +193,7 @@ const sleepMap: Record<AutoBeEvent.Type, number> = {
|
|
|
193
193
|
interfaceSchemasReview: 400,
|
|
194
194
|
interfaceComplement: 2_000,
|
|
195
195
|
interfaceComplete: 1_000,
|
|
196
|
-
interfacePrerequisites:
|
|
196
|
+
interfacePrerequisites: 400,
|
|
197
197
|
// TEST
|
|
198
198
|
testStart: 1_000,
|
|
199
199
|
testScenarios: 40,
|
|
@@ -16,6 +16,7 @@ import { AutoBeConfigConstant } from "../constants/AutoBeConfigConstant";
|
|
|
16
16
|
import { AutoBeSystemPromptConstant } from "../constants/AutoBeSystemPromptConstant";
|
|
17
17
|
import { IAutoBeConfig } from "../structures/IAutoBeConfig";
|
|
18
18
|
import { IAutoBeVendor } from "../structures/IAutoBeVendor";
|
|
19
|
+
import { supportMistral } from "./supportMistral";
|
|
19
20
|
|
|
20
21
|
export const consentFunctionCall = async (props: {
|
|
21
22
|
dispatch: (event: AutoBeEvent) => void;
|
|
@@ -67,6 +68,8 @@ export const consentFunctionCall = async (props: {
|
|
|
67
68
|
} satisfies IConsentApplication),
|
|
68
69
|
],
|
|
69
70
|
});
|
|
71
|
+
supportMistral(agent, props.vendor);
|
|
72
|
+
|
|
70
73
|
const histories: MicroAgenticaHistory<"chatgpt">[] = await agent.conversate(
|
|
71
74
|
"Analyze and judge this assistant message please.",
|
|
72
75
|
);
|
|
@@ -41,6 +41,7 @@ import { AutoBeTimeoutError } from "../utils/AutoBeTimeoutError";
|
|
|
41
41
|
import { TimedConversation } from "../utils/TimedConversation";
|
|
42
42
|
import { consentFunctionCall } from "./consentFunctionCall";
|
|
43
43
|
import { getCriticalCompiler } from "./getCriticalCompiler";
|
|
44
|
+
import { supportMistral } from "./supportMistral";
|
|
44
45
|
|
|
45
46
|
export const createAutoBeContext = <Model extends ILlmSchema.Model>(props: {
|
|
46
47
|
model: Model;
|
|
@@ -104,6 +105,7 @@ export const createAutoBeContext = <Model extends ILlmSchema.Model>(props: {
|
|
|
104
105
|
histories: next.histories,
|
|
105
106
|
controllers: [next.controller],
|
|
106
107
|
});
|
|
108
|
+
supportMistral(agent, props.vendor);
|
|
107
109
|
|
|
108
110
|
// ADD EVENT LISTENERS
|
|
109
111
|
agent.on("request", async (event) => {
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { MicroAgentica } from "@agentica/core";
|
|
2
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
3
|
+
import OpenAI from "openai";
|
|
4
|
+
|
|
5
|
+
import { IAutoBeVendor } from "../structures/IAutoBeVendor";
|
|
6
|
+
|
|
7
|
+
export const supportMistral = <Model extends ILlmSchema.Model>(
|
|
8
|
+
agent: MicroAgentica<Model>,
|
|
9
|
+
vendor: IAutoBeVendor,
|
|
10
|
+
): void => {
|
|
11
|
+
if (
|
|
12
|
+
vendor.model.includes("mistral") ||
|
|
13
|
+
vendor.model.includes("devstral") ||
|
|
14
|
+
vendor.model.includes("codestral")
|
|
15
|
+
) {
|
|
16
|
+
agent.on("request", async (e) => {
|
|
17
|
+
const newMessages: OpenAI.ChatCompletionMessageParam[] = [];
|
|
18
|
+
for (const m of e.body.messages) {
|
|
19
|
+
newMessages.push(m);
|
|
20
|
+
if (m.role === "tool") {
|
|
21
|
+
m.tool_call_id = uuidToShortId(m.tool_call_id);
|
|
22
|
+
newMessages.push({
|
|
23
|
+
role: "assistant",
|
|
24
|
+
content: "A tool has been called.",
|
|
25
|
+
});
|
|
26
|
+
} else if (m.role === "assistant") {
|
|
27
|
+
for (const call of m.tool_calls ?? [])
|
|
28
|
+
call.id = uuidToShortId(call.id);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
e.body.messages = newMessages;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// agent.on("request", (e) => {
|
|
35
|
+
// const toolCalls: OpenAI.ChatCompletionMessageFunctionToolCall[] =
|
|
36
|
+
// e.body.messages
|
|
37
|
+
// .filter((m) => m.role === "assistant")
|
|
38
|
+
// .filter((m) => !!m.tool_calls?.length)
|
|
39
|
+
// .map((m) => m.tool_calls ?? [])
|
|
40
|
+
// .flat()
|
|
41
|
+
// .filter((c) => c.type === "function");
|
|
42
|
+
// e.body.messages.forEach((m, i, array) => {
|
|
43
|
+
// if (m.role !== "tool") return;
|
|
44
|
+
// const call: OpenAI.ChatCompletionMessageFunctionToolCall | undefined =
|
|
45
|
+
// toolCalls.find((c) => c.id === m.tool_call_id);
|
|
46
|
+
// const content: string = getFunctionCallMessage(m, call);
|
|
47
|
+
// array[i] = {
|
|
48
|
+
// role: "assistant",
|
|
49
|
+
// content,
|
|
50
|
+
// };
|
|
51
|
+
// });
|
|
52
|
+
// e.body.messages = e.body.messages.filter(
|
|
53
|
+
// (m) => m.role !== "assistant" || !m.tool_calls?.length,
|
|
54
|
+
// );
|
|
55
|
+
// });
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// const getFunctionCallMessage = (
|
|
60
|
+
// param: OpenAI.ChatCompletionToolMessageParam,
|
|
61
|
+
// call: OpenAI.ChatCompletionMessageFunctionToolCall | undefined,
|
|
62
|
+
// ): string => {
|
|
63
|
+
// if (call === undefined) {
|
|
64
|
+
// // unreachable
|
|
65
|
+
// return StringUtil.trim`
|
|
66
|
+
// ## Function Call
|
|
67
|
+
|
|
68
|
+
// A function has been called, but could not find its arguments.
|
|
69
|
+
|
|
70
|
+
// - id: ${param.tool_call_id}
|
|
71
|
+
// - content: ${param.content}
|
|
72
|
+
// `;
|
|
73
|
+
// }
|
|
74
|
+
// return StringUtil.trim`
|
|
75
|
+
// ## Function Call
|
|
76
|
+
|
|
77
|
+
// - id: ${call.id}
|
|
78
|
+
// - function name: ${call.function.name}
|
|
79
|
+
// - arguments: ${JSON.stringify(call.function.arguments)}
|
|
80
|
+
// - content: ${param.content}
|
|
81
|
+
// `;
|
|
82
|
+
// };
|
|
83
|
+
|
|
84
|
+
const BASE62_CHARS =
|
|
85
|
+
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
86
|
+
|
|
87
|
+
function simpleHash(str: string): number {
|
|
88
|
+
let h1 = 0xdeadbeef;
|
|
89
|
+
let h2 = 0x41c6ce57;
|
|
90
|
+
|
|
91
|
+
for (let i = 0; i < str.length; i++) {
|
|
92
|
+
const ch = str.charCodeAt(i);
|
|
93
|
+
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
94
|
+
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
h1 =
|
|
98
|
+
Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^
|
|
99
|
+
Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
|
100
|
+
h2 =
|
|
101
|
+
Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^
|
|
102
|
+
Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
103
|
+
|
|
104
|
+
return 4294967296 * (2097151 & h2) + (h1 >>> 0);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function toBase62(num: number, length: number): string {
|
|
108
|
+
let result = "";
|
|
109
|
+
let n = num;
|
|
110
|
+
|
|
111
|
+
while (n > 0 && result.length < length) {
|
|
112
|
+
result = BASE62_CHARS[n % 62] + result;
|
|
113
|
+
n = Math.floor(n / 62);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return result.padStart(length, "0");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function uuidToShortId(uuid: string): string {
|
|
120
|
+
const hash = simpleHash(uuid);
|
|
121
|
+
return toBase62(hash, 9);
|
|
122
|
+
}
|
|
@@ -7,12 +7,18 @@ import {
|
|
|
7
7
|
IAutoBeTypeScriptCompileResult,
|
|
8
8
|
} from "@autobe/interface";
|
|
9
9
|
import { StringUtil } from "@autobe/utils";
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
ILlmApplication,
|
|
12
|
+
ILlmController,
|
|
13
|
+
ILlmSchema,
|
|
14
|
+
IValidation,
|
|
15
|
+
} from "@samchon/openapi";
|
|
11
16
|
import { IPointer } from "tstl";
|
|
12
17
|
import typia from "typia";
|
|
13
18
|
|
|
14
19
|
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
15
20
|
import { assertSchemaModel } from "../../context/assertSchemaModel";
|
|
21
|
+
import { validateEmptyCode } from "../../utils/validateEmptyCode";
|
|
16
22
|
import { transformCommonCorrectCastingHistories } from "./histories/transformCommonCorrectCastingHistories";
|
|
17
23
|
import { IAutoBeCommonCorrectCastingApplication } from "./structures/IAutoBeCommonCorrectCastingApplication";
|
|
18
24
|
|
|
@@ -31,6 +37,7 @@ interface IFactoryProps<
|
|
|
31
37
|
}): CorrectEvent;
|
|
32
38
|
script(event: ValidateEvent): string;
|
|
33
39
|
source: "testCorrect" | "realizeCorrect";
|
|
40
|
+
functionName: string;
|
|
34
41
|
}
|
|
35
42
|
|
|
36
43
|
export const orchestrateCommonCorrectCasting = async <
|
|
@@ -96,6 +103,7 @@ const correct = async <
|
|
|
96
103
|
),
|
|
97
104
|
controller: createController({
|
|
98
105
|
model: ctx.model,
|
|
106
|
+
functionName: factory.functionName,
|
|
99
107
|
then: (next) => {
|
|
100
108
|
pointer.value = next;
|
|
101
109
|
},
|
|
@@ -136,13 +144,31 @@ const correct = async <
|
|
|
136
144
|
|
|
137
145
|
const createController = <Model extends ILlmSchema.Model>(props: {
|
|
138
146
|
model: Model;
|
|
147
|
+
functionName: string;
|
|
139
148
|
then: (next: IAutoBeCommonCorrectCastingApplication.IProps) => void;
|
|
140
149
|
reject: () => void;
|
|
141
150
|
}): ILlmController<Model> => {
|
|
142
151
|
assertSchemaModel(props.model);
|
|
152
|
+
const validate: Validator = (input) => {
|
|
153
|
+
const result: IValidation<IAutoBeCommonCorrectCastingApplication.IProps> =
|
|
154
|
+
typia.validate<IAutoBeCommonCorrectCastingApplication.IProps>(input);
|
|
155
|
+
if (result.success === false) return result;
|
|
156
|
+
const errors: IValidation.IError[] = validateEmptyCode({
|
|
157
|
+
functionName: props.functionName,
|
|
158
|
+
draft: result.data.draft,
|
|
159
|
+
revise: result.data.revise,
|
|
160
|
+
});
|
|
161
|
+
return errors.length
|
|
162
|
+
? {
|
|
163
|
+
success: false,
|
|
164
|
+
errors,
|
|
165
|
+
data: result.data,
|
|
166
|
+
}
|
|
167
|
+
: result;
|
|
168
|
+
};
|
|
143
169
|
const application = collection[
|
|
144
170
|
props.model === "chatgpt" ? "chatgpt" : "claude"
|
|
145
|
-
] satisfies ILlmApplication<any> as any as ILlmApplication<Model>;
|
|
171
|
+
](validate) satisfies ILlmApplication<any> as any as ILlmApplication<Model>;
|
|
146
172
|
return {
|
|
147
173
|
protocol: "class",
|
|
148
174
|
name: "correctInvalidRequest",
|
|
@@ -159,12 +185,28 @@ const createController = <Model extends ILlmSchema.Model>(props: {
|
|
|
159
185
|
};
|
|
160
186
|
|
|
161
187
|
const collection = {
|
|
162
|
-
chatgpt:
|
|
163
|
-
IAutoBeCommonCorrectCastingApplication,
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
188
|
+
chatgpt: (validate: Validator) =>
|
|
189
|
+
typia.llm.application<IAutoBeCommonCorrectCastingApplication, "chatgpt">({
|
|
190
|
+
validate: {
|
|
191
|
+
rewrite: validate,
|
|
192
|
+
reject: () => ({
|
|
193
|
+
success: true,
|
|
194
|
+
data: undefined,
|
|
195
|
+
}),
|
|
196
|
+
},
|
|
197
|
+
}),
|
|
198
|
+
claude: (validate: Validator) =>
|
|
199
|
+
typia.llm.application<IAutoBeCommonCorrectCastingApplication, "claude">({
|
|
200
|
+
validate: {
|
|
201
|
+
rewrite: validate,
|
|
202
|
+
reject: () => ({
|
|
203
|
+
success: true,
|
|
204
|
+
data: undefined,
|
|
205
|
+
}),
|
|
206
|
+
},
|
|
207
|
+
}),
|
|
170
208
|
};
|
|
209
|
+
|
|
210
|
+
type Validator = (
|
|
211
|
+
input: unknown,
|
|
212
|
+
) => IValidation<IAutoBeCommonCorrectCastingApplication.IProps>;
|
|
@@ -27,7 +27,7 @@ export function orchestratePrismaCorrect<Model extends ILlmSchema.Model>(
|
|
|
27
27
|
return true;
|
|
28
28
|
});
|
|
29
29
|
application.files = application.files.filter((f) => f.models.length !== 0);
|
|
30
|
-
return iterate(ctx, application, Math.max(ctx.retry,
|
|
30
|
+
return iterate(ctx, application, Math.max(ctx.retry, 8));
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
async function iterate<Model extends ILlmSchema.Model>(
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AutoBeOpenApi,
|
|
2
3
|
AutoBeProgressEventBase,
|
|
3
4
|
AutoBeRealizeAuthorization,
|
|
4
5
|
AutoBeRealizeFunction,
|
|
@@ -6,7 +7,12 @@ import {
|
|
|
6
7
|
IAutoBeTypeScriptCompileResult,
|
|
7
8
|
} from "@autobe/interface";
|
|
8
9
|
import { StringUtil } from "@autobe/utils";
|
|
9
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
ILlmApplication,
|
|
12
|
+
ILlmController,
|
|
13
|
+
ILlmSchema,
|
|
14
|
+
IValidation,
|
|
15
|
+
} from "@samchon/openapi";
|
|
10
16
|
import { IPointer } from "tstl";
|
|
11
17
|
import typia from "typia";
|
|
12
18
|
import { v7 } from "uuid";
|
|
@@ -14,6 +20,7 @@ import { v7 } from "uuid";
|
|
|
14
20
|
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
15
21
|
import { assertSchemaModel } from "../../context/assertSchemaModel";
|
|
16
22
|
import { executeCachedBatch } from "../../utils/executeCachedBatch";
|
|
23
|
+
import { validateEmptyCode } from "../../utils/validateEmptyCode";
|
|
17
24
|
import { IAutoBeCommonCorrectCastingApplication } from "../common/structures/IAutoBeCommonCorrectCastingApplication";
|
|
18
25
|
import { transformRealizeCorrectCastingHistories } from "./histories/transformRealizeCorrectCastingHistories";
|
|
19
26
|
import { compileRealizeFiles } from "./internal/compileRealizeFiles";
|
|
@@ -113,13 +120,12 @@ const correct = async <Model extends ILlmSchema.Model>(
|
|
|
113
120
|
const func: AutoBeRealizeFunction = functions.find(
|
|
114
121
|
(f) => f.location === location,
|
|
115
122
|
)!;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const operation = scenario.operation;
|
|
120
|
-
const authorization =
|
|
121
|
-
(a) => a.role.name === operation.authorizationRole
|
|
122
|
-
);
|
|
123
|
+
const scenario: IAutoBeRealizeScenarioResult = scenarios.find(
|
|
124
|
+
(s) => s.location === func.location,
|
|
125
|
+
)!;
|
|
126
|
+
const operation: AutoBeOpenApi.IOperation = scenario.operation;
|
|
127
|
+
const authorization: AutoBeRealizeAuthorization | undefined =
|
|
128
|
+
authorizations.find((a) => a.role.name === operation.authorizationRole);
|
|
123
129
|
|
|
124
130
|
const pointer: IPointer<
|
|
125
131
|
IAutoBeCommonCorrectCastingApplication.IProps | false | null
|
|
@@ -137,6 +143,7 @@ const correct = async <Model extends ILlmSchema.Model>(
|
|
|
137
143
|
]),
|
|
138
144
|
controller: createController({
|
|
139
145
|
model: ctx.model,
|
|
146
|
+
functionName: scenario.functionName,
|
|
140
147
|
then: (next) => {
|
|
141
148
|
pointer.value = next;
|
|
142
149
|
},
|
|
@@ -373,13 +380,31 @@ const filterRelevantDiagnostics = (
|
|
|
373
380
|
|
|
374
381
|
const createController = <Model extends ILlmSchema.Model>(props: {
|
|
375
382
|
model: Model;
|
|
383
|
+
functionName: string;
|
|
376
384
|
then: (next: IAutoBeCommonCorrectCastingApplication.IProps) => void;
|
|
377
385
|
reject: () => void;
|
|
378
386
|
}): ILlmController<Model> => {
|
|
379
387
|
assertSchemaModel(props.model);
|
|
388
|
+
const validate: Validator = (input) => {
|
|
389
|
+
const result: IValidation<IAutoBeCommonCorrectCastingApplication.IProps> =
|
|
390
|
+
typia.validate<IAutoBeCommonCorrectCastingApplication.IProps>(input);
|
|
391
|
+
if (result.success === false) return result;
|
|
392
|
+
const errors: IValidation.IError[] = validateEmptyCode({
|
|
393
|
+
functionName: props.functionName,
|
|
394
|
+
draft: result.data.draft,
|
|
395
|
+
revise: result.data.revise,
|
|
396
|
+
});
|
|
397
|
+
return errors.length
|
|
398
|
+
? {
|
|
399
|
+
success: false,
|
|
400
|
+
errors,
|
|
401
|
+
data: result.data,
|
|
402
|
+
}
|
|
403
|
+
: result;
|
|
404
|
+
};
|
|
380
405
|
const application = collection[
|
|
381
406
|
props.model === "chatgpt" ? "chatgpt" : "claude"
|
|
382
|
-
] satisfies ILlmApplication<any> as any as ILlmApplication<Model>;
|
|
407
|
+
](validate) satisfies ILlmApplication<any> as any as ILlmApplication<Model>;
|
|
383
408
|
return {
|
|
384
409
|
protocol: "class",
|
|
385
410
|
name: "correctInvalidRequest",
|
|
@@ -396,12 +421,28 @@ const createController = <Model extends ILlmSchema.Model>(props: {
|
|
|
396
421
|
};
|
|
397
422
|
|
|
398
423
|
const collection = {
|
|
399
|
-
chatgpt:
|
|
400
|
-
IAutoBeCommonCorrectCastingApplication,
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
424
|
+
chatgpt: (validate: Validator) =>
|
|
425
|
+
typia.llm.application<IAutoBeCommonCorrectCastingApplication, "chatgpt">({
|
|
426
|
+
validate: {
|
|
427
|
+
rewrite: validate,
|
|
428
|
+
reject: () => ({
|
|
429
|
+
success: true,
|
|
430
|
+
data: undefined,
|
|
431
|
+
}),
|
|
432
|
+
},
|
|
433
|
+
}),
|
|
434
|
+
claude: (validate: Validator) =>
|
|
435
|
+
typia.llm.application<IAutoBeCommonCorrectCastingApplication, "claude">({
|
|
436
|
+
validate: {
|
|
437
|
+
rewrite: validate,
|
|
438
|
+
reject: () => ({
|
|
439
|
+
success: true,
|
|
440
|
+
data: undefined,
|
|
441
|
+
}),
|
|
442
|
+
},
|
|
443
|
+
}),
|
|
407
444
|
};
|
|
445
|
+
|
|
446
|
+
type Validator = (
|
|
447
|
+
input: unknown,
|
|
448
|
+
) => IValidation<IAutoBeCommonCorrectCastingApplication.IProps>;
|
|
@@ -5,7 +5,12 @@ import {
|
|
|
5
5
|
AutoBeRealizeFunction,
|
|
6
6
|
} from "@autobe/interface";
|
|
7
7
|
import { StringUtil } from "@autobe/utils";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
ILlmApplication,
|
|
10
|
+
ILlmController,
|
|
11
|
+
ILlmSchema,
|
|
12
|
+
IValidation,
|
|
13
|
+
} from "@samchon/openapi";
|
|
9
14
|
import { IPointer } from "tstl";
|
|
10
15
|
import typia from "typia";
|
|
11
16
|
import { v7 } from "uuid";
|
|
@@ -13,6 +18,7 @@ import { v7 } from "uuid";
|
|
|
13
18
|
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
14
19
|
import { assertSchemaModel } from "../../context/assertSchemaModel";
|
|
15
20
|
import { executeCachedBatch } from "../../utils/executeCachedBatch";
|
|
21
|
+
import { validateEmptyCode } from "../../utils/validateEmptyCode";
|
|
16
22
|
import { transformRealizeCorrectHistories } from "./histories/transformRealizeCorrectHistories";
|
|
17
23
|
import { compileRealizeFiles } from "./internal/compileRealizeFiles";
|
|
18
24
|
import { IAutoBeRealizeCorrectApplication } from "./structures/IAutoBeRealizeCorrectApplication";
|
|
@@ -70,9 +76,10 @@ export async function orchestrateRealizeCorrect<Model extends ILlmSchema.Model>(
|
|
|
70
76
|
if (!location.startsWith("src/providers")) return;
|
|
71
77
|
|
|
72
78
|
if (!diagnosticsByFile[location]) {
|
|
73
|
-
const func = functions.find(
|
|
74
|
-
|
|
75
|
-
|
|
79
|
+
const func: AutoBeRealizeFunction | undefined = functions.find(
|
|
80
|
+
(f) => f.location === location,
|
|
81
|
+
);
|
|
82
|
+
if (func === undefined) {
|
|
76
83
|
return;
|
|
77
84
|
}
|
|
78
85
|
|
|
@@ -195,6 +202,7 @@ async function step<Model extends ILlmSchema.Model>(
|
|
|
195
202
|
source: "realizeCorrect",
|
|
196
203
|
controller: createController({
|
|
197
204
|
model: ctx.model,
|
|
205
|
+
functionName: props.scenario.functionName,
|
|
198
206
|
build: (next) => {
|
|
199
207
|
pointer.value = next;
|
|
200
208
|
},
|
|
@@ -268,12 +276,33 @@ async function step<Model extends ILlmSchema.Model>(
|
|
|
268
276
|
|
|
269
277
|
function createController<Model extends ILlmSchema.Model>(props: {
|
|
270
278
|
model: Model;
|
|
279
|
+
functionName: string;
|
|
271
280
|
build: (next: IAutoBeRealizeCorrectApplication.IProps) => void;
|
|
272
281
|
}): ILlmController<Model> {
|
|
273
282
|
assertSchemaModel(props.model);
|
|
283
|
+
|
|
284
|
+
const validate: Validator = (input) => {
|
|
285
|
+
const result: IValidation<IAutoBeRealizeCorrectApplication.IProps> =
|
|
286
|
+
typia.validate<IAutoBeRealizeCorrectApplication.IProps>(input);
|
|
287
|
+
if (result.success === false) return result;
|
|
288
|
+
const errors: IValidation.IError[] = validateEmptyCode({
|
|
289
|
+
functionName: props.functionName,
|
|
290
|
+
draft: result.data.draft,
|
|
291
|
+
revise: result.data.revise,
|
|
292
|
+
});
|
|
293
|
+
return errors.length
|
|
294
|
+
? {
|
|
295
|
+
success: false,
|
|
296
|
+
errors,
|
|
297
|
+
data: result.data,
|
|
298
|
+
}
|
|
299
|
+
: result;
|
|
300
|
+
};
|
|
274
301
|
const application: ILlmApplication<Model> = collection[
|
|
275
|
-
props.model
|
|
276
|
-
]
|
|
302
|
+
props.model === "chatgpt" ? "chatgpt" : "claude"
|
|
303
|
+
](
|
|
304
|
+
validate,
|
|
305
|
+
) satisfies ILlmApplication<any> as unknown as ILlmApplication<Model>;
|
|
277
306
|
|
|
278
307
|
return {
|
|
279
308
|
protocol: "class",
|
|
@@ -287,14 +316,21 @@ function createController<Model extends ILlmSchema.Model>(props: {
|
|
|
287
316
|
};
|
|
288
317
|
}
|
|
289
318
|
|
|
290
|
-
const claude = typia.llm.application<
|
|
291
|
-
IAutoBeRealizeCorrectApplication,
|
|
292
|
-
"claude"
|
|
293
|
-
>();
|
|
294
319
|
const collection = {
|
|
295
|
-
chatgpt:
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
320
|
+
chatgpt: (validate: Validator) =>
|
|
321
|
+
typia.llm.application<IAutoBeRealizeCorrectApplication, "chatgpt">({
|
|
322
|
+
validate: {
|
|
323
|
+
correct: validate,
|
|
324
|
+
},
|
|
325
|
+
}),
|
|
326
|
+
claude: (validate: Validator) =>
|
|
327
|
+
typia.llm.application<IAutoBeRealizeCorrectApplication, "claude">({
|
|
328
|
+
validate: {
|
|
329
|
+
correct: validate,
|
|
330
|
+
},
|
|
331
|
+
}),
|
|
300
332
|
};
|
|
333
|
+
|
|
334
|
+
type Validator = (
|
|
335
|
+
input: unknown,
|
|
336
|
+
) => IValidation<IAutoBeRealizeCorrectApplication.IProps>;
|