@autobe/agent 0.4.0 → 0.4.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.
- package/lib/analyze/AnalyzeAgent.d.ts +2 -2
- package/lib/analyze/AnalyzeAgent.js +75 -40
- package/lib/analyze/AnalyzeAgent.js.map +1 -1
- package/lib/analyze/AutoBeAnalyzeAgent.d.ts +24 -0
- package/lib/analyze/AutoBeAnalyzeAgent.js +972 -0
- package/lib/analyze/AutoBeAnalyzeAgent.js.map +1 -0
- package/lib/analyze/AutoBeAnalyzeFileSystem.d.ts +65 -0
- package/lib/analyze/{Planning.js → AutoBeAnalyzeFileSystem.js} +4 -4
- package/lib/analyze/AutoBeAnalyzeFileSystem.js.map +1 -0
- package/lib/analyze/AutoBeAnalyzeReviewer.d.ts +15 -0
- package/lib/analyze/AutoBeAnalyzeReviewer.js +42 -0
- package/lib/analyze/AutoBeAnalyzeReviewer.js.map +1 -0
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +3 -2
- package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
- package/lib/index.mjs +572 -113
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/orchestrateAnalyze.js +512 -16
- package/lib/orchestrate/orchestrateAnalyze.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrisma.js +1 -1
- package/lib/orchestrate/prisma/orchestratePrisma.js.map +1 -1
- package/package.json +4 -4
- package/src/analyze/AnalyzeAgent.ts +24 -19
- package/src/analyze/AutoBeAnalyzeAgent.ts +217 -0
- package/src/analyze/AutoBeAnalyzeFileSystem.ts +81 -0
- package/src/analyze/AutoBeAnalyzeReviewer.ts +60 -0
- package/src/constants/AutoBeSystemPromptConstant.ts +3 -2
- package/src/orchestrate/orchestrateAnalyze.ts +178 -17
- package/src/orchestrate/prisma/orchestratePrisma.ts +1 -1
- package/lib/analyze/CreateReviewerAgent.d.ts +0 -16
- package/lib/analyze/CreateReviewerAgent.js +0 -98
- package/lib/analyze/CreateReviewerAgent.js.map +0 -1
- package/lib/analyze/Planning.d.ts +0 -67
- package/lib/analyze/Planning.js.map +0 -1
- package/src/analyze/CreateReviewerAgent.ts +0 -126
- package/src/analyze/Planning.ts +0 -77
|
@@ -6,8 +6,11 @@ import typia from "typia";
|
|
|
6
6
|
import { AutoBeSystemPromptConstant } from "../constants/AutoBeSystemPromptConstant";
|
|
7
7
|
import { AutoBeContext } from "../context/AutoBeContext";
|
|
8
8
|
import { assertSchemaModel } from "../context/assertSchemaModel";
|
|
9
|
-
import {
|
|
10
|
-
|
|
9
|
+
import {
|
|
10
|
+
AutoBeAnalyzeFileSystem,
|
|
11
|
+
IAutoBeAnalyzeFileSystem,
|
|
12
|
+
} from "./AutoBeAnalyzeFileSystem";
|
|
13
|
+
import { AutoBeAnalyzeReviewer } from "./AutoBeAnalyzeReviewer";
|
|
11
14
|
|
|
12
15
|
type Filename = string;
|
|
13
16
|
type FileContent = string;
|
|
@@ -17,7 +20,7 @@ export class AnalyzeAgent<Model extends ILlmSchema.Model> {
|
|
|
17
20
|
private readonly fileMap: Record<Filename, FileContent> = {};
|
|
18
21
|
|
|
19
22
|
constructor(
|
|
20
|
-
private readonly createReviewerAgentFn: typeof
|
|
23
|
+
private readonly createReviewerAgentFn: typeof AutoBeAnalyzeReviewer,
|
|
21
24
|
private readonly ctx: AutoBeContext<Model>,
|
|
22
25
|
private readonly pointer: IPointer<{
|
|
23
26
|
files: Record<Filename, FileContent>;
|
|
@@ -27,7 +30,7 @@ export class AnalyzeAgent<Model extends ILlmSchema.Model> {
|
|
|
27
30
|
|
|
28
31
|
const controller = createController<Model>({
|
|
29
32
|
model: ctx.model,
|
|
30
|
-
execute: new
|
|
33
|
+
execute: new AutoBeAnalyzeFileSystem(this.fileMap),
|
|
31
34
|
build: async (files: Record<Filename, FileContent>) => {
|
|
32
35
|
this.pointer.value = { files };
|
|
33
36
|
},
|
|
@@ -44,12 +47,7 @@ export class AnalyzeAgent<Model extends ILlmSchema.Model> {
|
|
|
44
47
|
return AutoBeSystemPromptConstant.ANALYZE.replace(
|
|
45
48
|
"{% Guidelines %}",
|
|
46
49
|
AutoBeSystemPromptConstant.ANALYZE_GUIDELINE,
|
|
47
|
-
)
|
|
48
|
-
.replace(
|
|
49
|
-
"{% Example Documentation %}",
|
|
50
|
-
AutoBeSystemPromptConstant.ANALYZE_EXAMPLE,
|
|
51
|
-
)
|
|
52
|
-
.replace("{% User Locale %}", ctx.config?.locale ?? "en-US");
|
|
50
|
+
).replace("{% User Locale %}", ctx.config?.locale ?? "en-US");
|
|
53
51
|
},
|
|
54
52
|
describe: () => {
|
|
55
53
|
return "Answer only 'completion' or 'failure'.";
|
|
@@ -98,11 +96,10 @@ export class AnalyzeAgent<Model extends ILlmSchema.Model> {
|
|
|
98
96
|
return lastMessage.text;
|
|
99
97
|
}
|
|
100
98
|
|
|
101
|
-
const currentFiles = this.fileMap;
|
|
102
|
-
|
|
99
|
+
const currentFiles = JSON.stringify(this.fileMap);
|
|
103
100
|
const reviewer = this.createReviewerAgentFn(this.ctx, {
|
|
104
101
|
query: content,
|
|
105
|
-
currentFiles,
|
|
102
|
+
files: currentFiles,
|
|
106
103
|
});
|
|
107
104
|
|
|
108
105
|
const [review] = await reviewer.conversate(lastMessage.text);
|
|
@@ -135,7 +132,7 @@ export class AnalyzeAgent<Model extends ILlmSchema.Model> {
|
|
|
135
132
|
|
|
136
133
|
function createController<Model extends ILlmSchema.Model>(props: {
|
|
137
134
|
model: Model;
|
|
138
|
-
execute:
|
|
135
|
+
execute: AutoBeAnalyzeFileSystem;
|
|
139
136
|
build: (input: Record<Filename, FileContent>) => void;
|
|
140
137
|
}): IAgenticaController.IClass<Model> {
|
|
141
138
|
assertSchemaModel(props.model);
|
|
@@ -144,7 +141,7 @@ function createController<Model extends ILlmSchema.Model>(props: {
|
|
|
144
141
|
] as unknown as ILlmApplication<Model>;
|
|
145
142
|
return {
|
|
146
143
|
protocol: "class",
|
|
147
|
-
name: "
|
|
144
|
+
name: "AutoBeAnalyzeFileSystem",
|
|
148
145
|
application,
|
|
149
146
|
// execute: props.execute,
|
|
150
147
|
execute: {
|
|
@@ -163,16 +160,24 @@ function createController<Model extends ILlmSchema.Model>(props: {
|
|
|
163
160
|
props.build(props.execute.allFiles());
|
|
164
161
|
return response;
|
|
165
162
|
},
|
|
166
|
-
} satisfies
|
|
163
|
+
} satisfies IAutoBeAnalyzeFileSystem,
|
|
167
164
|
};
|
|
168
165
|
}
|
|
169
166
|
|
|
170
|
-
const claude = typia.llm.application<
|
|
167
|
+
const claude = typia.llm.application<
|
|
168
|
+
AutoBeAnalyzeFileSystem,
|
|
169
|
+
"claude",
|
|
170
|
+
{ reference: true }
|
|
171
|
+
>();
|
|
171
172
|
const collection = {
|
|
172
|
-
chatgpt: typia.llm.application<
|
|
173
|
+
chatgpt: typia.llm.application<
|
|
174
|
+
AutoBeAnalyzeFileSystem,
|
|
175
|
+
"chatgpt",
|
|
176
|
+
{ reference: true }
|
|
177
|
+
>(),
|
|
173
178
|
claude,
|
|
174
179
|
llama: claude,
|
|
175
180
|
deepseek: claude,
|
|
176
181
|
"3.1": claude,
|
|
177
|
-
"3.0": typia.llm.application<
|
|
182
|
+
"3.0": typia.llm.application<AutoBeAnalyzeFileSystem, "3.0">(),
|
|
178
183
|
};
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { IAgenticaController, MicroAgentica } from "@agentica/core";
|
|
2
|
+
import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
|
|
3
|
+
import { IPointer } from "tstl";
|
|
4
|
+
import typia from "typia";
|
|
5
|
+
|
|
6
|
+
import { AutoBeSystemPromptConstant } from "../constants/AutoBeSystemPromptConstant";
|
|
7
|
+
import { AutoBeContext } from "../context/AutoBeContext";
|
|
8
|
+
import { assertSchemaModel } from "../context/assertSchemaModel";
|
|
9
|
+
import {
|
|
10
|
+
AutoBeAnalyzeFileSystem,
|
|
11
|
+
IAutoBeAnalyzeFileSystem,
|
|
12
|
+
} from "./AutoBeAnalyzeFileSystem";
|
|
13
|
+
import { AutoBeAnalyzeReviewer } from "./AutoBeAnalyzeReviewer";
|
|
14
|
+
|
|
15
|
+
type Filename = string;
|
|
16
|
+
type FileContent = string;
|
|
17
|
+
|
|
18
|
+
export class AutoBeAnalyzeAgent<Model extends ILlmSchema.Model> {
|
|
19
|
+
private readonly createAnalyzeAgent: () => MicroAgentica<Model>;
|
|
20
|
+
private readonly fileMap: Record<Filename, FileContent> = {};
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
private readonly createReviewerAgentFn: typeof AutoBeAnalyzeReviewer,
|
|
24
|
+
private readonly ctx: AutoBeContext<Model>,
|
|
25
|
+
private readonly pointer: IPointer<{
|
|
26
|
+
files: Record<Filename, FileContent>;
|
|
27
|
+
} | null>,
|
|
28
|
+
filenames: string[],
|
|
29
|
+
) {
|
|
30
|
+
assertSchemaModel(ctx.model);
|
|
31
|
+
|
|
32
|
+
const controller = createController<Model>({
|
|
33
|
+
model: ctx.model,
|
|
34
|
+
execute: new AutoBeAnalyzeFileSystem(this.fileMap),
|
|
35
|
+
build: async (files: Record<Filename, FileContent>) => {
|
|
36
|
+
this.pointer.value = { files };
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
this.createAnalyzeAgent = (): MicroAgentica<Model> => {
|
|
41
|
+
const agent = new MicroAgentica({
|
|
42
|
+
controllers: [controller],
|
|
43
|
+
model: ctx.model,
|
|
44
|
+
vendor: ctx.vendor,
|
|
45
|
+
config: {
|
|
46
|
+
locale: ctx.config?.locale,
|
|
47
|
+
systemPrompt: {
|
|
48
|
+
describe: () => {
|
|
49
|
+
return "Answer only 'completion' or 'failure'.";
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
tokenUsage: ctx.usage(),
|
|
54
|
+
histories: [
|
|
55
|
+
{
|
|
56
|
+
type: "systemMessage",
|
|
57
|
+
text: AutoBeSystemPromptConstant.ANALYZE.replace(
|
|
58
|
+
"{% User Locale %}",
|
|
59
|
+
ctx.config?.locale ?? "en-US",
|
|
60
|
+
),
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
type: "systemMessage",
|
|
64
|
+
text: [
|
|
65
|
+
"# Guidelines",
|
|
66
|
+
"If the user specifies the exact number of pages, please follow it precisely.",
|
|
67
|
+
AutoBeSystemPromptConstant.ANALYZE_GUIDELINE,
|
|
68
|
+
].join("\n"),
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
type: "systemMessage",
|
|
72
|
+
text: [
|
|
73
|
+
"The following is the name of the entire file.",
|
|
74
|
+
"Use it to build a table of contents.",
|
|
75
|
+
filenames.map((filename) => `- ${filename}`),
|
|
76
|
+
"",
|
|
77
|
+
"However, do not touch other than the file you have to create.",
|
|
78
|
+
].join("\n"),
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
agent.on("request", (event) => {
|
|
84
|
+
if (event.body.tools) {
|
|
85
|
+
event.body.tool_choice = "required";
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
return agent;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Conversate with planner agent
|
|
95
|
+
*
|
|
96
|
+
* @param content Conversation from user in this time.
|
|
97
|
+
* @returns
|
|
98
|
+
*/
|
|
99
|
+
async conversate(content: string, retry = 3): Promise<string> {
|
|
100
|
+
if (retry === 0) {
|
|
101
|
+
return "Abort due to excess retry count";
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const response = await this.createAnalyzeAgent().conversate(content);
|
|
105
|
+
const lastMessage = response[response.length - 1]!;
|
|
106
|
+
|
|
107
|
+
if ("text" in lastMessage) {
|
|
108
|
+
this.ctx.dispatch({
|
|
109
|
+
type: "analyzeWriteDocument",
|
|
110
|
+
files: this.fileMap,
|
|
111
|
+
created_at: new Date().toISOString(),
|
|
112
|
+
step: this.ctx.state().analyze?.step ?? 0,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const aborted =
|
|
116
|
+
lastMessage.type === "describe" &&
|
|
117
|
+
lastMessage.executes.some((el) => {
|
|
118
|
+
if (
|
|
119
|
+
el.protocol === "class" &&
|
|
120
|
+
el.operation.function.name === "abort"
|
|
121
|
+
) {
|
|
122
|
+
el.arguments;
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
if (aborted === true) {
|
|
128
|
+
return lastMessage.text;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const reviewer = this.createReviewerAgentFn(this.ctx, {
|
|
132
|
+
query: content,
|
|
133
|
+
files: JSON.stringify(this.fileMap),
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const filenames = Object.keys(this.fileMap).join(",");
|
|
137
|
+
const command = `Request for review of these files.: ${filenames}`;
|
|
138
|
+
const [review] = await reviewer.conversate(command);
|
|
139
|
+
|
|
140
|
+
if (review) {
|
|
141
|
+
if (review.type === "assistantMessage") {
|
|
142
|
+
this.ctx.dispatch({
|
|
143
|
+
type: "analyzeReview",
|
|
144
|
+
review: review.text,
|
|
145
|
+
created_at: new Date().toISOString(),
|
|
146
|
+
step: this.ctx.state().analyze?.step ?? 0,
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
return this.conversate(
|
|
150
|
+
JSON.stringify({
|
|
151
|
+
user_query: content,
|
|
152
|
+
message: `THIS IS ANSWER OF REVIEW AGENT. FOLLOW THIS INSTRUCTIONS. AND DON\'T REQUEST ANYTHING.`,
|
|
153
|
+
review: review.text,
|
|
154
|
+
}),
|
|
155
|
+
retry--,
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return `COMPLETE WITHOUT REVIEW`;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return "COMPLETE";
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function createController<Model extends ILlmSchema.Model>(props: {
|
|
168
|
+
model: Model;
|
|
169
|
+
execute: AutoBeAnalyzeFileSystem;
|
|
170
|
+
build: (input: Record<Filename, FileContent>) => void;
|
|
171
|
+
}): IAgenticaController.IClass<Model> {
|
|
172
|
+
assertSchemaModel(props.model);
|
|
173
|
+
const application: ILlmApplication<Model> = collection[
|
|
174
|
+
props.model
|
|
175
|
+
] as unknown as ILlmApplication<Model>;
|
|
176
|
+
return {
|
|
177
|
+
protocol: "class",
|
|
178
|
+
name: "Planning",
|
|
179
|
+
application,
|
|
180
|
+
// execute: props.execute,
|
|
181
|
+
execute: {
|
|
182
|
+
removeFile: (input) => {
|
|
183
|
+
const response = props.execute.removeFile(input);
|
|
184
|
+
props.build(props.execute.allFiles());
|
|
185
|
+
return response;
|
|
186
|
+
},
|
|
187
|
+
abort: (input) => {
|
|
188
|
+
const response = props.execute.abort(input);
|
|
189
|
+
props.build(props.execute.allFiles());
|
|
190
|
+
return response;
|
|
191
|
+
},
|
|
192
|
+
createOrUpdateFiles: (input) => {
|
|
193
|
+
const response = props.execute.createOrUpdateFiles(input);
|
|
194
|
+
props.build(props.execute.allFiles());
|
|
195
|
+
return response;
|
|
196
|
+
},
|
|
197
|
+
} satisfies IAutoBeAnalyzeFileSystem,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const claude = typia.llm.application<
|
|
202
|
+
AutoBeAnalyzeFileSystem,
|
|
203
|
+
"claude",
|
|
204
|
+
{ reference: true }
|
|
205
|
+
>();
|
|
206
|
+
const collection = {
|
|
207
|
+
chatgpt: typia.llm.application<
|
|
208
|
+
AutoBeAnalyzeFileSystem,
|
|
209
|
+
"chatgpt",
|
|
210
|
+
{ reference: true }
|
|
211
|
+
>(),
|
|
212
|
+
claude,
|
|
213
|
+
llama: claude,
|
|
214
|
+
deepseek: claude,
|
|
215
|
+
"3.1": claude,
|
|
216
|
+
"3.0": typia.llm.application<AutoBeAnalyzeFileSystem, "3.0">(),
|
|
217
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { tags } from "typia";
|
|
2
|
+
|
|
3
|
+
export interface IFile {
|
|
4
|
+
/**
|
|
5
|
+
* Describe briefly why you made this document, and if you have any plans for
|
|
6
|
+
* the next one.
|
|
7
|
+
*/
|
|
8
|
+
reason: string;
|
|
9
|
+
|
|
10
|
+
/** Filename to generate or overwrite. */
|
|
11
|
+
filename: `${string}.md`;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Markdown file content. Only write the content of the file. Do not include
|
|
15
|
+
* any questions. This should contain only the contents of the file. Do not
|
|
16
|
+
* write down any questions or appreciation. For example, remove a sentence
|
|
17
|
+
* such as "Is it okay if we proceed with the table of contents? Please let me
|
|
18
|
+
* know if there is anything to add or exclude from the table of contents!"
|
|
19
|
+
*/
|
|
20
|
+
markdown: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ICreateOrUpdateInput {
|
|
24
|
+
/**
|
|
25
|
+
* Fill in the elements of the array as many files as you want to create.
|
|
26
|
+
* Overwrite if you point to the name of the file that already exists.
|
|
27
|
+
*
|
|
28
|
+
* @title files to create or update
|
|
29
|
+
*/
|
|
30
|
+
files: Array<IFile> & tags.MinItems<1>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
type Filename = string;
|
|
34
|
+
type FileContent = string;
|
|
35
|
+
|
|
36
|
+
export interface IAutoBeAnalyzeFileSystem {
|
|
37
|
+
/**
|
|
38
|
+
* Generate multiple markdown files. if there is already created files,
|
|
39
|
+
* overwrite it. Generate several markdown files at once. It is recommended
|
|
40
|
+
* that you create multiple files at a time.
|
|
41
|
+
*/
|
|
42
|
+
createOrUpdateFiles(input: ICreateOrUpdateInput): Promise<void>;
|
|
43
|
+
|
|
44
|
+
/** Remove markdown file. */
|
|
45
|
+
removeFile(input: Pick<IFile, "filename">): Promise<void>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* If you decide that you no longer need any reviews, or if the reviewer
|
|
49
|
+
* refuses to do so, call abort. This is a function to end document creation
|
|
50
|
+
* and review, and to respond to users.
|
|
51
|
+
*
|
|
52
|
+
* When there is content you are unsure about and need to ask the user a
|
|
53
|
+
* question, abort the process and ask the user directly. The reason for
|
|
54
|
+
* aborting should be included as the content of the question.
|
|
55
|
+
*/
|
|
56
|
+
abort(input: { reason: string }): "OK";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export class AutoBeAnalyzeFileSystem implements IAutoBeAnalyzeFileSystem {
|
|
60
|
+
constructor(private readonly fileMap: Record<Filename, FileContent> = {}) {}
|
|
61
|
+
async createOrUpdateFiles(input: {
|
|
62
|
+
files: Array<IFile> & tags.MinItems<1>;
|
|
63
|
+
}): Promise<void> {
|
|
64
|
+
input.files.forEach((file) => {
|
|
65
|
+
this.fileMap[file.filename] = file.markdown;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async removeFile(input: Pick<IFile, "filename">): Promise<void> {
|
|
70
|
+
delete this.fileMap[input.filename];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
abort(_input: { reason: string }): "OK" {
|
|
74
|
+
return "OK";
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** @ignore */
|
|
78
|
+
allFiles(): Record<string, string> {
|
|
79
|
+
return this.fileMap;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { MicroAgentica } from "@agentica/core";
|
|
2
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
3
|
+
|
|
4
|
+
import { AutoBeSystemPromptConstant } from "../constants/AutoBeSystemPromptConstant";
|
|
5
|
+
import { AutoBeContext } from "../context/AutoBeContext";
|
|
6
|
+
|
|
7
|
+
export const AutoBeAnalyzeReviewer = <Model extends ILlmSchema.Model>(
|
|
8
|
+
ctx: AutoBeContext<Model>,
|
|
9
|
+
input: AutoBeAnalyzeReviewer.ICreateReviewerAgentInput,
|
|
10
|
+
) => {
|
|
11
|
+
const agent = new MicroAgentica({
|
|
12
|
+
model: ctx.model,
|
|
13
|
+
vendor: ctx.vendor,
|
|
14
|
+
controllers: [],
|
|
15
|
+
config: {
|
|
16
|
+
systemPrompt: {
|
|
17
|
+
describe: () => {
|
|
18
|
+
return "Answer only 'completion' or 'failure'.";
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
locale: ctx.config?.locale,
|
|
22
|
+
},
|
|
23
|
+
histories: [
|
|
24
|
+
...ctx
|
|
25
|
+
.histories()
|
|
26
|
+
.filter(
|
|
27
|
+
(el) => el.type === "assistantMessage" || el.type === "userMessage",
|
|
28
|
+
),
|
|
29
|
+
{
|
|
30
|
+
type: "systemMessage",
|
|
31
|
+
text: AutoBeSystemPromptConstant.ANALYZE_REVIEWER,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
type: "systemMessage",
|
|
35
|
+
text: [
|
|
36
|
+
"Below are all of the files.",
|
|
37
|
+
"```json",
|
|
38
|
+
input.files,
|
|
39
|
+
"```",
|
|
40
|
+
].join("\n"),
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
tokenUsage: ctx.usage(),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return agent;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export namespace AutoBeAnalyzeReviewer {
|
|
50
|
+
export interface ICreateReviewerAgentInput {
|
|
51
|
+
/**
|
|
52
|
+
* Indicates the initial utterance of the user. Identify the purpose of your
|
|
53
|
+
* documentation for better review.
|
|
54
|
+
*/
|
|
55
|
+
query: string;
|
|
56
|
+
|
|
57
|
+
/** Total file names */
|
|
58
|
+
files: string;
|
|
59
|
+
}
|
|
60
|
+
}
|