@ai.ntellect/core 0.3.1 → 0.4.0

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.
Files changed (86) hide show
  1. package/.nvmrc +1 -0
  2. package/README.FR.md +201 -261
  3. package/README.md +208 -260
  4. package/agent/index.ts +204 -185
  5. package/agent/tools/get-rss.ts +64 -0
  6. package/bull.ts +5 -0
  7. package/dist/agent/index.d.ts +29 -22
  8. package/dist/agent/index.js +124 -97
  9. package/dist/agent/tools/get-rss.d.ts +16 -0
  10. package/dist/agent/tools/get-rss.js +62 -0
  11. package/dist/bull.d.ts +1 -0
  12. package/dist/bull.js +9 -0
  13. package/dist/examples/index.d.ts +2 -0
  14. package/dist/examples/index.js +89 -0
  15. package/dist/llm/interpreter/context.d.ts +5 -22
  16. package/dist/llm/interpreter/context.js +8 -9
  17. package/dist/llm/interpreter/index.d.ts +9 -5
  18. package/dist/llm/interpreter/index.js +55 -48
  19. package/dist/llm/memory-manager/context.d.ts +2 -0
  20. package/dist/llm/memory-manager/context.js +22 -0
  21. package/dist/llm/memory-manager/index.d.ts +17 -0
  22. package/dist/llm/memory-manager/index.js +107 -0
  23. package/dist/llm/orchestrator/context.d.ts +2 -10
  24. package/dist/llm/orchestrator/context.js +19 -16
  25. package/dist/llm/orchestrator/index.d.ts +36 -21
  26. package/dist/llm/orchestrator/index.js +122 -88
  27. package/dist/llm/orchestrator/types.d.ts +12 -0
  28. package/dist/llm/orchestrator/types.js +2 -0
  29. package/dist/memory/cache.d.ts +6 -6
  30. package/dist/memory/cache.js +35 -42
  31. package/dist/memory/persistent.d.ts +9 -13
  32. package/dist/memory/persistent.js +94 -114
  33. package/dist/services/redis-cache.d.ts +37 -0
  34. package/dist/services/redis-cache.js +93 -0
  35. package/dist/services/scheduler.d.ts +40 -0
  36. package/dist/services/scheduler.js +99 -0
  37. package/dist/services/telegram-monitor.d.ts +0 -0
  38. package/dist/services/telegram-monitor.js +118 -0
  39. package/dist/test.d.ts +0 -167
  40. package/dist/test.js +437 -372
  41. package/dist/types.d.ts +60 -9
  42. package/dist/utils/generate-object.d.ts +12 -0
  43. package/dist/utils/generate-object.js +90 -0
  44. package/dist/utils/header-builder.d.ts +11 -0
  45. package/dist/utils/header-builder.js +34 -0
  46. package/dist/utils/inject-actions.js +2 -2
  47. package/dist/utils/queue-item-transformer.d.ts +2 -2
  48. package/dist/utils/schema-generator.d.ts +16 -0
  49. package/dist/utils/schema-generator.js +46 -0
  50. package/examples/index.ts +103 -0
  51. package/llm/interpreter/context.ts +20 -8
  52. package/llm/interpreter/index.ts +81 -54
  53. package/llm/memory-manager/context.ts +21 -0
  54. package/llm/memory-manager/index.ts +163 -0
  55. package/llm/orchestrator/context.ts +20 -13
  56. package/llm/orchestrator/index.ts +210 -130
  57. package/llm/orchestrator/types.ts +14 -0
  58. package/memory/cache.ts +41 -55
  59. package/memory/persistent.ts +121 -149
  60. package/package.json +11 -2
  61. package/services/redis-cache.ts +128 -0
  62. package/services/scheduler.ts +128 -0
  63. package/services/telegram-monitor.ts +138 -0
  64. package/t.py +79 -0
  65. package/t.spec +38 -0
  66. package/types.ts +64 -9
  67. package/utils/generate-object.ts +105 -0
  68. package/utils/header-builder.ts +40 -0
  69. package/utils/inject-actions.ts +4 -6
  70. package/utils/queue-item-transformer.ts +2 -1
  71. package/utils/schema-generator.ts +73 -0
  72. package/agent/handlers/ActionHandler.ts +0 -48
  73. package/agent/handlers/ConfirmationHandler.ts +0 -37
  74. package/agent/handlers/EventHandler.ts +0 -35
  75. package/dist/agent/handlers/ActionHandler.d.ts +0 -8
  76. package/dist/agent/handlers/ActionHandler.js +0 -36
  77. package/dist/agent/handlers/ConfirmationHandler.d.ts +0 -7
  78. package/dist/agent/handlers/ConfirmationHandler.js +0 -31
  79. package/dist/agent/handlers/EventHandler.d.ts +0 -10
  80. package/dist/agent/handlers/EventHandler.js +0 -34
  81. package/dist/llm/evaluator/context.d.ts +0 -10
  82. package/dist/llm/evaluator/context.js +0 -22
  83. package/dist/llm/evaluator/index.d.ts +0 -16
  84. package/dist/llm/evaluator/index.js +0 -151
  85. package/llm/evaluator/context.ts +0 -21
  86. package/llm/evaluator/index.ts +0 -194
@@ -1,116 +1,143 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.Agent = void 0;
4
- const evaluator_1 = require("../llm/evaluator");
5
- const types_1 = require("../types");
7
+ const ws_1 = __importDefault(require("ws"));
8
+ const memory_manager_1 = require("../llm/memory-manager");
9
+ const orchestrator_1 = require("../llm/orchestrator");
10
+ const queue_1 = require("../services/queue");
11
+ const redis_cache_1 = require("../services/redis-cache");
6
12
  const queue_item_transformer_1 = require("../utils/queue-item-transformer");
7
- const sanitize_results_1 = require("../utils/sanitize-results");
8
- const ActionHandler_1 = require("./handlers/ActionHandler");
9
13
  class Agent {
10
- constructor({ orchestrator, interpreters, memory, stream, maxEvaluatorIteration = 1, }) {
11
- this.evaluatorIteration = 0;
12
- this.accumulatedResults = "";
13
- this.orchestrator = orchestrator;
14
- this.interpreters = interpreters;
15
- this.memory = memory;
16
- this.stream = stream;
17
- this.maxEvaluatorIteration = maxEvaluatorIteration;
18
- this.actionHandler = new ActionHandler_1.ActionHandler();
19
- this.accumulatedResults = "";
20
- }
21
- async process(prompt, events) {
22
- this.accumulatedResults = "";
23
- this.evaluatorIteration = 0;
24
- console.log("Requesting orchestrator for actions..");
25
- const cacheMemories = await this.memory.cache?.findSimilarActions(prompt, {
26
- similarityThreshold: 70,
27
- maxResults: 5,
28
- userId: "1",
29
- scope: types_1.MemoryScope.GLOBAL,
14
+ constructor(config) {
15
+ this.webSocketClients = new Map();
16
+ this.cache = new redis_cache_1.RedisCache(config.cache);
17
+ this.config = config;
18
+ this.agent = new orchestrator_1.AgentRuntime(config.orchestrator.model, config.orchestrator.tools, config.interpreters, config.cache, config.orchestrator.memory);
19
+ this.memoryManager = new memory_manager_1.MemoryManager({
20
+ model: config.memoryManager.model,
21
+ memory: {
22
+ cache: config.memoryManager.memory?.cache ?? undefined,
23
+ persistent: config.memoryManager.memory?.persistent ?? undefined,
24
+ },
30
25
  });
31
- console.log("✅ RECENT_ACTIONS: ", cacheMemories);
32
- const request = await this.orchestrator.process(prompt, `## RECENT_ACTIONS: ${JSON.stringify(cacheMemories)} ## CURRENT_RESULTS: ${this.accumulatedResults}`);
33
- events.onMessage?.(request);
34
- return request.actions.length > 0
35
- ? this.handleActions({
36
- initialPrompt: prompt,
37
- actions: request.actions,
38
- }, events)
39
- : undefined;
26
+ this.config.maxIterations = 3;
40
27
  }
41
- async handleActions({ initialPrompt, actions, }, events) {
42
- const queueItems = this.transformActions(actions);
43
- const actionsResult = await this.actionHandler.executeActions(queueItems, this.orchestrator.tools, {
44
- onQueueStart: events.onQueueStart,
45
- onActionStart: events.onActionStart,
46
- onActionComplete: events.onActionComplete,
47
- onQueueComplete: events.onQueueComplete,
48
- onConfirmationRequired: events.onConfirmationRequired,
49
- });
50
- this.accumulatedResults += this.formatResults(actionsResult.data);
51
- const isOnChainAction = actions.some((action) => action.type === "on-chain");
52
- if (isOnChainAction) {
53
- return {
54
- data: this.accumulatedResults,
55
- initialPrompt,
28
+ async process(state, callbacks) {
29
+ console.log("🔄 Processing state:");
30
+ console.dir(state, { depth: null });
31
+ let countIterations = 0;
32
+ const response = await this.agent.process(state);
33
+ const unscheduledActions = response.actions.filter((action) => !action.scheduler?.isScheduled);
34
+ // Execute actions if needed
35
+ if (unscheduledActions?.length > 0 && response.shouldContinue) {
36
+ console.log("\n📋 Processing action queue");
37
+ const queueManager = new queue_1.ActionQueueManager(this.config.orchestrator.tools, callbacks);
38
+ const queueItems = queue_item_transformer_1.QueueItemTransformer.transformActionsToQueueItems(response.actions);
39
+ if (!queueItems) {
40
+ throw new Error("No queue items found");
41
+ }
42
+ console.log("📋 Actions to execute:", queueItems
43
+ .map((item) => (typeof item === "string" ? item : item.name))
44
+ .join(", "));
45
+ queueManager.addToQueue(queueItems);
46
+ console.log("\n⚡ Executing actions...");
47
+ const results = await queueManager.processQueue();
48
+ console.log("✅ Execution results:", results);
49
+ const updatedNextState = {
50
+ ...state,
51
+ currentContext: state.currentContext,
52
+ previousActions: [...(state.previousActions || []), ...(results || [])],
56
53
  };
54
+ console.log("\n🔁 Recursively processing with updated state");
55
+ countIterations++;
56
+ if (countIterations < this.config.maxIterations) {
57
+ return this.process(updatedNextState);
58
+ }
57
59
  }
58
- if (this.evaluatorIteration >= this.maxEvaluatorIteration) {
59
- return this.interpreterResult({
60
- data: this.accumulatedResults,
61
- initialPrompt,
62
- interpreter: this.interpreters[0],
63
- });
60
+ if (countIterations >= this.config.maxIterations) {
61
+ console.log("Max iterations reached");
62
+ response.shouldContinue = false;
63
+ console.log("Forcing stop");
64
64
  }
65
- const evaluator = new evaluator_1.Evaluator(this.orchestrator.tools, this.memory, this.interpreters);
66
- // const sanitizedResults = ResultSanitizer.sanitize(this.accumulatedResults);
67
- const evaluation = await evaluator.process(initialPrompt, this.accumulatedResults);
68
- events.onMessage?.(evaluation);
69
- if (evaluation.isNextActionNeeded) {
70
- this.evaluatorIteration++;
71
- return this.handleActions({
72
- initialPrompt: initialPrompt,
73
- actions: evaluation.nextActionsNeeded,
74
- }, events);
65
+ // Handle final interpretation
66
+ if (!response.shouldContinue &&
67
+ state.previousActions?.length &&
68
+ response.interpreter) {
69
+ console.log("\n🏁 Analysis complete - generating final interpretation");
70
+ const interpreter = this.getInterpreter(this.config.interpreters, response.interpreter);
71
+ console.log("🎭 Selected Interpreter:", interpreter?.name);
72
+ console.dir(state, { depth: null });
73
+ const interpretationResult = (await interpreter?.process("Interpret the analysis results", {
74
+ ...state,
75
+ results: JSON.stringify(state.previousActions),
76
+ userRequest: state.currentContext,
77
+ }));
78
+ console.log("\n📊 Final Analysis:", interpretationResult.response);
79
+ const finalState = {
80
+ ...state,
81
+ results: interpretationResult.response,
82
+ };
83
+ console.log("🔄 Final state:", finalState);
75
84
  }
76
- const interpreter = this.getInterpreter(this.interpreters, evaluation.interpreter);
77
- if (!interpreter) {
78
- throw new Error("Interpreter not found");
85
+ // Return the final response at the end of the function
86
+ const validatedActions = response.actions.map((action) => ({
87
+ ...action,
88
+ parameters: action.parameters.map((param) => ({
89
+ ...param,
90
+ value: param.value ?? null, // Set a default value if undefined
91
+ })),
92
+ }));
93
+ const result = {
94
+ ...response,
95
+ actions: validatedActions,
96
+ results: JSON.stringify(state.previousActions),
97
+ };
98
+ if (!result.shouldContinue) {
99
+ await this.memoryManager.process(state, JSON.stringify(result));
79
100
  }
80
- return this.interpreterResult({
81
- data: this.accumulatedResults,
82
- initialPrompt,
83
- interpreter,
84
- });
101
+ return result;
85
102
  }
86
103
  getInterpreter(interpreters, name) {
87
104
  return interpreters.find((interpreter) => interpreter.name === name);
88
105
  }
89
- async interpreterResult(actionsResult) {
90
- const { interpreter, initialPrompt, data } = actionsResult;
91
- return this.stream
92
- ? (await interpreter.streamProcess(initialPrompt, {
93
- userRequest: initialPrompt,
94
- results: data,
95
- })).toDataStreamResponse()
96
- : await interpreter.process(initialPrompt, {
97
- userRequest: initialPrompt,
98
- results: data,
99
- });
100
- }
101
- transformActions(actions) {
102
- let predefinedActions = queue_item_transformer_1.QueueItemTransformer.transformActionsToQueueItems(actions) || [];
103
- return predefinedActions;
104
- }
105
- formatResults(results) {
106
- const formattedResults = results.map((result) => ({
107
- ...result,
108
- result: typeof result.result === "object"
109
- ? JSON.stringify(result.result)
110
- : result.result,
111
- }));
112
- const sanitizedResults = sanitize_results_1.ResultSanitizer.sanitize(formattedResults);
113
- return sanitizedResults;
106
+ addListener(id, url, subscriptionMessageFactory, callback) {
107
+ if (this.webSocketClients.has(id)) {
108
+ console.warn(`WebSocket with ID ${id} already exists.`);
109
+ return;
110
+ }
111
+ const socket = new ws_1.default(url);
112
+ const wrappedCallback = async (data) => {
113
+ await callback(data, this);
114
+ };
115
+ socket.on("open", () => {
116
+ console.log(`🔗 WebSocket connected for ID: ${id}`);
117
+ // Envoie le message d'abonnement si une factory est fournie
118
+ if (subscriptionMessageFactory) {
119
+ const subscriptionMessage = subscriptionMessageFactory();
120
+ socket.send(subscriptionMessage);
121
+ console.log(`📡 Sent subscription message for ID ${id}:`, subscriptionMessage);
122
+ }
123
+ });
124
+ socket.on("message", async (message) => {
125
+ console.log(`📨 Message received for WebSocket ID ${id}:`, message);
126
+ try {
127
+ const data = JSON.parse(message);
128
+ await wrappedCallback(data);
129
+ }
130
+ catch (error) {
131
+ console.error(`❌ Error in callback for WebSocket ID ${id}:`, error);
132
+ }
133
+ });
134
+ socket.on("error", (error) => {
135
+ console.error(`❌ WebSocket error for ID ${id}:`, error);
136
+ });
137
+ socket.on("close", () => {
138
+ console.log(`🔌 WebSocket closed for ID: ${id}`);
139
+ });
140
+ this.webSocketClients.set(id, { socket, callback: wrappedCallback });
114
141
  }
115
142
  }
116
143
  exports.Agent = Agent;
@@ -0,0 +1,16 @@
1
+ import { z } from "zod";
2
+ export declare const getRssNews: {
3
+ name: string;
4
+ description: string;
5
+ parameters: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
6
+ execute: () => Promise<{
7
+ status: string;
8
+ items: {
9
+ title: any;
10
+ content: string;
11
+ link: any;
12
+ date: any;
13
+ source: any;
14
+ }[];
15
+ }>;
16
+ };
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getRssNews = void 0;
7
+ const rss_parser_1 = __importDefault(require("rss-parser"));
8
+ const zod_1 = require("zod");
9
+ const RSS_FEEDS = [
10
+ "https://www.investing.com/rss/news_301.rss",
11
+ "https://cointelegraph.com/rss/category/analysis",
12
+ "https://cointelegraph.com/rss/category/top-10-cryptocurrencies",
13
+ ];
14
+ const parser = new rss_parser_1.default();
15
+ function stripHtmlTags(content) {
16
+ if (!content)
17
+ return "";
18
+ return content
19
+ .replace(/<[^>]*>/g, "")
20
+ .replace(/\n/g, "")
21
+ .replace(" ", "");
22
+ }
23
+ exports.getRssNews = {
24
+ name: "get-news-rss",
25
+ description: "Get latest news about on website",
26
+ parameters: zod_1.z.object({}),
27
+ execute: async () => {
28
+ const itemsPerSource = 5;
29
+ try {
30
+ const feedPromises = RSS_FEEDS.map((url) => parser.parseURL(url));
31
+ const results = await Promise.allSettled(feedPromises);
32
+ const successfulFeeds = results
33
+ .filter((result) => {
34
+ return (result.status === "fulfilled" && result.value?.items?.length > 0);
35
+ })
36
+ .map((result) => result.value);
37
+ const allItems = successfulFeeds
38
+ .flatMap((feed) => feed.items.slice(0, itemsPerSource))
39
+ .sort((a, b) => {
40
+ const dateA = a.pubDate ? new Date(a.pubDate).getTime() : 0;
41
+ const dateB = b.pubDate ? new Date(b.pubDate).getTime() : 0;
42
+ return dateB - dateA;
43
+ })
44
+ .slice(0, 5)
45
+ .map((item) => ({
46
+ title: item.title,
47
+ content: stripHtmlTags(item.content),
48
+ link: item.link,
49
+ date: item.pubDate,
50
+ source: item.creator || new URL(item.link).hostname,
51
+ }));
52
+ const result = {
53
+ status: "success",
54
+ items: allItems,
55
+ };
56
+ return result;
57
+ }
58
+ catch (error) {
59
+ throw error;
60
+ }
61
+ },
62
+ };
package/dist/bull.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/bull.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_cron_1 = __importDefault(require("node-cron"));
7
+ node_cron_1.default.schedule("* * * * *", () => {
8
+ console.log("running a task every minute");
9
+ });
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const deepseek_1 = require("@ai-sdk/deepseek");
8
+ const dotenv_1 = require("dotenv");
9
+ const readline_1 = __importDefault(require("readline"));
10
+ const agent_1 = require("../agent");
11
+ const get_rss_1 = require("../agent/tools/get-rss");
12
+ const interpreter_1 = require("../llm/interpreter");
13
+ const context_1 = require("../llm/interpreter/context");
14
+ (0, dotenv_1.configDotenv)();
15
+ // Initialiser l'agent une fois pour toute la session
16
+ const initializeAgent = () => {
17
+ const model = (0, deepseek_1.deepseek)("deepseek-reasoner");
18
+ const securityInterpreter = new interpreter_1.Interpreter({
19
+ name: "security",
20
+ model,
21
+ character: context_1.securityInterpreterCharacter,
22
+ });
23
+ const marketInterpreter = new interpreter_1.Interpreter({
24
+ name: "market",
25
+ model,
26
+ character: context_1.marketInterpreterCharacter,
27
+ });
28
+ const generalInterpreter = new interpreter_1.Interpreter({
29
+ name: "general",
30
+ model,
31
+ character: context_1.generalInterpreterCharacter,
32
+ });
33
+ const agent = new agent_1.Agent({
34
+ cache: {
35
+ host: process.env.REDIS_HOST || "localhost",
36
+ port: Number(process.env.REDIS_PORT) || 6379,
37
+ },
38
+ orchestrator: {
39
+ model,
40
+ tools: [get_rss_1.getRssNews],
41
+ },
42
+ interpreters: [securityInterpreter, marketInterpreter, generalInterpreter],
43
+ memoryManager: {
44
+ model,
45
+ },
46
+ maxIterations: 3,
47
+ });
48
+ return agent;
49
+ };
50
+ // Fonction pour lancer une session interactive
51
+ const startChatSession = async () => {
52
+ console.log("Bienvenue dans votre session de chat avec l'agent !");
53
+ console.log("Tapez 'exit' pour quitter.\n");
54
+ const agent = initializeAgent();
55
+ const rl = readline_1.default.createInterface({
56
+ input: process.stdin,
57
+ output: process.stdout,
58
+ prompt: "Vous > ",
59
+ });
60
+ let state = {
61
+ currentContext: "",
62
+ previousActions: [],
63
+ };
64
+ rl.prompt();
65
+ rl.on("line", async (line) => {
66
+ const input = line.trim();
67
+ if (input.toLowerCase() === "exit") {
68
+ console.log("Fin de la session. À bientôt !");
69
+ rl.close();
70
+ return;
71
+ }
72
+ state.currentContext = input;
73
+ console.log("Agent en réflexion...");
74
+ try {
75
+ const result = await agent.process(state);
76
+ console.log(`Agent > ${result}\n`);
77
+ }
78
+ catch (error) {
79
+ console.error("Erreur avec l'agent :", error);
80
+ }
81
+ rl.prompt();
82
+ });
83
+ rl.on("close", () => {
84
+ console.log("Session terminée.");
85
+ process.exit(0);
86
+ });
87
+ };
88
+ // Lancer la session de chat
89
+ startChatSession();
@@ -1,32 +1,15 @@
1
- export declare const generalInterpreterContext: {
2
- role: string;
3
- language: string;
4
- guidelines: {
5
- important: never[];
6
- warnings: never[];
7
- };
8
- };
9
- export declare const securityInterpreterContext: {
10
- role: string;
11
- language: string;
12
- guidelines: {
13
- important: string[];
14
- warnings: string[];
15
- };
16
- examplesMessages: {
17
- role: string;
18
- content: string;
19
- }[];
20
- };
21
- export declare const marketInterpreterContext: {
1
+ export type Character = {
22
2
  role: string;
23
3
  language: string;
24
4
  guidelines: {
25
5
  important: string[];
26
6
  warnings: string[];
27
7
  };
28
- examplesMessages: {
8
+ examplesMessages?: {
29
9
  role: string;
30
10
  content: string;
31
11
  }[];
32
12
  };
13
+ export declare const generalInterpreterCharacter: Character;
14
+ export declare const securityInterpreterCharacter: Character;
15
+ export declare const marketInterpreterCharacter: Character;
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.marketInterpreterContext = exports.securityInterpreterContext = exports.generalInterpreterContext = void 0;
4
- exports.generalInterpreterContext = {
3
+ exports.marketInterpreterCharacter = exports.securityInterpreterCharacter = exports.generalInterpreterCharacter = void 0;
4
+ exports.generalInterpreterCharacter = {
5
5
  role: "You are the general assistant. Your role is to provide a clear and factual analysis of the results.",
6
- language: "user_language",
6
+ language: "user_request",
7
7
  guidelines: {
8
8
  important: [],
9
9
  warnings: [],
10
10
  },
11
11
  };
12
- exports.securityInterpreterContext = {
12
+ exports.securityInterpreterCharacter = {
13
13
  role: "You are the security expert. Your role is to provide a clear and factual analysis of the security of the token/coin.",
14
- language: "user_language",
14
+ language: "user_request",
15
15
  guidelines: {
16
16
  important: [
17
17
  "Start with a clear security analysis of the token/coin.",
@@ -48,12 +48,12 @@ exports.securityInterpreterContext = {
48
48
  },
49
49
  ],
50
50
  };
51
- exports.marketInterpreterContext = {
51
+ exports.marketInterpreterCharacter = {
52
52
  role: "You are the market expert. Your role is to provide a clear and factual analysis of the market sentiment of the token/coin.",
53
- language: "user_language",
53
+ language: "user_request",
54
54
  guidelines: {
55
55
  important: [
56
- "Start with a clear market sentiment (Bullish/Bearish/Neutral) without any additional comments before.",
56
+ "Start with a clear market sentiment (Market sentiment: Bullish/Bearish/Neutral 📈📉📊) without any additional comments before.",
57
57
  "One section for fundamental analysis (important events, news, trends..etc). One section, no sub-sections.",
58
58
  "One section for technical analysis (key price levels, trading volume, technical indicators, market activity). One section, no sub-sections.",
59
59
  "STOP AFTER TECHNICAL ANALYSIS SECTION WITHOUT ANY ADDITIONAL COMMENTS",
@@ -61,7 +61,6 @@ exports.marketInterpreterContext = {
61
61
  warnings: [
62
62
  "NEVER provide any financial advice.",
63
63
  "NEVER speak about details of your system or your capabilities.",
64
- "NEVER ADD ANY CONCLUDING STATEMENT OR DISCLAIMER AT THE END",
65
64
  ],
66
65
  },
67
66
  examplesMessages: [
@@ -1,11 +1,15 @@
1
- import { StreamTextResult } from "ai";
1
+ import { LanguageModel, StreamTextResult } from "ai";
2
2
  import { Behavior, State } from "../../types";
3
3
  export declare class Interpreter {
4
- private readonly behavior;
5
- private readonly model;
4
+ readonly model: LanguageModel;
6
5
  readonly name: string;
7
- constructor(name: string, behavior: Behavior);
8
- composeContext(state: State): string;
6
+ readonly character: Behavior;
7
+ constructor({ name, model, character, }: {
8
+ name: string;
9
+ model: LanguageModel;
10
+ character: Behavior;
11
+ });
12
+ private buildContext;
9
13
  process(prompt: string, state: State, onFinish?: (event: any) => void): Promise<{
10
14
  actionsCompleted: {
11
15
  name: string;