@ai.ntellect/core 0.1.85 → 0.1.89
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 +7 -3
- package/llm/synthesizer/context.ts +18 -3
- package/llm/synthesizer/index.ts +4 -2
- package/package.json +1 -1
package/agent/index.ts
CHANGED
@@ -186,7 +186,6 @@ export class Agent {
|
|
186
186
|
const sanitizedResults = ResultSanitizer.sanitize(this.accumulatedResults);
|
187
187
|
const summaryData = JSON.stringify({
|
188
188
|
result: sanitizedResults,
|
189
|
-
initialPrompt: actionsResult.initialPrompt,
|
190
189
|
});
|
191
190
|
|
192
191
|
this.accumulatedResults = [];
|
@@ -200,8 +199,13 @@ export class Agent {
|
|
200
199
|
});
|
201
200
|
|
202
201
|
return this.stream
|
203
|
-
? (
|
204
|
-
|
202
|
+
? (
|
203
|
+
await synthesizer.streamProcess(
|
204
|
+
actionsResult.initialPrompt,
|
205
|
+
summaryData
|
206
|
+
)
|
207
|
+
).toDataStreamResponse()
|
208
|
+
: await synthesizer.process(actionsResult.initialPrompt, summaryData);
|
205
209
|
}
|
206
210
|
|
207
211
|
private transformActions(actions: ActionSchema[]) {
|
@@ -25,10 +25,12 @@ export const synthesizerContext = {
|
|
25
25
|
"NEVER explain technical errors or issues. Just say retry later.",
|
26
26
|
],
|
27
27
|
},
|
28
|
-
compose: (
|
28
|
+
compose: (initialPrompt: string, summaryData?: string) => {
|
29
29
|
return `
|
30
30
|
${JSON.stringify(synthesizerContext.guidelines)}
|
31
|
-
|
31
|
+
|
32
|
+
Initial prompt: ${initialPrompt} (Speak in the same language as the initial prompt)
|
33
|
+
Results: ${summaryData}
|
32
34
|
|
33
35
|
1. FOR ALL ANALYSIS OF SPECIFIC TOKEN, RESPECT THE FOLLOWING FORMAT:
|
34
36
|
--------------------------------
|
@@ -44,8 +46,21 @@ export const synthesizerContext = {
|
|
44
46
|
|
45
47
|
STOP AFTER TECHNICAL ANALYSIS SECTION WITHOUT ANY CONCLUDING STATEMENT OR DISCLAIMER OR ADDITIONAL COMMENTS
|
46
48
|
--------------------------------
|
49
|
+
|
50
|
+
2. FOR SECURITY CHECKS, USE THE FOLLOWING FORMAT:
|
51
|
+
--------------------------------
|
52
|
+
## Security check of x/y:
|
53
|
+
|
54
|
+
### Good:
|
55
|
+
Speak about the good points of the security check. If there is no good point, say "No good point found"
|
56
|
+
|
57
|
+
### Bad:
|
58
|
+
Speak about the bad points of the security check. If there is no bad point, say "No bad point found"
|
59
|
+
|
60
|
+
STOP AFTER SECURITY CHECK SECTION WITHOUT ANY CONCLUDING STATEMENT OR DISCLAIMER OR ADDITIONAL COMMENTS
|
61
|
+
--------------------------------
|
47
62
|
|
48
|
-
|
63
|
+
3. OTHERWISE FOR OTHER REQUESTS, USE THE FORMAT YOU WANT.
|
49
64
|
`;
|
50
65
|
},
|
51
66
|
};
|
package/llm/synthesizer/index.ts
CHANGED
@@ -9,6 +9,7 @@ export class Synthesizer implements BaseLLM {
|
|
9
9
|
|
10
10
|
async process(
|
11
11
|
prompt: string,
|
12
|
+
summaryData?: string,
|
12
13
|
onFinish?: (event: any) => void
|
13
14
|
): Promise<
|
14
15
|
| {
|
@@ -32,7 +33,7 @@ export class Synthesizer implements BaseLLM {
|
|
32
33
|
),
|
33
34
|
response: z.string(),
|
34
35
|
}),
|
35
|
-
prompt: synthesizerContext.compose(prompt),
|
36
|
+
prompt: synthesizerContext.compose(prompt, summaryData || ""),
|
36
37
|
system: synthesizerContext.role,
|
37
38
|
});
|
38
39
|
console.log("Synthesizer");
|
@@ -43,11 +44,12 @@ export class Synthesizer implements BaseLLM {
|
|
43
44
|
|
44
45
|
async streamProcess(
|
45
46
|
prompt: string,
|
47
|
+
summaryData?: string,
|
46
48
|
onFinish?: (event: any) => void
|
47
49
|
): Promise<StreamTextResult<Record<string, any>>> {
|
48
50
|
const result = await streamText({
|
49
51
|
model: this.model,
|
50
|
-
prompt: synthesizerContext.compose(prompt),
|
52
|
+
prompt: synthesizerContext.compose(prompt, summaryData || ""),
|
51
53
|
onFinish: onFinish,
|
52
54
|
system: synthesizerContext.role,
|
53
55
|
});
|