@autobe/agent 0.3.11 → 0.3.12

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.
@@ -13,7 +13,7 @@ type Filename = string;
13
13
  type FileContent = string;
14
14
 
15
15
  export class AnalyzeAgent<Model extends ILlmSchema.Model> {
16
- private readonly agent: MicroAgentica<Model>;
16
+ private readonly createInnerAgent: () => MicroAgentica<Model>;
17
17
  private readonly fileMap: Record<Filename, FileContent> = {};
18
18
 
19
19
  constructor(
@@ -32,27 +32,36 @@ export class AnalyzeAgent<Model extends ILlmSchema.Model> {
32
32
  this.pointer.value = { files };
33
33
  },
34
34
  });
35
- this.agent = new MicroAgentica({
36
- controllers: [controller],
37
- model: ctx.model,
38
- vendor: ctx.vendor,
39
- config: {
40
- systemPrompt: {
41
- common: () => {
42
- return AutoBeSystemPromptConstant.ANALYZE.replace(
43
- "{% Guidelines %}",
44
- AutoBeSystemPromptConstant.ANALYZE_GUIDELINE,
45
- )
46
- .replace(
47
- "{% Example Documentation %}",
48
- AutoBeSystemPromptConstant.ANALYZE_EXAMPLE,
35
+
36
+ this.createInnerAgent = (): MicroAgentica<Model> => {
37
+ const agent = new MicroAgentica({
38
+ controllers: [controller],
39
+ model: ctx.model,
40
+ vendor: ctx.vendor,
41
+ config: {
42
+ systemPrompt: {
43
+ common: () => {
44
+ return AutoBeSystemPromptConstant.ANALYZE.replace(
45
+ "{% Guidelines %}",
46
+ AutoBeSystemPromptConstant.ANALYZE_GUIDELINE,
49
47
  )
50
- .replace("{% User Locale %}", ctx.config?.locale ?? "en-US");
48
+ .replace(
49
+ "{% Example Documentation %}",
50
+ AutoBeSystemPromptConstant.ANALYZE_EXAMPLE,
51
+ )
52
+ .replace("{% User Locale %}", ctx.config?.locale ?? "en-US");
53
+ },
54
+ describe: () => {
55
+ return "Answer only 'completion' or 'failure'.";
56
+ },
51
57
  },
52
58
  },
53
- },
54
- tokenUsage: ctx.usage(),
55
- });
59
+ tokenUsage: ctx.usage(),
60
+ histories: [],
61
+ });
62
+
63
+ return agent;
64
+ };
56
65
  }
57
66
 
58
67
  /**
@@ -62,7 +71,7 @@ export class AnalyzeAgent<Model extends ILlmSchema.Model> {
62
71
  * @returns
63
72
  */
64
73
  async conversate(content: string): Promise<string> {
65
- const response = await this.agent.conversate(content);
74
+ const response = await this.createInnerAgent().conversate(content);
66
75
  const lastMessage = response[response.length - 1]!;
67
76
 
68
77
  if ("text" in lastMessage) {
@@ -116,6 +125,8 @@ export class AnalyzeAgent<Model extends ILlmSchema.Model> {
116
125
  );
117
126
  }
118
127
  }
128
+
129
+ return `If the document is not 1,000 characters, please fill it out in more abundance, and if it exceeds 1,000 characters, please fill out the next document. If you don't have the next document, you can exit now.`;
119
130
  }
120
131
 
121
132
  return "COMPLETE";
@@ -147,8 +158,8 @@ function createController<Model extends ILlmSchema.Model>(props: {
147
158
  props.build(props.execute.allFiles());
148
159
  return response;
149
160
  },
150
- createOrUpdateFile: (input) => {
151
- const response = props.execute.createOrUpdateFile(input);
161
+ createOrUpdateFiles: (input) => {
162
+ const response = props.execute.createOrUpdateFiles(input);
152
163
  props.build(props.execute.allFiles());
153
164
  return response;
154
165
  },
@@ -27,7 +27,7 @@ export const createReviewerAgent = <Model extends ILlmSchema.Model>(
27
27
  ),
28
28
  );
29
29
 
30
- return new MicroAgentica({
30
+ const agent = new MicroAgentica({
31
31
  model: ctx.model,
32
32
  vendor: ctx.vendor,
33
33
  controllers: [],
@@ -70,17 +70,13 @@ export const createReviewerAgent = <Model extends ILlmSchema.Model>(
70
70
  "At this time, the document should be newly created with the name attached to the link, not modified.",
71
71
  "<CurrentFiles>",
72
72
  JSON.stringify(
73
- Object.entries(input.currentFiles)
74
- .slice(-2)
75
- .map(([filename, content]) => {
76
- return {
77
- filename,
78
- content,
79
- content_length: content.length,
80
- };
81
- }),
82
- null,
83
- 2,
73
+ Object.entries(input.currentFiles).map(([filename, content]) => {
74
+ return {
75
+ filename,
76
+ content,
77
+ content_length: content.length,
78
+ };
79
+ }),
84
80
  ),
85
81
  "</CurrentFiles>",
86
82
  "",
@@ -95,20 +91,24 @@ export const createReviewerAgent = <Model extends ILlmSchema.Model>(
95
91
  `</Linked Files>`,
96
92
  "",
97
93
  "Write a long document, but keep your answer short.",
98
- "The planner agent can only create and modify one document at a time, so do not ask to create or modify multiple documents at a time.",
99
94
  "If you say the document is complete, the planner will finish writing the document.",
100
95
  "If only one document has been written out of several that need to be completed, do not simply state that it is complete—also provide instructions for what should be done next.",
101
96
  "For example, if you say, “The document internal_bulletin_board_service_plan.md has already been written with over 1,000 characters. Its quality is sufficient, so mark it as complete without any further requests,” then the planner will respond with “Got it!” and stop writing—even if there are still remaining documents.",
102
97
  "Be cautious: the planner will try to avoid work by interpreting your words in a way that lets them do less.",
103
98
  "The correct response from you should be:",
104
- "\“The document's quality is sufficient, so mark it as complete without any further requests. Now, proceed to write the next document immediately.\”",
99
+ "\“The document's quality is sufficient, so mark it as complete without any further requests. Now, proceed to write the next documents immediately.\”",
105
100
  "When requesting the next document to be written, you must include both the document title and a brief description of its content.",
106
101
  ].join("\n");
107
102
  },
103
+ describe: () => {
104
+ return "Answer only 'completion' or 'failure'.";
105
+ },
108
106
  },
109
107
  },
110
108
  tokenUsage: ctx.usage(),
111
109
  });
110
+
111
+ return agent;
112
112
  };
113
113
 
114
114
  export interface ICreateReviewerAgentInput {
@@ -3,26 +3,27 @@ type FileContent = string;
3
3
 
4
4
  export interface IPlanning {
5
5
  /**
6
- * Generate markdown file. if there is already created file, overwrite it.
7
- *
8
- * @param input.reason Describe briefly why you made this document, and if you
9
- * have any plans for the next one.
10
- * @param input.filename Filename to generate or overwrite.
11
- * @param input.markdown Markdown file content. Only write the content of the
12
- * file. Do not include any questions.
6
+ * Generate multiple markdown files. if there is already created files,
7
+ * overwrite it. Generate several markdown files at once.
13
8
  */
14
- createOrUpdateFile(input: {
15
- reason: string;
16
- filename: `${string}.md`;
17
- markdown: string;
18
- }): Promise<void>;
9
+ createOrUpdateFiles(input: {
10
+ files: Array<{
11
+ /**
12
+ * Describe briefly why you made this document, and if you have any plans
13
+ * for the next one.
14
+ */
15
+ reason: string;
19
16
 
20
- /**
21
- * Read markdown file content.
22
- *
23
- * @param input.filename Filename to read.
24
- */
25
- // readFile(input: { filename: `${string}.md` }): Promise<string>;
17
+ /** Filename to generate or overwrite. */
18
+ filename: `${string}.md`;
19
+
20
+ /**
21
+ * Markdown file content. Only write the content of the file. Do not
22
+ * include any questions.
23
+ */
24
+ markdown: string;
25
+ }>;
26
+ }): Promise<void>;
26
27
 
27
28
  /**
28
29
  * Remove markdown file.
@@ -48,18 +49,18 @@ export interface IPlanning {
48
49
  export class Planning implements IPlanning {
49
50
  constructor(private readonly fileMap: Record<Filename, FileContent> = {}) {}
50
51
 
51
- async createOrUpdateFile(input: {
52
- reason: string;
53
- filename: `${string}.md`;
54
- markdown: string;
52
+ async createOrUpdateFiles(input: {
53
+ files: Array<{
54
+ reason: string;
55
+ filename: `${string}.md`;
56
+ markdown: string;
57
+ }>;
55
58
  }): Promise<void> {
56
- this.fileMap[input.filename] = input.markdown;
59
+ input.files.forEach((file) => {
60
+ this.fileMap[file.filename] = file.markdown;
61
+ });
57
62
  }
58
63
 
59
- // async readFile(input: { filename: `${string}.md` }): Promise<string> {
60
- // return this.fileMap[input.filename];
61
- // }
62
-
63
64
  async removeFile(input: { filename: `${string}.md` }): Promise<void> {
64
65
  delete this.fileMap[input.filename];
65
66
  }