@autobe/agent 0.25.4 → 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/AutoBeMockAgent.js +1 -1
- package/lib/AutoBeMockAgent.js.map +1 -1
- package/lib/index.mjs +1943 -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/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/AutoBeMockAgent.ts +1 -1
- package/src/orchestrate/common/orchestrateCommonCorrectCasting.ts +52 -10
- 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;SACb,CAAC;QACF,MAAM,MAAM,GAAyC,MAAM,IAAA,uCAAkB;QAC3E;;;;WAIG;QACH,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAO,cAAc,EAAE,EAAE;YACzD,IAAI,CAAC;gBACH,MAAM,SAAS,GACb,MAAM,IAAA,mDAAwB,EAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;gBAChD,MAAM,KAAK,GAAyB,MAAM,OAAO,CAAC,GAAG,EAAE;oBACrD,QAAQ;oBACR,SAAS;oBACT,QAAQ;oBACR,cAAc;oBACd,WAAW,EAAE,KAAK,CAAC,WAAW;iBAC/B,CAAC,CAAC;gBACH,GAAG,CAAC,QAAQ,CAAC,KAA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,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/interface": "^0.25.
|
|
31
|
-
"@autobe/utils": "^0.25.
|
|
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/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,
|
|
@@ -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>;
|
|
@@ -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>;
|
|
@@ -5,13 +5,19 @@ import {
|
|
|
5
5
|
AutoBeRealizeWriteEvent,
|
|
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";
|
|
12
17
|
|
|
13
18
|
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
14
19
|
import { assertSchemaModel } from "../../context/assertSchemaModel";
|
|
20
|
+
import { validateEmptyCode } from "../../utils/validateEmptyCode";
|
|
15
21
|
import { transformRealizeWriteHistories } from "./histories/transformRealizeWriteHistories";
|
|
16
22
|
import { IAutoBeRealizeScenarioResult } from "./structures/IAutoBeRealizeScenarioResult";
|
|
17
23
|
import { IAutoBeRealizeWriteApplication } from "./structures/IAutoBeRealizeWriteApplication";
|
|
@@ -45,6 +51,7 @@ export async function orchestrateRealizeWrite<Model extends ILlmSchema.Model>(
|
|
|
45
51
|
}),
|
|
46
52
|
controller: createController({
|
|
47
53
|
model: ctx.model,
|
|
54
|
+
functionName: props.scenario.functionName,
|
|
48
55
|
build: (next) => {
|
|
49
56
|
pointer.value = next;
|
|
50
57
|
},
|
|
@@ -102,13 +109,33 @@ export async function orchestrateRealizeWrite<Model extends ILlmSchema.Model>(
|
|
|
102
109
|
|
|
103
110
|
function createController<Model extends ILlmSchema.Model>(props: {
|
|
104
111
|
model: Model;
|
|
112
|
+
functionName: string;
|
|
105
113
|
build: (next: IAutoBeRealizeWriteApplication.IProps) => void;
|
|
106
114
|
}): ILlmController<Model> {
|
|
107
115
|
assertSchemaModel(props.model);
|
|
108
116
|
|
|
117
|
+
const validate: Validator = (input) => {
|
|
118
|
+
const result: IValidation<IAutoBeRealizeWriteApplication.IProps> =
|
|
119
|
+
typia.validate<IAutoBeRealizeWriteApplication.IProps>(input);
|
|
120
|
+
if (result.success === false) return result;
|
|
121
|
+
const errors: IValidation.IError[] = validateEmptyCode({
|
|
122
|
+
functionName: props.functionName,
|
|
123
|
+
draft: result.data.draft,
|
|
124
|
+
revise: result.data.revise,
|
|
125
|
+
});
|
|
126
|
+
return errors.length
|
|
127
|
+
? {
|
|
128
|
+
success: false,
|
|
129
|
+
errors,
|
|
130
|
+
data: result.data,
|
|
131
|
+
}
|
|
132
|
+
: result;
|
|
133
|
+
};
|
|
109
134
|
const application: ILlmApplication<Model> = collection[
|
|
110
|
-
props.model
|
|
111
|
-
]
|
|
135
|
+
props.model === "chatgpt" ? "chatgpt" : "claude"
|
|
136
|
+
](
|
|
137
|
+
validate,
|
|
138
|
+
) satisfies ILlmApplication<any> as unknown as ILlmApplication<Model>;
|
|
112
139
|
|
|
113
140
|
return {
|
|
114
141
|
protocol: "class",
|
|
@@ -122,14 +149,21 @@ function createController<Model extends ILlmSchema.Model>(props: {
|
|
|
122
149
|
};
|
|
123
150
|
}
|
|
124
151
|
|
|
125
|
-
const claude = typia.llm.application<
|
|
126
|
-
IAutoBeRealizeWriteApplication,
|
|
127
|
-
"claude"
|
|
128
|
-
>();
|
|
129
152
|
const collection = {
|
|
130
|
-
chatgpt:
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
153
|
+
chatgpt: (validate: Validator) =>
|
|
154
|
+
typia.llm.application<IAutoBeRealizeWriteApplication, "chatgpt">({
|
|
155
|
+
validate: {
|
|
156
|
+
write: validate,
|
|
157
|
+
},
|
|
158
|
+
}),
|
|
159
|
+
claude: (validate: Validator) =>
|
|
160
|
+
typia.llm.application<IAutoBeRealizeWriteApplication, "claude">({
|
|
161
|
+
validate: {
|
|
162
|
+
write: validate,
|
|
163
|
+
},
|
|
164
|
+
}),
|
|
135
165
|
};
|
|
166
|
+
|
|
167
|
+
type Validator = (
|
|
168
|
+
input: unknown,
|
|
169
|
+
) => IValidation<IAutoBeRealizeWriteApplication.IProps>;
|
|
@@ -14,6 +14,7 @@ import { v7 } from "uuid";
|
|
|
14
14
|
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
15
15
|
import { assertSchemaModel } from "../../context/assertSchemaModel";
|
|
16
16
|
import { executeCachedBatch } from "../../utils/executeCachedBatch";
|
|
17
|
+
import { validateEmptyCode } from "../../utils/validateEmptyCode";
|
|
17
18
|
import { orchestrateCommonCorrectCasting } from "../common/orchestrateCommonCorrectCasting";
|
|
18
19
|
import { completeTestCode } from "./compile/completeTestCode";
|
|
19
20
|
import { transformTestCorrectHistories } from "./histories/transformTestCorrectHistories";
|
|
@@ -66,6 +67,7 @@ export const orchestrateTestCorrect = async <Model extends ILlmSchema.Model>(
|
|
|
66
67
|
step: ctx.state().analyze?.step ?? 0,
|
|
67
68
|
}) satisfies AutoBeTestCorrectEvent,
|
|
68
69
|
script: (event) => event.file.content,
|
|
70
|
+
functionName: w.scenario.functionName,
|
|
69
71
|
},
|
|
70
72
|
x.file.content,
|
|
71
73
|
);
|
|
@@ -163,6 +165,7 @@ const correct = async <Model extends ILlmSchema.Model>(
|
|
|
163
165
|
}),
|
|
164
166
|
controller: createController({
|
|
165
167
|
model: ctx.model,
|
|
168
|
+
functionName: props.function.scenario.functionName,
|
|
166
169
|
failure: props.validate.result,
|
|
167
170
|
build: (next) => {
|
|
168
171
|
pointer.value = next;
|
|
@@ -233,6 +236,7 @@ const correct = async <Model extends ILlmSchema.Model>(
|
|
|
233
236
|
|
|
234
237
|
const createController = <Model extends ILlmSchema.Model>(props: {
|
|
235
238
|
model: Model;
|
|
239
|
+
functionName: string;
|
|
236
240
|
failure: IAutoBeTypeScriptCompileResult.IFailure;
|
|
237
241
|
build: (next: IAutoBeTestCorrectApplication.IProps) => void;
|
|
238
242
|
}): IAgenticaController.IClass<Model> => {
|
|
@@ -243,30 +247,19 @@ const createController = <Model extends ILlmSchema.Model>(props: {
|
|
|
243
247
|
): IValidation<IAutoBeTestCorrectApplication.IProps> => {
|
|
244
248
|
const result: IValidation<IAutoBeTestCorrectApplication.IProps> =
|
|
245
249
|
typia.validate<IAutoBeTestCorrectApplication.IProps>(input);
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
// The 'think.analyses' must contain all the compilation errors.
|
|
260
|
-
|
|
261
|
-
// Therefore, the length of the 'think.analyses' must be not
|
|
262
|
-
// ${actual}, but exactly ${expected}, which is equal to the length of
|
|
263
|
-
// the 'diagnostics' of the compilation failure.
|
|
264
|
-
// `,
|
|
265
|
-
// },
|
|
266
|
-
// ],
|
|
267
|
-
// data: input,
|
|
268
|
-
// };
|
|
269
|
-
return result;
|
|
250
|
+
if (result.success === false) return result;
|
|
251
|
+
const errors: IValidation.IError[] = validateEmptyCode({
|
|
252
|
+
functionName: props.functionName,
|
|
253
|
+
draft: result.data.draft,
|
|
254
|
+
revise: result.data.revise,
|
|
255
|
+
});
|
|
256
|
+
return errors.length
|
|
257
|
+
? {
|
|
258
|
+
success: false,
|
|
259
|
+
errors,
|
|
260
|
+
data: result.data,
|
|
261
|
+
}
|
|
262
|
+
: result;
|
|
270
263
|
};
|
|
271
264
|
const application: ILlmApplication<Model> = collection[
|
|
272
265
|
props.model === "chatgpt" ? "chatgpt" : "claude"
|