@ai.ntellect/core 0.5.0 → 0.6.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 (131) hide show
  1. package/.mocharc.json +1 -1
  2. package/README.md +311 -272
  3. package/dist/graph/controller.js +63 -0
  4. package/dist/graph/engine.js +563 -0
  5. package/dist/index.js +6 -6
  6. package/dist/memory/adapters/meilisearch/index.js +249 -0
  7. package/dist/memory/adapters/redis/index.js +96 -0
  8. package/dist/memory/index.js +9 -0
  9. package/dist/services/agenda.js +115 -0
  10. package/dist/services/embedding.js +40 -0
  11. package/dist/services/queue.js +99 -103
  12. package/dist/test/graph/controller.test.js +170 -0
  13. package/dist/test/graph/engine.test.js +465 -0
  14. package/dist/test/memory/adapters/meilisearch.test.js +250 -0
  15. package/dist/test/memory/adapters/redis.test.js +143 -0
  16. package/dist/test/memory/base.test.js +209 -0
  17. package/dist/test/services/agenda.test.js +230 -0
  18. package/dist/test/services/queue.test.js +258 -0
  19. package/dist/types/index.js +2 -0
  20. package/dist/utils/generate-object.js +32 -11
  21. package/dist/utils/inject-actions.js +2 -2
  22. package/dist/utils/queue-item-transformer.js +2 -2
  23. package/dist/utils/state-manager.js +20 -0
  24. package/graph/controller.ts +60 -0
  25. package/{services/workflow.ts → graph/engine.ts} +331 -113
  26. package/index.ts +7 -7
  27. package/interfaces/index.ts +119 -0
  28. package/memory/adapters/meilisearch/index.ts +286 -0
  29. package/memory/adapters/redis/index.ts +103 -0
  30. package/memory/index.ts +22 -0
  31. package/package.json +7 -2
  32. package/services/agenda.ts +48 -43
  33. package/services/embedding.ts +26 -0
  34. package/services/queue.ts +2 -29
  35. package/test/.env.test +4 -0
  36. package/test/graph/controller.test.ts +186 -0
  37. package/test/graph/engine.test.ts +563 -0
  38. package/test/memory/adapters/meilisearch.test.ts +297 -0
  39. package/test/memory/adapters/redis.test.ts +160 -0
  40. package/test/memory/base.test.ts +229 -0
  41. package/test/services/agenda.test.ts +280 -0
  42. package/test/services/queue.test.ts +286 -44
  43. package/tsconfig.json +10 -10
  44. package/types/index.ts +270 -0
  45. package/utils/generate-object.js +111 -0
  46. package/utils/header-builder.js +34 -0
  47. package/utils/inject-actions.js +16 -0
  48. package/utils/queue-item-transformer.js +24 -0
  49. package/utils/queue-item-transformer.ts +8 -11
  50. package/utils/sanitize-results.js +60 -0
  51. package/utils/schema-generator.js +46 -0
  52. package/utils/state-manager.js +20 -0
  53. package/utils/state-manager.ts +17 -12
  54. package/.nvmrc +0 -1
  55. package/README.FR.md +0 -916
  56. package/agent/index.ts +0 -151
  57. package/agent/workflow/conditions.ts +0 -16
  58. package/agent/workflow/handlers/interpreter.handler.ts +0 -48
  59. package/agent/workflow/handlers/memory.handler.ts +0 -106
  60. package/agent/workflow/handlers/orchestrator.handler.ts +0 -23
  61. package/agent/workflow/handlers/queue.handler.ts +0 -34
  62. package/agent/workflow/handlers/scheduler.handler.ts +0 -61
  63. package/agent/workflow/index.ts +0 -62
  64. package/dist/agent/index.d.ts +0 -38
  65. package/dist/agent/index.js +0 -143
  66. package/dist/agent/tools/get-rss.d.ts +0 -16
  67. package/dist/agent/tools/get-rss.js +0 -62
  68. package/dist/bull.d.ts +0 -1
  69. package/dist/bull.js +0 -9
  70. package/dist/examples/index.d.ts +0 -2
  71. package/dist/examples/index.js +0 -89
  72. package/dist/index.d.ts +0 -7
  73. package/dist/llm/interpreter/context.d.ts +0 -15
  74. package/dist/llm/interpreter/context.js +0 -89
  75. package/dist/llm/interpreter/index.d.ts +0 -21
  76. package/dist/llm/interpreter/index.js +0 -87
  77. package/dist/llm/memory-manager/context.d.ts +0 -2
  78. package/dist/llm/memory-manager/context.js +0 -22
  79. package/dist/llm/memory-manager/index.d.ts +0 -17
  80. package/dist/llm/memory-manager/index.js +0 -107
  81. package/dist/llm/orchestrator/context.d.ts +0 -2
  82. package/dist/llm/orchestrator/context.js +0 -23
  83. package/dist/llm/orchestrator/index.d.ts +0 -44
  84. package/dist/llm/orchestrator/index.js +0 -139
  85. package/dist/llm/orchestrator/types.d.ts +0 -12
  86. package/dist/memory/cache.d.ts +0 -22
  87. package/dist/memory/cache.js +0 -165
  88. package/dist/memory/persistent.d.ts +0 -57
  89. package/dist/memory/persistent.js +0 -189
  90. package/dist/services/queue.d.ts +0 -13
  91. package/dist/services/redis-cache.d.ts +0 -37
  92. package/dist/services/redis-cache.js +0 -93
  93. package/dist/services/scheduler.d.ts +0 -40
  94. package/dist/services/scheduler.js +0 -99
  95. package/dist/services/telegram-monitor.d.ts +0 -0
  96. package/dist/services/telegram-monitor.js +0 -118
  97. package/dist/t.d.ts +0 -46
  98. package/dist/t.js +0 -102
  99. package/dist/test.d.ts +0 -0
  100. package/dist/test.js +0 -438
  101. package/dist/types.d.ts +0 -258
  102. package/dist/types.js +0 -22
  103. package/dist/utils/generate-object.d.ts +0 -12
  104. package/dist/utils/header-builder.d.ts +0 -11
  105. package/dist/utils/inject-actions.d.ts +0 -2
  106. package/dist/utils/queue-item-transformer.d.ts +0 -7
  107. package/dist/utils/sanitize-results.d.ts +0 -17
  108. package/dist/utils/schema-generator.d.ts +0 -16
  109. package/examples/actions/get-rss.ts +0 -71
  110. package/examples/index.ts +0 -98
  111. package/index.html +0 -42
  112. package/llm/dynamic-condition/example.ts +0 -36
  113. package/llm/dynamic-condition/index.ts +0 -108
  114. package/llm/interpreter/context.ts +0 -94
  115. package/llm/interpreter/index.ts +0 -140
  116. package/llm/memory-manager/context.ts +0 -19
  117. package/llm/memory-manager/index.ts +0 -115
  118. package/llm/orchestrator/context.ts +0 -19
  119. package/llm/orchestrator/index.ts +0 -192
  120. package/llm/orchestrator/types.ts +0 -14
  121. package/memory/cache.ts +0 -221
  122. package/memory/persistent.ts +0 -265
  123. package/script.js +0 -167
  124. package/services/cache.ts +0 -298
  125. package/services/telegram-monitor.ts +0 -138
  126. package/t.py +0 -79
  127. package/t.ts +0 -25
  128. package/test/llm/orchestrator.test.ts +0 -47
  129. package/test/llm/synthesizer.test.ts +0 -31
  130. package/types.ts +0 -367
  131. /package/dist/{llm/orchestrator/types.js → interfaces/index.js} +0 -0
package/services/cache.ts DELETED
@@ -1,298 +0,0 @@
1
- import { type CoreMessage } from "ai";
2
- import Redis from "ioredis";
3
- import cron from "node-cron";
4
-
5
- export interface CacheConfig {
6
- host: string;
7
- port: number;
8
- password?: string;
9
- ttl?: number; // Time to live in seconds (default 30 minutes)
10
- cleanupInterval?: string; // Cron expression (default every 30 minutes)
11
- }
12
-
13
- export class RedisCache {
14
- private redis: Redis;
15
- private readonly defaultTTL: number;
16
- private readonly cleanupJob: cron.ScheduledTask;
17
-
18
- constructor(config: CacheConfig) {
19
- this.redis = new Redis({
20
- host: config.host,
21
- port: config.port,
22
- password: config.password,
23
- });
24
-
25
- this.defaultTTL = config.ttl || 1800; // 30 minutes in seconds
26
- // Setup cleanup job (default: every 30 minutes)
27
-
28
- // this.cleanupEverything();
29
-
30
- this.cleanupJob = cron.schedule(
31
- config.cleanupInterval || "*/30 * * * *",
32
- () => this.cleanup()
33
- );
34
- }
35
-
36
- /**
37
- * Store previous actions for a specific request
38
- */
39
- async storePreviousActions(requestId: string, actions: any[]): Promise<void> {
40
- const key = `previous_actions:${requestId}`;
41
- await this.redis.setex(
42
- key,
43
- this.defaultTTL,
44
- JSON.stringify({
45
- timestamp: new Date().toISOString(),
46
- actions,
47
- })
48
- );
49
- }
50
-
51
- /**
52
- * Get previous actions for a specific request
53
- */
54
- async getPreviousActions(requestId: string): Promise<any[]> {
55
- const key = `previous_actions:${requestId}`;
56
- const data = await this.redis.get(key);
57
- if (!data) return [];
58
-
59
- const parsed = JSON.parse(data);
60
- return parsed.actions;
61
- }
62
-
63
- async storeMessage(
64
- role: "user" | "assistant" | "system",
65
- message: string
66
- ): Promise<void> {
67
- const id = crypto.randomUUID();
68
- const key = `recent_messages:${id}`;
69
- const coreMessage: CoreMessage = {
70
- role,
71
- content: message,
72
- };
73
- await this.redis.setex(
74
- key,
75
- this.defaultTTL,
76
- JSON.stringify({ ...coreMessage, timestamp: new Date().toISOString() })
77
- );
78
- console.log("🔍 Message stored successfully", { key, message });
79
- }
80
-
81
- /**
82
- * Store a recent message following CoreMessage structure
83
- */
84
- async storeRecentMessage(
85
- message: string,
86
- metadata?: {
87
- socialResponse?: string;
88
- agentName?: string;
89
- agentResponse?: string;
90
- actions?: any[];
91
- }
92
- ): Promise<void> {
93
- console.log("🔍 Storing recent message:", message);
94
- const id = crypto.randomUUID();
95
- const key = `recent_messages:${id}`;
96
-
97
- // Create CoreMessage structure
98
- const coreMessage: CoreMessage[] = [
99
- {
100
- role: "user",
101
- content: message,
102
- },
103
- ];
104
-
105
- // Add assistant response if available
106
- if (metadata?.socialResponse || metadata?.agentResponse) {
107
- coreMessage.push({
108
- role: "assistant",
109
- content:
110
- metadata.socialResponse || metadata.agentResponse
111
- ? `Agent ${metadata.agentName ? metadata.agentName : "Main"}: ${
112
- metadata.socialResponse || metadata.agentResponse
113
- }`
114
- : "",
115
- });
116
- }
117
-
118
- await this.redis.setex(
119
- key,
120
- this.defaultTTL,
121
- JSON.stringify({
122
- timestamp: new Date().toISOString(),
123
- messages: coreMessage,
124
- actions: metadata?.actions || [],
125
- })
126
- );
127
- console.log("🔍 Recent message stored successfully", {
128
- key,
129
- message,
130
- });
131
- }
132
-
133
- /**
134
- * Get previous actions
135
- */
136
- async getRecentPreviousActions(limit: number = 10): Promise<any[]> {
137
- const keys = await this.redis.keys("previous_actions:*");
138
- if (!keys.length) return [];
139
-
140
- const actions = await Promise.all(
141
- keys.map(async (key) => {
142
- const data = await this.redis.get(key);
143
- return data ? JSON.parse(data) : null;
144
- })
145
- );
146
- return actions.slice(0, limit);
147
- }
148
-
149
- /**
150
- * Get recent messages in CoreMessage format
151
- */
152
- async getRecentMessages(limit: number = 10): Promise<CoreMessage[]> {
153
- const keys = await this.redis.keys("recent_messages:*");
154
- if (!keys.length) return [];
155
-
156
- const messages = await Promise.all(
157
- keys.map(async (key) => {
158
- const data = await this.redis.get(key);
159
- return data ? JSON.parse(data) : null;
160
- })
161
- );
162
-
163
- const formattedMessages = messages
164
- .sort(
165
- (a, b) =>
166
- new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime()
167
- ) // Tri par timestamp
168
- .map((message) => {
169
- return {
170
- role: message.role,
171
- content: message.content,
172
- };
173
- }) // Extraire les messages de chaque entrée
174
- .slice(0, limit); // Limiter le nombre de messages
175
- return formattedMessages;
176
- }
177
- /**
178
- * Cleanup expired keys
179
- */
180
- private async cleanup(): Promise<void> {
181
- console.log("🧹 Starting cache cleanup...");
182
- try {
183
- // Redis automatically removes expired keys
184
- // This is just for logging purposes
185
- const actionKeys = await this.redis.keys("previous_actions:*");
186
- const messageKeys = await this.redis.keys("recent_messages:*");
187
- console.log(
188
- `Cache status: ${actionKeys.length} actions, ${messageKeys.length} messages`
189
- );
190
- } catch (error) {
191
- console.error("❌ Cache cleanup error:", error);
192
- }
193
- }
194
- async cleanupEverything(): Promise<void> {
195
- const keys = await this.redis.keys("*");
196
- console.log("🔍 Cleaning up messages with TTL:", keys);
197
-
198
- for (const key of keys) {
199
- console.log(`🧹 Suppression de la clé expirée ou invalide: ${key}`);
200
- await this.redis.del(key);
201
- }
202
- }
203
-
204
- /**
205
- * Stop the cleanup job and close Redis connection
206
- */
207
- async close(): Promise<void> {
208
- this.cleanupJob.stop();
209
- await this.redis.quit();
210
- }
211
-
212
- /**
213
- * Store a memory with tags and categories
214
- */
215
- async storeMemory(
216
- data: string,
217
- category: string,
218
- tags: string[],
219
- ttl?: number
220
- ): Promise<void> {
221
- const id = crypto.randomUUID();
222
- const key = `memory:${id}`;
223
- const memoryData = {
224
- data,
225
- category,
226
- tags,
227
- timestamp: new Date().toISOString(),
228
- };
229
-
230
- // Enregistrer la mémoire avec TTL
231
- await this.redis.setex(
232
- key,
233
- ttl || this.defaultTTL,
234
- JSON.stringify(memoryData)
235
- );
236
-
237
- // Indexer les tags
238
- for (const tag of tags) {
239
- const tagKey = `tag:${tag}`;
240
- await this.redis.sadd(tagKey, key);
241
- }
242
-
243
- // Indexer les catégories
244
- const categoryKey = `category:${category}`;
245
- await this.redis.sadd(categoryKey, key);
246
- console.log("🔍 Memory stored successfully", { key, memoryData });
247
- }
248
-
249
- /**
250
- * Get memories by a specific tag
251
- */
252
- async getMemoriesByTag(tag: string): Promise<any[]> {
253
- const tagKey = `tag:${tag}`;
254
- const keys = await this.redis.smembers(tagKey);
255
-
256
- const memories = await Promise.all(
257
- keys.map(async (key) => {
258
- const data = await this.redis.get(key);
259
- return data ? JSON.parse(data) : null;
260
- })
261
- );
262
-
263
- return memories.filter(Boolean); // Filtrer les valeurs nulles
264
- }
265
-
266
- /**
267
- * Get memories by a specific category
268
- */
269
- async getMemoriesByCategory(category: string): Promise<any[]> {
270
- const categoryKey = `category:${category}`;
271
- const keys = await this.redis.smembers(categoryKey);
272
-
273
- const memories = await Promise.all(
274
- keys.map(async (key) => {
275
- const data = await this.redis.get(key);
276
- return data ? JSON.parse(data) : null;
277
- })
278
- );
279
-
280
- return memories.filter(Boolean); // Filtrer les valeurs nulles
281
- }
282
-
283
- /**
284
- * Get all available tags
285
- */
286
- async getAllTags(): Promise<string[]> {
287
- const keys = await this.redis.keys("tag:*");
288
- return keys.map((key) => key.replace("tag:", ""));
289
- }
290
-
291
- /**
292
- * Get all available categories
293
- */
294
- async getAllCategories(): Promise<string[]> {
295
- const keys = await this.redis.keys("category:*");
296
- return keys.map((key) => key.replace("category:", ""));
297
- }
298
- }
@@ -1,138 +0,0 @@
1
- // import dotenv from "dotenv";
2
- // import promptSync from "prompt-sync";
3
- // import { TelegramClient } from "telegram";
4
- // import { NewMessage } from "telegram/events";
5
- // import { StringSession } from "telegram/sessions";
6
-
7
- // dotenv.config();
8
-
9
- // const prompt = promptSync({ sigint: true });
10
-
11
- // export interface TokenLaunch {
12
- // tokenAddress: string;
13
- // messageUrl: string;
14
- // timestamp: string;
15
- // }
16
-
17
- // export class TelegramMonitor {
18
- // private client: TelegramClient;
19
- // private botStartTime: Date;
20
-
21
- // constructor() {
22
- // if (!process.env.TELEGRAM_API_ID || !process.env.TELEGRAM_API_HASH) {
23
- // throw new Error("TELEGRAM_API_ID and TELEGRAM_API_HASH must be set");
24
- // }
25
- // this.botStartTime = new Date();
26
-
27
- // const apiId = parseInt(process.env.TELEGRAM_API_ID);
28
- // const apiHash = process.env.TELEGRAM_API_HASH;
29
-
30
- // // Utiliser une session stockée si disponible
31
- // const sessionString = process.env.TELEGRAM_SESSION;
32
- // this.client = new TelegramClient(
33
- // new StringSession(sessionString),
34
- // apiId,
35
- // apiHash,
36
- // {
37
- // connectionRetries: 5,
38
- // }
39
- // );
40
- // }
41
-
42
- // async connect() {
43
- // // Se connecter en tant qu'utilisateur
44
- // await this.client.start({
45
- // phoneNumber: async () => prompt("Numéro de téléphone ? "),
46
- // password: async () => prompt("Mot de passe ? "),
47
- // phoneCode: async () => prompt("Code reçu ? "),
48
- // onError: (err) => console.log(err),
49
- // });
50
-
51
- // // Sauvegarder la session pour une utilisation ultérieure
52
- // console.log("Session string à sauvegarder:", this.client.session.save());
53
- // }
54
-
55
- // async startMonitoring(
56
- // channelUsername: string,
57
- // callback: {
58
- // onNewLaunch: (message: string) => void;
59
- // }
60
- // ) {
61
- // console.log(`Démarrage du monitoring pour ${channelUsername}`);
62
-
63
- // try {
64
- // // S'assurer que le client est connecté
65
- // if (!this.client.connected) {
66
- // console.log("Client non connecté, tentative de connexion...");
67
- // await this.client.connect();
68
- // console.log("Client connecté avec succès");
69
- // }
70
-
71
- // console.log("État de la connexion:", this.client.connected);
72
-
73
- // // Vérifier si le canal existe et est accessible
74
- // try {
75
- // const channel = await this.client.getEntity(channelUsername);
76
- // console.log("Canal trouvé:", channel.id);
77
- // } catch (e) {
78
- // console.error("Erreur lors de l'accès au canal:", e);
79
- // }
80
-
81
- // this.client.addEventHandler(async (event: any) => {
82
- // const message = event.message;
83
- // if (!message) {
84
- // console.log("Pas de message dans l'événement");
85
- // return;
86
- // }
87
-
88
- // if (!message.text) {
89
- // console.log("Message sans texte:", message);
90
- // return;
91
- // }
92
-
93
- // try {
94
- // callback.onNewLaunch(message.text);
95
- // } catch (error) {
96
- // console.error("Erreur lors du traitement du message:", error);
97
- // }
98
- // }, new NewMessage({ chats: [channelUsername] }));
99
-
100
- // console.log("Handler d'événements ajouté avec succès");
101
- // } catch (error) {
102
- // console.error("Erreur lors du démarrage du monitoring:", error);
103
- // }
104
- // }
105
-
106
- // static async generateNewSession() {
107
- // // Supprimer la session existante
108
- // const client = new TelegramClient(
109
- // new StringSession(""),
110
- // parseInt(process.env.TELEGRAM_API_ID || ""),
111
- // process.env.TELEGRAM_API_HASH || "",
112
- // {
113
- // connectionRetries: 5,
114
- // }
115
- // );
116
-
117
- // // Se connecter en tant qu'utilisateur
118
- // await client.start({
119
- // phoneNumber: async () => prompt("Numéro de téléphone ? "),
120
- // password: async () => prompt("Mot de passe ? "),
121
- // phoneCode: async () => prompt("Code reçu ? "),
122
- // onError: (err) => console.log(err),
123
- // });
124
-
125
- // // Sauvegarder la nouvelle session pour une utilisation ultérieure
126
- // console.log(
127
- // "Nouvelle session string à sauvegarder:",
128
- // client.session.save()
129
- // );
130
- // }
131
- // }
132
-
133
- // const telegramMonitor = new TelegramMonitor();
134
- // telegramMonitor.startMonitoring("testcalldegen", {
135
- // onNewLaunch: (message: string) => {
136
- // console.log("Nouveau message:", message);
137
- // },
138
- // });
package/t.py DELETED
@@ -1,79 +0,0 @@
1
- import os
2
- import platform
3
- import subprocess
4
- import urllib.request
5
- import sys
6
-
7
- def download_meilisearch():
8
- """Download the Meilisearch binary for the current OS."""
9
- print("Checking operating system...")
10
- os_name = platform.system().lower()
11
- if os_name == "windows":
12
- binary_url = "https://github.com/meilisearch/meilisearch/releases/latest/download/meilisearch-windows-amd64.exe"
13
- binary_name = "meilisearch.exe"
14
- elif os_name == "darwin": # macOS
15
- binary_url = "https://github.com/meilisearch/meilisearch/releases/latest/download/meilisearch-macos-amd64"
16
- binary_name = "meilisearch"
17
- elif os_name == "linux":
18
- binary_url = "https://github.com/meilisearch/meilisearch/releases/latest/download/meilisearch-linux-amd64"
19
- binary_name = "meilisearch"
20
- else:
21
- print(f"Unsupported operating system: {os_name}")
22
- sys.exit(1)
23
-
24
- # Download the binary
25
- if not os.path.exists(binary_name):
26
- print(f"Downloading Meilisearch binary for {os_name}...")
27
- try:
28
- urllib.request.urlretrieve(binary_url, binary_name)
29
- print("Download complete.")
30
- except Exception as e:
31
- print(f"Failed to download Meilisearch: {e}")
32
- sys.exit(1)
33
-
34
- # Add execute permissions for Linux/macOS
35
- if os_name != "windows":
36
- os.chmod(binary_name, 0o755)
37
- else:
38
- print("Meilisearch binary already exists.")
39
-
40
- return binary_name
41
-
42
-
43
- def create_data_directory():
44
- """Create a directory for Meilisearch data if it doesn't exist."""
45
- data_dir = "./data"
46
- if not os.path.exists(data_dir):
47
- print("Creating data directory...")
48
- os.makedirs(data_dir)
49
- else:
50
- print("Data directory already exists.")
51
- return data_dir
52
-
53
- def launch_meilisearch(binary_name, data_dir):
54
- """Launch the Meilisearch server."""
55
- print("Launching Meilisearch...")
56
- try:
57
- process = subprocess.Popen(
58
- [
59
- f"./{binary_name}" if platform.system().lower() != "windows" else binary_name,
60
- "--db-path",
61
- data_dir,
62
- "--master-key",
63
- "DEFAULT_MASTER_KEY",
64
- ],
65
- stdout=subprocess.PIPE,
66
- stderr=subprocess.PIPE,
67
- )
68
- print("Meilisearch is running! Access it at http://localhost:7700")
69
- for line in iter(process.stdout.readline, b""):
70
- print("Meilisearch Log:", line.decode().strip())
71
- except Exception as e:
72
- print(f"Failed to launch Meilisearch: {e}")
73
- sys.exit(1)
74
-
75
-
76
- if __name__ == "__main__":
77
- binary = download_meilisearch()
78
- data_directory = create_data_directory()
79
- launch_meilisearch(binary, data_directory)
package/t.ts DELETED
@@ -1,25 +0,0 @@
1
- import { deepseek } from "@ai-sdk/deepseek";
2
- import { streamObject } from "ai";
3
- import { configDotenv } from "dotenv";
4
- import { z } from "zod";
5
-
6
- configDotenv();
7
- const model = deepseek("deepseek-chat");
8
-
9
- const main = async () => {
10
- try {
11
- const result = await streamObject({
12
- model,
13
- schema: z.object({
14
- text: z.string(),
15
- reason: z.string(),
16
- }),
17
- prompt: "Tell me why you are so good",
18
- });
19
- } catch (error) {
20
- console.error("🔄 Start handler error:", error);
21
- throw error;
22
- }
23
- };
24
-
25
- main();
@@ -1,47 +0,0 @@
1
- import { expect } from "chai";
2
- import { z } from "zod";
3
- import { Orchestrator } from "../../llm/orchestrator";
4
- import { ActionSchema } from "../../types";
5
-
6
- describe("Orchestrator", () => {
7
- let orchestrator: Orchestrator;
8
-
9
- const mockAction: ActionSchema = {
10
- name: "prepare-transaction",
11
- description: "Prepare a transfer transaction",
12
- parameters: z.object({
13
- walletAddress: z.string(),
14
- amount: z.string(),
15
- networkId: z.string(),
16
- }),
17
- execute: async ({ walletAddress, amount, networkId }) => {
18
- return { walletAddress, amount, networkId };
19
- },
20
- };
21
-
22
- beforeEach(() => {
23
- orchestrator = new Orchestrator([mockAction]);
24
- });
25
-
26
- it("should process a prompt and return just the answer", async function () {
27
- this.timeout(10000);
28
-
29
- const prompt = "Hello how are you?";
30
- const result = await orchestrator.process(prompt);
31
-
32
- expect(result).to.have.property("answer").that.is.a("string");
33
- });
34
-
35
- it("should process a prompt and return valid actions", async function () {
36
- this.timeout(10000);
37
-
38
- const prompt = "Send 0.1 ETH to 0x123...456 on ethereum";
39
- const result = await orchestrator.process(prompt);
40
- console.dir(result, { depth: null });
41
- expect(result).to.have.property("actions").that.is.an("array");
42
- expect(result).to.have.property("answer").that.is.a("string");
43
- expect(result.actions[0])
44
- .to.have.property("parameters")
45
- .that.is.an("object");
46
- });
47
- });
@@ -1,31 +0,0 @@
1
- // import { expect } from "chai";
2
- // import { Summarizer } from "../../llm/synthesizer";
3
-
4
- // describe("Synthesizer", () => {
5
- // let synthesizer: Summarizer;
6
-
7
- // beforeEach(() => {
8
- // synthesizer = new Summarizer();
9
- // });
10
-
11
- // it("should process results and return a summary", async function () {
12
- // this.timeout(10000);
13
-
14
- // const mockResults = JSON.stringify({
15
- // result: [
16
- // {
17
- // name: "prepare-transaction",
18
- // result: {
19
- // to: "0x123...456",
20
- // value: "0.1",
21
- // chain: { id: 1, name: "ethereum" },
22
- // },
23
- // },
24
- // ],
25
- // initialPrompt: "Send 0.1 ETH to 0x123...456 on ethereum",
26
- // });
27
-
28
- // const result = await synthesizer.process(mockResults);
29
- // expect(result).to.have.property("response").that.is.a("string");
30
- // });
31
- // });