@ai.ntellect/core 0.1.84 → 0.1.89

Sign up to get free protection for your applications and to get access to all the features.
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
- ? (await synthesizer.streamProcess(summaryData)).toDataStreamResponse()
204
- : await synthesizer.process(summaryData);
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[]) {
@@ -1,37 +1,43 @@
1
1
  import { ActionSchema } from "../../types";
2
2
  import { injectActions } from "../../utils/inject-actions";
3
-
4
3
  export const evaluatorContext = {
5
4
  role: "You are the evaluator agent. Your role is to verify if the goal has been achieved and if the results are correct.",
6
5
  guidelines: {
7
6
  important: [
8
- "Verify if all required actions were executed successfully",
9
- "Check if the results match the initial goal",
10
- "Identify any missing or incomplete information",
11
- "Extra and relevant information they don't have be stored in the memory: link symbol to token address, name to wallet, etc.",
7
+ "Verify if all required actions were executed successfully.",
8
+ "Check if the results align with the initial goal.",
9
+ "Identify and extract additional relevant information naturally during the process. Examples:",
10
+ " - Link a token symbol (e.g., 'USDC') to its address (e.g., '0xA0b8...6EB48').",
11
+ " - Associate a wallet address (e.g., '0x1234...abcd') to a user-friendly name (e.g., 'Work Wallet').",
12
+ " - Map a token address (e.g., '0x6B17...71d0F') back to its symbol or name (e.g., 'DAI').",
13
+ "Store these facts in memory with their type (episodic, semantic, or procedural).",
12
14
  ],
13
15
  warnings: [
14
- "NEVER modify the results directly",
15
- "NEVER make assumptions about missing data",
16
- "NEVER repeat the same action if you already did it",
16
+ "NEVER modify the results directly.",
17
+ "NEVER make assumptions about missing data.",
18
+ "NEVER repeat actions already completed unless explicitly required.",
17
19
  ],
18
20
  },
19
21
  compose: (goal: string, results: string, tools: ActionSchema[]) => {
20
22
  return `
21
- ${JSON.stringify(evaluatorContext.guidelines)}
22
-
23
- ACTIONS COMPLETED: ${results}
24
-
25
- Initial Goal: ${goal} (You must use the same language)
26
-
27
- The actions available are: ${injectActions(tools)}
28
-
29
- Evaluate if the goal has been achieved and provide:
30
- 1. Success status with explanation (no action needed)
31
- 2. Next actions needed (if any)
32
- 3. Why you are doing the next actions or why you are not doing them
33
- 4. Extract relevant information to remember
34
- 5. For each facts, generate a memoryType (3 memory types: episodic, semantic, procedural)
35
- `;
23
+ You are evaluating if the following goal has been achieved: "${goal}".
24
+
25
+ COMPLETED ACTIONS: ${results}
26
+
27
+ The tools available are: ${injectActions(tools)}
28
+
29
+ Follow these steps to evaluate:
30
+ 1. Verify success: Confirm if the goal has been fully or partially achieved. If partially, describe what's missing.
31
+ 2. Recommend next actions: Clearly state what needs to be done next (if applicable) and why.
32
+ 3. Extract relevant information:
33
+ - Example: Link token symbols to addresses, map wallet names to addresses, or connect tokens to specific networks.
34
+ - For each fact, specify its memory type:
35
+ - **Episodic**: Record specific events. Format: [{"type": "episodic", "query": "query", "event": "event", "description": "description"}]
36
+ - **Semantic**: Store general knowledge. Format: [{"knowledge": "knowledge", "link": "link", "type": "semantic", "description": "description"}]
37
+ - **Procedural**: Save recurring workflows. Format: [{"type": "procedural", "actions": [{"name": "action_name", "parameters": {"param1": "value1", "param2": "value2"}}]]
38
+ 4. Provide a final assessment: Explain if the user's goal is achievable with the tools and data available.
39
+
40
+ Be clear, concise, and prioritize storing key facts that may help improve future interactions.
41
+ `;
36
42
  },
37
43
  };
@@ -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: (results: string) => {
28
+ compose: (initialPrompt: string, summaryData?: string) => {
29
29
  return `
30
30
  ${JSON.stringify(synthesizerContext.guidelines)}
31
- Results: ${results}
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
- 2. OTHERWISE FOR OTHER REQUESTS, USE THE FORMAT YOU WANT.
63
+ 3. OTHERWISE FOR OTHER REQUESTS, USE THE FORMAT YOU WANT.
49
64
  `;
50
65
  },
51
66
  };
@@ -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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai.ntellect/core",
3
- "version": "0.1.84",
3
+ "version": "0.1.89",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {