@autobe/agent 0.25.2 → 0.25.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/AutoBeAgent.js +2 -0
- package/lib/AutoBeAgent.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 +66 -6
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +12 -4
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +1 -1
- package/package.json +5 -5
- package/src/AutoBeAgent.ts +2 -0
- package/src/factory/consentFunctionCall.ts +3 -0
- package/src/factory/createAutoBeContext.ts +2 -0
- package/src/factory/supportMistral.ts +122 -0
- package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +14 -4
- package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +1 -1
|
@@ -60,14 +60,19 @@ const JsonSchemaNamingConvention_1 = require("./utils/JsonSchemaNamingConvention
|
|
|
60
60
|
const JsonSchemaValidator_1 = require("./utils/JsonSchemaValidator");
|
|
61
61
|
const fulfillJsonSchemaErrorMessages_1 = require("./utils/fulfillJsonSchemaErrorMessages");
|
|
62
62
|
function orchestrateInterfaceComplement(ctx, props) {
|
|
63
|
-
return step(ctx, props,
|
|
63
|
+
return step(ctx, props, {
|
|
64
|
+
wasEmpty: false,
|
|
65
|
+
life: 10,
|
|
66
|
+
});
|
|
64
67
|
}
|
|
65
|
-
function step(ctx, props,
|
|
68
|
+
function step(ctx, props, progress) {
|
|
66
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
70
|
var _a, _b;
|
|
68
71
|
const missed = (0, utils_1.missedOpenApiSchemas)(props.document);
|
|
69
72
|
if (missed.length === 0)
|
|
70
73
|
return props.document.components.schemas;
|
|
74
|
+
else if (progress.life === 0)
|
|
75
|
+
return props.document.components.schemas;
|
|
71
76
|
const pointer = {
|
|
72
77
|
value: null,
|
|
73
78
|
};
|
|
@@ -105,14 +110,17 @@ function step(ctx, props, wasEmpty) {
|
|
|
105
110
|
created_at: new Date().toISOString(),
|
|
106
111
|
});
|
|
107
112
|
const empty = Object.keys(pointer.value).length === 0;
|
|
108
|
-
if (empty === true && wasEmpty === true)
|
|
113
|
+
if (empty === true && progress.wasEmpty === true)
|
|
109
114
|
return props.document.components.schemas;
|
|
110
115
|
const newSchemas = Object.assign(Object.assign({}, pointer.value), props.document.components.schemas);
|
|
111
116
|
JsonSchemaNamingConvention_1.JsonSchemaNamingConvention.schemas(props.document.operations, newSchemas);
|
|
112
117
|
return step(ctx, {
|
|
113
118
|
instruction: props.instruction,
|
|
114
119
|
document: Object.assign(Object.assign({}, props.document), { components: Object.assign(Object.assign({}, props.document.components), { schemas: newSchemas }) }),
|
|
115
|
-
},
|
|
120
|
+
}, {
|
|
121
|
+
wasEmpty: empty,
|
|
122
|
+
life: progress.life - 1,
|
|
123
|
+
});
|
|
116
124
|
});
|
|
117
125
|
}
|
|
118
126
|
function createController(props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrateInterfaceComplement.js","sourceRoot":"","sources":["../../../src/orchestrate/interface/orchestrateInterfaceComplement.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,
|
|
1
|
+
{"version":3,"file":"orchestrateInterfaceComplement.js","sourceRoot":"","sources":["../../../src/orchestrate/interface/orchestrateInterfaceComplement.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,wEAWC;;;;AA3BD,yCAAqD;AA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uHACyC;YACrE,QAAQ,EAAE;gBACR,oBAAoB,EAAE,QAAQ;aAC/B;SACF;;QAAC;CACL,CAAC"}
|
|
@@ -62,7 +62,7 @@ function orchestratePrismaCorrect(ctx, application) {
|
|
|
62
62
|
return true;
|
|
63
63
|
});
|
|
64
64
|
application.files = application.files.filter((f) => f.models.length !== 0);
|
|
65
|
-
return iterate(ctx, application, Math.max(ctx.retry,
|
|
65
|
+
return iterate(ctx, application, Math.max(ctx.retry, 8));
|
|
66
66
|
}
|
|
67
67
|
function iterate(ctx, application, life) {
|
|
68
68
|
return __awaiter(this, void 0, void 0, function* () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autobe/agent",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.4",
|
|
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.4",
|
|
31
|
+
"@autobe/utils": "^0.25.4"
|
|
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.4",
|
|
44
|
+
"@autobe/filesystem": "^0.25.4"
|
|
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(
|
|
@@ -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
|
+
}
|
|
@@ -23,7 +23,10 @@ export function orchestrateInterfaceComplement<Model extends ILlmSchema.Model>(
|
|
|
23
23
|
document: AutoBeOpenApi.IDocument;
|
|
24
24
|
},
|
|
25
25
|
): Promise<Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>> {
|
|
26
|
-
return step(ctx, props,
|
|
26
|
+
return step(ctx, props, {
|
|
27
|
+
wasEmpty: false,
|
|
28
|
+
life: 10,
|
|
29
|
+
});
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
async function step<Model extends ILlmSchema.Model>(
|
|
@@ -32,10 +35,14 @@ async function step<Model extends ILlmSchema.Model>(
|
|
|
32
35
|
instruction: string;
|
|
33
36
|
document: AutoBeOpenApi.IDocument;
|
|
34
37
|
},
|
|
35
|
-
|
|
38
|
+
progress: {
|
|
39
|
+
wasEmpty: boolean;
|
|
40
|
+
life: number;
|
|
41
|
+
},
|
|
36
42
|
): Promise<Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>> {
|
|
37
43
|
const missed: string[] = missedOpenApiSchemas(props.document);
|
|
38
44
|
if (missed.length === 0) return props.document.components.schemas;
|
|
45
|
+
else if (progress.life === 0) return props.document.components.schemas;
|
|
39
46
|
|
|
40
47
|
const pointer: IPointer<Record<
|
|
41
48
|
string,
|
|
@@ -85,7 +92,7 @@ async function step<Model extends ILlmSchema.Model>(
|
|
|
85
92
|
});
|
|
86
93
|
|
|
87
94
|
const empty: boolean = Object.keys(pointer.value).length === 0;
|
|
88
|
-
if (empty === true && wasEmpty === true)
|
|
95
|
+
if (empty === true && progress.wasEmpty === true)
|
|
89
96
|
return props.document.components.schemas;
|
|
90
97
|
|
|
91
98
|
const newSchemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> = {
|
|
@@ -105,7 +112,10 @@ async function step<Model extends ILlmSchema.Model>(
|
|
|
105
112
|
},
|
|
106
113
|
},
|
|
107
114
|
},
|
|
108
|
-
|
|
115
|
+
{
|
|
116
|
+
wasEmpty: empty,
|
|
117
|
+
life: progress.life - 1,
|
|
118
|
+
},
|
|
109
119
|
);
|
|
110
120
|
}
|
|
111
121
|
|
|
@@ -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>(
|