@ai.ntellect/core 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- package/agent/index.ts +6 -10
- package/dist/agent/index.js +5 -9
- package/dist/llm/synthesizer/index.js +1 -1
- package/llm/synthesizer/index.ts +1 -1
- package/package.json +1 -1
package/agent/index.ts
CHANGED
@@ -12,7 +12,6 @@ import {
|
|
12
12
|
User,
|
13
13
|
} from "../types";
|
14
14
|
import { QueueItemTransformer } from "../utils/queue-item-transformer";
|
15
|
-
import { ResultSanitizer } from "../utils/sanitize-results";
|
16
15
|
import { ActionHandler } from "./handlers/ActionHandler";
|
17
16
|
|
18
17
|
export class Agent {
|
@@ -158,13 +157,6 @@ export class Agent {
|
|
158
157
|
initialPrompt: string;
|
159
158
|
}) {
|
160
159
|
const synthesizer = new Synthesizer();
|
161
|
-
const sanitizedResults = ResultSanitizer.sanitize(this.accumulatedResults);
|
162
|
-
const summaryData = JSON.stringify({
|
163
|
-
result: sanitizedResults,
|
164
|
-
});
|
165
|
-
|
166
|
-
this.accumulatedResults = [];
|
167
|
-
this.evaluatorIteration = 0;
|
168
160
|
|
169
161
|
for (const action of actionsResult.data) {
|
170
162
|
if (!action.error) {
|
@@ -177,16 +169,20 @@ export class Agent {
|
|
177
169
|
}
|
178
170
|
}
|
179
171
|
|
172
|
+
const accumulatedResults = this.accumulatedResults;
|
173
|
+
this.accumulatedResults = [];
|
174
|
+
this.evaluatorIteration = 0;
|
175
|
+
|
180
176
|
return this.stream
|
181
177
|
? (
|
182
178
|
await synthesizer.streamProcess(
|
183
179
|
actionsResult.initialPrompt,
|
184
|
-
|
180
|
+
accumulatedResults
|
185
181
|
)
|
186
182
|
).toDataStreamResponse()
|
187
183
|
: await synthesizer.process(
|
188
184
|
actionsResult.initialPrompt,
|
189
|
-
|
185
|
+
accumulatedResults
|
190
186
|
);
|
191
187
|
}
|
192
188
|
|
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;
|
package/llm/synthesizer/index.ts
CHANGED
@@ -102,11 +102,11 @@ export class Synthesizer {
|
|
102
102
|
|
103
103
|
const result = await streamText({
|
104
104
|
model: this.model,
|
105
|
-
prompt,
|
106
105
|
onFinish: (event) => {
|
107
106
|
console.log("\n✅ Streaming synthesis completed");
|
108
107
|
if (onFinish) onFinish(event);
|
109
108
|
},
|
109
|
+
prompt,
|
110
110
|
system: context,
|
111
111
|
});
|
112
112
|
|