@ai.ntellect/core 0.2.1 → 0.2.3

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/agent/index.ts CHANGED
@@ -48,6 +48,8 @@ export class Agent {
48
48
  }
49
49
 
50
50
  async process(prompt: string, events: AgentEvent): Promise<any> {
51
+ this.accumulatedResults = [];
52
+ this.evaluatorIteration = 0;
51
53
  console.log("Requesting orchestrator for actions..");
52
54
  const request = await this.orchestrator.process(
53
55
  prompt,
@@ -170,9 +172,6 @@ export class Agent {
170
172
  }
171
173
 
172
174
  const accumulatedResults = this.accumulatedResults;
173
- this.accumulatedResults = [];
174
- this.evaluatorIteration = 0;
175
-
176
175
  return this.stream
177
176
  ? (
178
177
  await synthesizer.streamProcess(
@@ -5,7 +5,6 @@ const evaluator_1 = require("../llm/evaluator");
5
5
  const synthesizer_1 = require("../llm/synthesizer");
6
6
  const types_1 = require("../types");
7
7
  const queue_item_transformer_1 = require("../utils/queue-item-transformer");
8
- const sanitize_results_1 = require("../utils/sanitize-results");
9
8
  const ActionHandler_1 = require("./handlers/ActionHandler");
10
9
  class Agent {
11
10
  constructor({ orchestrator, persistentMemory, cacheMemory, stream, maxEvaluatorIteration = 1, }) {
@@ -20,6 +19,8 @@ class Agent {
20
19
  this.accumulatedResults = [];
21
20
  }
22
21
  async process(prompt, events) {
22
+ this.accumulatedResults = [];
23
+ this.evaluatorIteration = 0;
23
24
  console.log("Requesting orchestrator for actions..");
24
25
  const request = await this.orchestrator.process(prompt, this.accumulatedResults);
25
26
  events.onMessage?.(request);
@@ -76,12 +77,6 @@ class Agent {
76
77
  }
77
78
  async handleActionResults(actionsResult) {
78
79
  const synthesizer = new synthesizer_1.Synthesizer();
79
- const sanitizedResults = sanitize_results_1.ResultSanitizer.sanitize(this.accumulatedResults);
80
- const summaryData = JSON.stringify({
81
- result: sanitizedResults,
82
- });
83
- this.accumulatedResults = [];
84
- this.evaluatorIteration = 0;
85
80
  for (const action of actionsResult.data) {
86
81
  if (!action.error) {
87
82
  await this.cacheMemory?.createMemory({
@@ -92,9 +87,10 @@ class Agent {
92
87
  });
93
88
  }
94
89
  }
90
+ const accumulatedResults = this.accumulatedResults;
95
91
  return this.stream
96
- ? (await synthesizer.streamProcess(actionsResult.initialPrompt, this.accumulatedResults)).toDataStreamResponse()
97
- : await synthesizer.process(actionsResult.initialPrompt, this.accumulatedResults);
92
+ ? (await synthesizer.streamProcess(actionsResult.initialPrompt, accumulatedResults)).toDataStreamResponse()
93
+ : await synthesizer.process(actionsResult.initialPrompt, accumulatedResults);
98
94
  }
99
95
  transformActions(actions) {
100
96
  let predefinedActions = queue_item_transformer_1.QueueItemTransformer.transformActionsToQueueItems(actions) || [];
@@ -43,6 +43,8 @@ class Evaluator {
43
43
  const response = await (0, ai_1.generateObject)({
44
44
  model: this.model,
45
45
  schema: zod_1.z.object({
46
+ actionsCompleted: zod_1.z.array(zod_1.z.string()),
47
+ actionsFailed: zod_1.z.array(zod_1.z.string()),
46
48
  isRemindNeeded: zod_1.z.boolean(),
47
49
  importantToRemembers: zod_1.z.array(zod_1.z.object({
48
50
  memoryType: zod_1.z.string(),
@@ -26,6 +26,7 @@ class Synthesizer {
26
26
  # STEPS: ${steps?.join("\n") || ""}
27
27
  # MESSAGES EXAMPLES: ${JSON.stringify(examplesMessages, null, 2)}
28
28
  `;
29
+ console.log("Synthesizer Context:", context);
29
30
  return context;
30
31
  }
31
32
  async process(prompt, results, onFinish) {
@@ -75,12 +76,12 @@ class Synthesizer {
75
76
  });
76
77
  const result = await (0, ai_1.streamText)({
77
78
  model: this.model,
78
- prompt,
79
79
  onFinish: (event) => {
80
80
  console.log("\n✅ Streaming synthesis completed");
81
81
  if (onFinish)
82
82
  onFinish(event);
83
83
  },
84
+ prompt,
84
85
  system: context,
85
86
  });
86
87
  return result;
@@ -50,6 +50,8 @@ export class Evaluator {
50
50
  const response = await generateObject({
51
51
  model: this.model,
52
52
  schema: z.object({
53
+ actionsCompleted: z.array(z.string()),
54
+ actionsFailed: z.array(z.string()),
53
55
  isRemindNeeded: z.boolean(),
54
56
  importantToRemembers: z.array(
55
57
  z.object({
@@ -26,7 +26,7 @@ export class Synthesizer {
26
26
  # STEPS: ${steps?.join("\n") || ""}
27
27
  # MESSAGES EXAMPLES: ${JSON.stringify(examplesMessages, null, 2)}
28
28
  `;
29
-
29
+ console.log("Synthesizer Context:", context);
30
30
  return context;
31
31
  }
32
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai.ntellect/core",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {