@ai.ntellect/core 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
package/dist/agent/index.js
CHANGED
@@ -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, }) {
|
@@ -76,12 +75,6 @@ class Agent {
|
|
76
75
|
}
|
77
76
|
async handleActionResults(actionsResult) {
|
78
77
|
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
78
|
for (const action of actionsResult.data) {
|
86
79
|
if (!action.error) {
|
87
80
|
await this.cacheMemory?.createMemory({
|
@@ -92,9 +85,12 @@ class Agent {
|
|
92
85
|
});
|
93
86
|
}
|
94
87
|
}
|
88
|
+
const accumulatedResults = this.accumulatedResults;
|
89
|
+
this.accumulatedResults = [];
|
90
|
+
this.evaluatorIteration = 0;
|
95
91
|
return this.stream
|
96
|
-
? (await synthesizer.streamProcess(actionsResult.initialPrompt,
|
97
|
-
: await synthesizer.process(actionsResult.initialPrompt,
|
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) || [];
|
@@ -75,12 +75,12 @@ class Synthesizer {
|
|
75
75
|
});
|
76
76
|
const result = await (0, ai_1.streamText)({
|
77
77
|
model: this.model,
|
78
|
-
prompt,
|
79
78
|
onFinish: (event) => {
|
80
79
|
console.log("\n✅ Streaming synthesis completed");
|
81
80
|
if (onFinish)
|
82
81
|
onFinish(event);
|
83
82
|
},
|
83
|
+
prompt,
|
84
84
|
system: context,
|
85
85
|
});
|
86
86
|
return result;
|