@ai.ntellect/core 0.2.3 ā 0.2.5
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 +13 -24
- package/dist/agent/index.d.ts +1 -0
- package/dist/agent/index.js +10 -16
- package/dist/llm/synthesizer/context.d.ts +4 -4
- package/dist/llm/synthesizer/context.js +37 -37
- package/llm/synthesizer/context.ts +37 -37
- package/llm/synthesizer/index.ts +1 -0
- package/package.json +1 -1
package/agent/index.ts
CHANGED
@@ -3,14 +3,7 @@ import { Orchestrator } from "../llm/orchestrator";
|
|
3
3
|
import { Synthesizer } from "../llm/synthesizer";
|
4
4
|
import { CacheMemory } from "../memory/cache";
|
5
5
|
import { PersistentMemory } from "../memory/persistent";
|
6
|
-
import {
|
7
|
-
ActionSchema,
|
8
|
-
AgentEvent,
|
9
|
-
MemoryScope,
|
10
|
-
MemoryType,
|
11
|
-
QueueResult,
|
12
|
-
User,
|
13
|
-
} from "../types";
|
6
|
+
import { ActionSchema, AgentEvent, QueueResult, User } from "../types";
|
14
7
|
import { QueueItemTransformer } from "../utils/queue-item-transformer";
|
15
8
|
import { ActionHandler } from "./handlers/ActionHandler";
|
16
9
|
|
@@ -126,8 +119,6 @@ export class Agent {
|
|
126
119
|
this.orchestrator.tools,
|
127
120
|
this.persistentMemory
|
128
121
|
);
|
129
|
-
console.log("Accumulated results:");
|
130
|
-
console.dir(this.accumulatedResults, { depth: null });
|
131
122
|
|
132
123
|
// const sanitizedResults = ResultSanitizer.sanitize(this.accumulatedResults);
|
133
124
|
const evaluation = await evaluator.process(
|
@@ -160,28 +151,16 @@ export class Agent {
|
|
160
151
|
}) {
|
161
152
|
const synthesizer = new Synthesizer();
|
162
153
|
|
163
|
-
for (const action of actionsResult.data) {
|
164
|
-
if (!action.error) {
|
165
|
-
await this.cacheMemory?.createMemory({
|
166
|
-
content: actionsResult.initialPrompt,
|
167
|
-
data: action.result,
|
168
|
-
scope: MemoryScope.GLOBAL,
|
169
|
-
type: MemoryType.ACTION,
|
170
|
-
});
|
171
|
-
}
|
172
|
-
}
|
173
|
-
|
174
|
-
const accumulatedResults = this.accumulatedResults;
|
175
154
|
return this.stream
|
176
155
|
? (
|
177
156
|
await synthesizer.streamProcess(
|
178
157
|
actionsResult.initialPrompt,
|
179
|
-
|
158
|
+
this.formatResults(actionsResult.data)
|
180
159
|
)
|
181
160
|
).toDataStreamResponse()
|
182
161
|
: await synthesizer.process(
|
183
162
|
actionsResult.initialPrompt,
|
184
|
-
|
163
|
+
this.formatResults(actionsResult.data)
|
185
164
|
);
|
186
165
|
}
|
187
166
|
|
@@ -191,4 +170,14 @@ export class Agent {
|
|
191
170
|
|
192
171
|
return predefinedActions;
|
193
172
|
}
|
173
|
+
|
174
|
+
private formatResults(results: QueueResult[]): QueueResult[] {
|
175
|
+
return results.map((result) => ({
|
176
|
+
...result,
|
177
|
+
result:
|
178
|
+
typeof result.result === "object"
|
179
|
+
? JSON.stringify(result.result)
|
180
|
+
: result.result,
|
181
|
+
}));
|
182
|
+
}
|
194
183
|
}
|
package/dist/agent/index.d.ts
CHANGED
package/dist/agent/index.js
CHANGED
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Agent = void 0;
|
4
4
|
const evaluator_1 = require("../llm/evaluator");
|
5
5
|
const synthesizer_1 = require("../llm/synthesizer");
|
6
|
-
const types_1 = require("../types");
|
7
6
|
const queue_item_transformer_1 = require("../utils/queue-item-transformer");
|
8
7
|
const ActionHandler_1 = require("./handlers/ActionHandler");
|
9
8
|
class Agent {
|
@@ -58,8 +57,6 @@ class Agent {
|
|
58
57
|
});
|
59
58
|
}
|
60
59
|
const evaluator = new evaluator_1.Evaluator(this.orchestrator.tools, this.persistentMemory);
|
61
|
-
console.log("Accumulated results:");
|
62
|
-
console.dir(this.accumulatedResults, { depth: null });
|
63
60
|
// const sanitizedResults = ResultSanitizer.sanitize(this.accumulatedResults);
|
64
61
|
const evaluation = await evaluator.process(initialPrompt, this.accumulatedResults);
|
65
62
|
events.onMessage?.(evaluation);
|
@@ -77,24 +74,21 @@ class Agent {
|
|
77
74
|
}
|
78
75
|
async handleActionResults(actionsResult) {
|
79
76
|
const synthesizer = new synthesizer_1.Synthesizer();
|
80
|
-
for (const action of actionsResult.data) {
|
81
|
-
if (!action.error) {
|
82
|
-
await this.cacheMemory?.createMemory({
|
83
|
-
content: actionsResult.initialPrompt,
|
84
|
-
data: action.result,
|
85
|
-
scope: types_1.MemoryScope.GLOBAL,
|
86
|
-
type: types_1.MemoryType.ACTION,
|
87
|
-
});
|
88
|
-
}
|
89
|
-
}
|
90
|
-
const accumulatedResults = this.accumulatedResults;
|
91
77
|
return this.stream
|
92
|
-
? (await synthesizer.streamProcess(actionsResult.initialPrompt,
|
93
|
-
: await synthesizer.process(actionsResult.initialPrompt,
|
78
|
+
? (await synthesizer.streamProcess(actionsResult.initialPrompt, this.formatResults(actionsResult.data))).toDataStreamResponse()
|
79
|
+
: await synthesizer.process(actionsResult.initialPrompt, this.formatResults(actionsResult.data));
|
94
80
|
}
|
95
81
|
transformActions(actions) {
|
96
82
|
let predefinedActions = queue_item_transformer_1.QueueItemTransformer.transformActionsToQueueItems(actions) || [];
|
97
83
|
return predefinedActions;
|
98
84
|
}
|
85
|
+
formatResults(results) {
|
86
|
+
return results.map((result) => ({
|
87
|
+
...result,
|
88
|
+
result: typeof result.result === "object"
|
89
|
+
? JSON.stringify(result.result)
|
90
|
+
: result.result,
|
91
|
+
}));
|
92
|
+
}
|
99
93
|
}
|
100
94
|
exports.Agent = Agent;
|
@@ -25,47 +25,47 @@ exports.synthesizerContext = {
|
|
25
25
|
"Respond in the same language as the user request.",
|
26
26
|
],
|
27
27
|
},
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
28
|
+
},
|
29
|
+
examplesMessages: [
|
30
|
+
{
|
31
|
+
role: "user",
|
32
|
+
content: "Analysis security of token/coin",
|
33
|
+
},
|
34
|
+
{
|
35
|
+
role: "assistant",
|
36
|
+
content: `
|
37
|
+
## Security analysis of x/y:
|
38
|
+
|
39
|
+
### Good:
|
40
|
+
Speak about the good points of the security check. If there is no good point, say "No good point found"
|
40
41
|
|
41
|
-
|
42
|
-
|
42
|
+
### Bad:
|
43
|
+
Speak about the bad points of the security check. If there is no bad point, say "No bad point found"
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
45
|
+
STOP AFTER SECURITY CHECK SECTION WITHOUT ANY CONCLUDING STATEMENT OR DISCLAIMER OR ADDITIONAL COMMENTS
|
46
|
+
--------------------------------
|
47
|
+
`,
|
48
|
+
},
|
49
|
+
{
|
50
|
+
role: "user",
|
51
|
+
content: "Analysis market sentiment of token/coin",
|
52
|
+
},
|
53
|
+
{
|
54
|
+
role: "assistant",
|
55
|
+
content: `
|
56
|
+
## Analysis of x/y:
|
56
57
|
|
57
|
-
|
58
|
+
Market sentiment: Bullish š (Adapt the emoji to the market sentiment)
|
58
59
|
|
59
|
-
|
60
|
-
|
60
|
+
### Fundamental analysis (No sub-sections):
|
61
|
+
Speak about important events, news, trends..etc
|
61
62
|
|
62
|
-
|
63
|
-
|
63
|
+
### Technical analysis (No sub-sections):
|
64
|
+
Speak about key price levels, trading volume, technical indicators, market activity..etc
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
},
|
66
|
+
STOP AFTER TECHNICAL ANALYSIS SECTION WITHOUT ANY CONCLUDING STATEMENT OR DISCLAIMER OR ADDITIONAL COMMENTS
|
67
|
+
--------------------------------
|
68
|
+
`,
|
69
|
+
},
|
70
|
+
],
|
71
71
|
};
|
@@ -22,47 +22,47 @@ export const synthesizerContext = {
|
|
22
22
|
"Respond in the same language as the user request.",
|
23
23
|
],
|
24
24
|
},
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
25
|
+
},
|
26
|
+
examplesMessages: [
|
27
|
+
{
|
28
|
+
role: "user",
|
29
|
+
content: "Analysis security of token/coin",
|
30
|
+
},
|
31
|
+
{
|
32
|
+
role: "assistant",
|
33
|
+
content: `
|
34
|
+
## Security analysis of x/y:
|
35
|
+
|
36
|
+
### Good:
|
37
|
+
Speak about the good points of the security check. If there is no good point, say "No good point found"
|
37
38
|
|
38
|
-
|
39
|
-
|
39
|
+
### Bad:
|
40
|
+
Speak about the bad points of the security check. If there is no bad point, say "No bad point found"
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
42
|
+
STOP AFTER SECURITY CHECK SECTION WITHOUT ANY CONCLUDING STATEMENT OR DISCLAIMER OR ADDITIONAL COMMENTS
|
43
|
+
--------------------------------
|
44
|
+
`,
|
45
|
+
},
|
46
|
+
{
|
47
|
+
role: "user",
|
48
|
+
content: "Analysis market sentiment of token/coin",
|
49
|
+
},
|
50
|
+
{
|
51
|
+
role: "assistant",
|
52
|
+
content: `
|
53
|
+
## Analysis of x/y:
|
53
54
|
|
54
|
-
|
55
|
+
Market sentiment: Bullish š (Adapt the emoji to the market sentiment)
|
55
56
|
|
56
|
-
|
57
|
-
|
57
|
+
### Fundamental analysis (No sub-sections):
|
58
|
+
Speak about important events, news, trends..etc
|
58
59
|
|
59
|
-
|
60
|
-
|
60
|
+
### Technical analysis (No sub-sections):
|
61
|
+
Speak about key price levels, trading volume, technical indicators, market activity..etc
|
61
62
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
},
|
63
|
+
STOP AFTER TECHNICAL ANALYSIS SECTION WITHOUT ANY CONCLUDING STATEMENT OR DISCLAIMER OR ADDITIONAL COMMENTS
|
64
|
+
--------------------------------
|
65
|
+
`,
|
66
|
+
},
|
67
|
+
],
|
68
68
|
};
|
package/llm/synthesizer/index.ts
CHANGED
@@ -47,6 +47,7 @@ export class Synthesizer {
|
|
47
47
|
console.log("\nšØ Starting synthesis process");
|
48
48
|
console.log("Prompt:", prompt);
|
49
49
|
console.log("Results to synthesize:", JSON.stringify(results, null, 2));
|
50
|
+
|
50
51
|
const context = this.composeContext({
|
51
52
|
behavior: synthesizerContext.behavior,
|
52
53
|
userRequest: prompt,
|