@ai.ntellect/core 0.3.3 → 0.4.1
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/.nvmrc +1 -0
- package/README.FR.md +242 -247
- package/README.md +249 -246
- package/agent/index.ts +199 -215
- package/agent/tools/get-rss.ts +64 -0
- package/bull.ts +5 -0
- package/dist/agent/index.d.ts +29 -26
- package/dist/agent/index.js +123 -112
- package/dist/agent/tools/get-rss.d.ts +16 -0
- package/dist/agent/tools/get-rss.js +62 -0
- package/dist/bull.d.ts +1 -0
- package/dist/bull.js +9 -0
- package/dist/examples/index.d.ts +2 -0
- package/dist/examples/index.js +89 -0
- package/dist/llm/interpreter/context.d.ts +5 -22
- package/dist/llm/interpreter/context.js +8 -9
- package/dist/llm/interpreter/index.d.ts +9 -5
- package/dist/llm/interpreter/index.js +55 -48
- package/dist/llm/memory-manager/context.d.ts +2 -0
- package/dist/llm/memory-manager/context.js +22 -0
- package/dist/llm/memory-manager/index.d.ts +17 -0
- package/dist/llm/memory-manager/index.js +107 -0
- package/dist/llm/orchestrator/context.d.ts +2 -10
- package/dist/llm/orchestrator/context.js +19 -14
- package/dist/llm/orchestrator/index.d.ts +36 -21
- package/dist/llm/orchestrator/index.js +122 -88
- package/dist/llm/orchestrator/types.d.ts +12 -0
- package/dist/llm/orchestrator/types.js +2 -0
- package/dist/memory/cache.d.ts +6 -5
- package/dist/memory/cache.js +31 -21
- package/dist/memory/persistent.d.ts +5 -3
- package/dist/memory/persistent.js +89 -73
- package/dist/services/redis-cache.d.ts +37 -0
- package/dist/services/redis-cache.js +93 -0
- package/dist/services/scheduler.d.ts +39 -16
- package/dist/services/scheduler.js +81 -103
- package/dist/services/telegram-monitor.d.ts +0 -15
- package/dist/services/telegram-monitor.js +117 -101
- package/dist/test.js +106 -172
- package/dist/types.d.ts +38 -7
- package/dist/utils/generate-object.d.ts +12 -0
- package/dist/utils/generate-object.js +90 -0
- package/dist/utils/header-builder.d.ts +11 -0
- package/dist/utils/header-builder.js +34 -0
- package/dist/utils/inject-actions.js +2 -2
- package/dist/utils/queue-item-transformer.d.ts +2 -2
- package/dist/utils/schema-generator.d.ts +16 -0
- package/dist/utils/schema-generator.js +46 -0
- package/examples/index.ts +103 -0
- package/llm/interpreter/context.ts +20 -8
- package/llm/interpreter/index.ts +81 -54
- package/llm/memory-manager/context.ts +21 -0
- package/llm/memory-manager/index.ts +163 -0
- package/llm/orchestrator/context.ts +20 -13
- package/llm/orchestrator/index.ts +210 -130
- package/llm/orchestrator/types.ts +14 -0
- package/memory/cache.ts +37 -31
- package/memory/persistent.ts +121 -99
- package/package.json +11 -2
- package/services/redis-cache.ts +128 -0
- package/services/scheduler.ts +102 -141
- package/services/telegram-monitor.ts +138 -138
- package/t.py +79 -0
- package/t.spec +38 -0
- package/types.ts +40 -7
- package/utils/generate-object.ts +105 -0
- package/utils/header-builder.ts +40 -0
- package/utils/inject-actions.ts +4 -6
- package/utils/queue-item-transformer.ts +2 -1
- package/utils/schema-generator.ts +73 -0
- package/agent/handlers/ActionHandler.ts +0 -48
- package/agent/handlers/ConfirmationHandler.ts +0 -37
- package/agent/handlers/EventHandler.ts +0 -35
- package/dist/agent/handlers/ActionHandler.d.ts +0 -8
- package/dist/agent/handlers/ActionHandler.js +0 -36
- package/dist/agent/handlers/ConfirmationHandler.d.ts +0 -7
- package/dist/agent/handlers/ConfirmationHandler.js +0 -31
- package/dist/agent/handlers/EventHandler.d.ts +0 -10
- package/dist/agent/handlers/EventHandler.js +0 -34
- package/dist/llm/evaluator/context.d.ts +0 -10
- package/dist/llm/evaluator/context.js +0 -24
- package/dist/llm/evaluator/index.d.ts +0 -16
- package/dist/llm/evaluator/index.js +0 -150
- package/llm/evaluator/context.ts +0 -21
- package/llm/evaluator/index.ts +0 -193
package/README.md
CHANGED
@@ -1,362 +1,365 @@
|
|
1
1
|
# AI.ntellect Core Framework
|
2
2
|
|
3
|
-
##
|
3
|
+
## Overview
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
This framework is designed to execute complex workflows using advanced orchestration, memory management, and actionable intelligence. It integrates tools, interpreters, and memory systems to:
|
6
|
+
|
7
|
+
- Analyze user inputs in their context.
|
8
|
+
- Execute predefined workflows and dynamic actions.
|
9
|
+
- Efficiently manage short-term and long-term memory.
|
10
|
+
- Enable seamless integration with external APIs and tools.
|
11
|
+
|
12
|
+
---
|
13
|
+
|
14
|
+
## Table of Contents
|
15
|
+
|
16
|
+
1. [Architecture Components](#architecture-components)
|
17
|
+
- [Agent Runtime](#agent-runtime)
|
7
18
|
- [Orchestrator](#orchestrator)
|
8
|
-
- [
|
19
|
+
- [Queue Manager](#queue-manager)
|
9
20
|
- [Interpreter](#interpreter)
|
10
|
-
- [Memory](#memory-
|
11
|
-
|
12
|
-
|
13
|
-
|
21
|
+
- [Memory System](#memory-system)
|
22
|
+
- [Listeners](#listeners)
|
23
|
+
- [Schedulers](#schedulers)
|
24
|
+
2. [Defining and Executing Actions](#defining-and-executing-actions)
|
25
|
+
3. [State Management and Recursion](#state-management-and-recursion)
|
26
|
+
4. [Installation and Configuration](#installation-and-configuration)
|
27
|
+
5. [Usage Example](#usage-example)
|
28
|
+
6. [Work in Progress (WIP)](#work-in-progress-wip)
|
14
29
|
|
15
30
|
---
|
16
31
|
|
17
|
-
##
|
32
|
+
## Architecture Components
|
18
33
|
|
19
|
-
|
34
|
+
### Agent Runtime
|
20
35
|
|
21
|
-
|
36
|
+
The `AgentRuntime` is the main engine coordinating the overall workflow. It connects all components and ensures tasks are executed efficiently.
|
22
37
|
|
23
|
-
|
38
|
+
**Responsibilities:**
|
24
39
|
|
25
|
-
-
|
26
|
-
-
|
27
|
-
|
28
|
-
- Manages conversation context
|
29
|
-
- Coordinates with orchestrator for action execution
|
30
|
-
- Handles response generation
|
31
|
-
- Maintains user state and memory
|
40
|
+
- Build context for the current state using memory systems (RAG and CAG).
|
41
|
+
- Orchestrate actions using the queue manager.
|
42
|
+
- Leverage interpreters to analyze results and generate responses.
|
32
43
|
|
33
|
-
|
44
|
+
#### Context Building
|
34
45
|
|
35
|
-
The
|
46
|
+
The `buildContext` method creates a complete context by:
|
36
47
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
- Uses memory for context and caching
|
42
|
-
- Coordinates with evaluator for result assessment
|
48
|
+
1. Adding tools and user requests.
|
49
|
+
2. Retrieving recent actions via cache memory (CAG).
|
50
|
+
3. Fetching relevant knowledge from persistent memory (RAG).
|
51
|
+
4. Including available interpreters for the request.
|
43
52
|
|
44
|
-
|
53
|
+
#### Workflow Processing
|
45
54
|
|
46
|
-
The
|
55
|
+
The `process` method:
|
47
56
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
- Determines if additional actions are needed
|
52
|
-
- Routes results to appropriate Interpreter
|
53
|
-
- Ensures completion of user requirements
|
54
|
-
- **Interactions**:
|
55
|
-
- Works with orchestrator to manage workflow
|
56
|
-
- Coordinates with Interpreters for specialized processing
|
57
|
-
- Can trigger additional action cycles if needed
|
57
|
+
1. Generates responses based on context using a language model.
|
58
|
+
2. Handles recursive workflows for action execution.
|
59
|
+
3. Selects appropriate interpreters to analyze results.
|
58
60
|
|
59
|
-
|
61
|
+
---
|
60
62
|
|
61
|
-
|
63
|
+
### Orchestrator
|
62
64
|
|
63
|
-
**
|
65
|
+
The **orchestrator** directs workflows by analyzing user inputs and planning actions. It interacts with tools, memory systems, and interpreters to ensure logical execution.
|
64
66
|
|
65
|
-
|
66
|
-
- Domain-adapted response formatting
|
67
|
-
- Specialized data processing based on context
|
67
|
+
**Key Features:**
|
68
68
|
|
69
|
-
|
69
|
+
- Dynamic action selection based on context.
|
70
|
+
- Memory interaction management for RAG and CAG operations.
|
71
|
+
- Multi-step workflow management with iterative refinement.
|
70
72
|
|
71
|
-
|
72
|
-
- Analyzes data according to its specific context
|
73
|
-
- Produces formatted responses following domain rules
|
73
|
+
---
|
74
74
|
|
75
|
-
|
75
|
+
### Queue Manager
|
76
76
|
|
77
|
-
|
77
|
+
The **queue manager** is responsible for organizing and executing actions in the correct order, whether sequential or parallel. It acts as the central mechanism for managing workflows, ensuring each action is properly queued, validated, and executed.
|
78
78
|
|
79
|
-
|
80
|
-
- Format adapted for financial analysis
|
79
|
+
**Main Responsibilities:**
|
81
80
|
|
82
|
-
|
81
|
+
1. **Action Queueing:**
|
83
82
|
|
84
|
-
-
|
85
|
-
-
|
83
|
+
- Actions are added to a queue for execution, individually or in batches.
|
84
|
+
- Includes logging support for debugging and traceability.
|
86
85
|
|
87
|
-
|
88
|
-
- Handles general purpose requests
|
89
|
-
- Flexible formatting based on context
|
86
|
+
2. **Action Processing:**
|
90
87
|
|
91
|
-
|
88
|
+
- Executes actions while maintaining correct order.
|
89
|
+
- Respects dependencies between actions.
|
90
|
+
- Handles errors or confirmations via callbacks.
|
92
91
|
|
93
|
-
|
92
|
+
3. **Confirmation Management:**
|
93
|
+
- Supports prompts for critical actions.
|
94
|
+
- Relies on callbacks to decide whether to proceed with specific actions.
|
94
95
|
|
95
|
-
|
96
|
+
**Example:**
|
96
97
|
|
97
|
-
|
98
|
+
```typescript
|
99
|
+
import { ActionQueueManager } from "@ai-ntellect/core";
|
100
|
+
import { actions, callbacks } from "@ai-ntellect/core/examples";
|
98
101
|
|
99
|
-
|
102
|
+
const queueManager = new ActionQueueManager(actions, callbacks);
|
103
|
+
queueManager.addToQueue([{ name: "fetch-data", parameters: [...] }]);
|
104
|
+
const results = await queueManager.processQueue();
|
105
|
+
console.log("Results:", results);
|
106
|
+
```
|
100
107
|
|
101
|
-
|
108
|
+
---
|
102
109
|
|
103
|
-
|
110
|
+
### Interpreter
|
104
111
|
|
105
|
-
|
106
|
-
# Install Meilisearch
|
107
|
-
curl -L https://install.meilisearch.com | sh
|
112
|
+
The **interpreter** specializes in analyzing results and generating domain-specific insights. Each interpreter is tailored for a specific use case and uses its own character configuration.
|
108
113
|
|
109
|
-
|
110
|
-
./meilisearch --master-key="YOUR_MASTER_KEY"
|
111
|
-
```
|
114
|
+
**Examples:**
|
112
115
|
|
113
|
-
|
116
|
+
1. **MarketInterpreter**: Analyzes financial market data.
|
117
|
+
2. **SecurityInterpreter**: Performs security checks.
|
118
|
+
3. **GeneralInterpreter**: Processes general-purpose requests.
|
114
119
|
|
115
|
-
|
120
|
+
#### Interpretation Workflow
|
116
121
|
|
117
|
-
|
118
|
-
|
119
|
-
|
122
|
+
1. Builds context with the current state, including results and user requests.
|
123
|
+
2. Uses the language model to generate actionable insights.
|
124
|
+
3. Provides detailed responses for the end user.
|
120
125
|
|
121
|
-
|
122
|
-
sudo apt-get install redis-server
|
123
|
-
```
|
126
|
+
---
|
124
127
|
|
125
|
-
|
126
|
-
- Default port: 6379
|
127
|
-
- Configure memory limits
|
128
|
-
- Enable persistence if needed
|
128
|
+
### Memory System
|
129
129
|
|
130
|
-
|
130
|
+
The memory architecture combines short-term and long-term memory to provide contextual processing.
|
131
131
|
|
132
|
-
####
|
132
|
+
#### Memory Types
|
133
133
|
|
134
|
-
1. **
|
134
|
+
1. **Cache Memory (Redis):**
|
135
|
+
- Stores temporary data for quick access.
|
136
|
+
- Examples: Recent actions, session data.
|
137
|
+
2. **Persistent Memory (Meilisearch):**
|
138
|
+
- Stores long-term data such as historical interactions and knowledge.
|
139
|
+
- Supports semantic searches and vector-based retrievals.
|
135
140
|
|
136
|
-
|
137
|
-
- Contains reusable action sequences and workflows
|
138
|
-
- Optimizes performance through caching
|
139
|
-
- Example: "Common token approval + swap sequence"
|
141
|
+
---
|
140
142
|
|
141
|
-
|
142
|
-
- Recent messages and interactions
|
143
|
-
- Temporary context for ongoing conversations
|
144
|
-
- Stored in Redis for quick retrieval
|
145
|
-
- Example: "Last 10 messages in current conversation"
|
143
|
+
### Listeners
|
146
144
|
|
147
|
-
|
145
|
+
**Listeners** connect to external events via WebSocket. They listen for real-time updates and trigger specific actions or callbacks in response to events.
|
148
146
|
|
149
|
-
|
147
|
+
**Key Features:**
|
150
148
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
- Example: "Token X has contract address Y on network Z"
|
149
|
+
- Connect to WebSockets to listen for events.
|
150
|
+
- Manage subscriptions with custom messages.
|
151
|
+
- Trigger callbacks to process received data.
|
155
152
|
|
156
|
-
|
157
|
-
- Historical interactions and experiences
|
158
|
-
- Persistent context across sessions
|
159
|
-
- Searchable through vector similarity
|
160
|
-
- Example: "User X's past successful transactions"
|
153
|
+
**Usage Example:**
|
161
154
|
|
162
|
-
|
155
|
+
```typescript
|
156
|
+
agent.addListener(
|
157
|
+
"listener-id",
|
158
|
+
"wss://example.com/socket",
|
159
|
+
() => JSON.stringify({ action: "subscribe" }),
|
160
|
+
async (data) => {
|
161
|
+
console.log("Received data:", data);
|
162
|
+
}
|
163
|
+
);
|
164
|
+
```
|
165
|
+
|
166
|
+
---
|
163
167
|
|
164
|
-
|
168
|
+
### Schedulers
|
165
169
|
|
166
|
-
|
167
|
-
- **Implementation**:
|
170
|
+
**Schedulers** allow tasks or actions to be scheduled for later execution. They use cron expressions to define scheduling intervals.
|
168
171
|
|
169
|
-
|
170
|
-
- Stores action sequences and their results
|
171
|
-
- Enables quick retrieval of common patterns
|
172
|
+
**Key Features:**
|
172
173
|
|
173
|
-
-
|
174
|
-
|
175
|
-
|
176
|
-
- Optimizes resource usage
|
174
|
+
- Cron-based scheduling.
|
175
|
+
- Support for recurring and non-recurring tasks.
|
176
|
+
- Management and cancellation of scheduled tasks.
|
177
177
|
|
178
|
-
|
178
|
+
**Usage Example:**
|
179
179
|
|
180
|
-
|
180
|
+
```typescript
|
181
|
+
const scheduler = new TaskScheduler(agentRuntime, redisCache);
|
181
182
|
|
182
|
-
|
183
|
+
const taskId = await scheduler.scheduleRequest({
|
184
|
+
originalRequest: "Market analysis",
|
185
|
+
cronExpression: "0 9 * * *", // Every day at 9 AM
|
186
|
+
});
|
183
187
|
|
184
|
-
|
185
|
-
- Dual indexing (global and user-specific)
|
186
|
-
- Combines with traditional text search
|
188
|
+
console.log(`Task scheduled with ID: ${taskId}`);
|
187
189
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
- Relevance-based result ranking
|
190
|
+
// Cancel the task if needed
|
191
|
+
scheduler.cancelScheduledRequest(taskId);
|
192
|
+
```
|
192
193
|
|
193
194
|
---
|
194
195
|
|
195
|
-
##
|
196
|
+
## Defining and Executing Actions
|
196
197
|
|
197
|
-
|
198
|
+
### What is an Action?
|
198
199
|
|
199
|
-
|
200
|
+
Actions are the fundamental tasks executed by the framework. Each action includes:
|
200
201
|
|
201
|
-
|
202
|
+
- A unique name and description.
|
203
|
+
- Input parameters validated using schemas.
|
204
|
+
- Execution logic encapsulated in the `execute` method.
|
205
|
+
|
206
|
+
### Action Example
|
202
207
|
|
203
208
|
```typescript
|
204
|
-
import { networkConfigs } from "@config/network";
|
205
|
-
import { parseEther } from "ethers";
|
206
209
|
import { z } from "zod";
|
210
|
+
import { parseEther } from "ethers";
|
207
211
|
|
208
212
|
export const prepareTransaction = {
|
209
213
|
name: "prepare-transaction",
|
210
|
-
description: "
|
214
|
+
description: "Prepares a token transfer for user approval.",
|
211
215
|
parameters: z.object({
|
212
216
|
walletAddress: z.string(),
|
213
|
-
amount: z.string()
|
214
|
-
networkId: z.string()
|
217
|
+
amount: z.string(),
|
218
|
+
networkId: z.string(),
|
215
219
|
}),
|
216
|
-
execute: async ({
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
amount: string;
|
223
|
-
networkId: string;
|
224
|
-
}) => {
|
225
|
-
try {
|
226
|
-
const networkConfig = networkConfigs[networkId];
|
227
|
-
if (!networkConfig) {
|
228
|
-
throw new Error(`Network ${network} not found`);
|
229
|
-
}
|
230
|
-
|
231
|
-
return {
|
232
|
-
to: walletAddress,
|
233
|
-
value: parseEther(amount).toString(),
|
234
|
-
chain: {
|
235
|
-
id: networkConfig.id,
|
236
|
-
rpc: networkConfig.rpc,
|
237
|
-
},
|
238
|
-
type: "transfer",
|
239
|
-
};
|
240
|
-
} catch (error) {
|
241
|
-
return "Error preparing the transaction";
|
242
|
-
}
|
220
|
+
execute: async ({ walletAddress, amount, networkId }) => {
|
221
|
+
return {
|
222
|
+
to: walletAddress,
|
223
|
+
value: parseEther(amount).toString(),
|
224
|
+
network: networkId,
|
225
|
+
};
|
243
226
|
},
|
244
227
|
};
|
245
228
|
```
|
246
229
|
|
247
|
-
### How to define an action:
|
248
|
-
|
249
|
-
1. **Name**: Unique identifier for the action.
|
250
|
-
2. **Description**: Brief description of what the action does.
|
251
|
-
3. **Parameters**: Parameters required to execute the action, validated by `zod`.
|
252
|
-
4. **Execution**: `execute` function that performs the action.
|
253
|
-
|
254
230
|
---
|
255
231
|
|
256
|
-
##
|
232
|
+
## State Management and Recursion
|
257
233
|
|
258
|
-
The agent
|
234
|
+
The agent manages state and recursive workflows to ensure actions are executed in an orderly manner and to completion, while adhering to a maximum number of iterations to avoid infinite loops.
|
259
235
|
|
260
|
-
|
261
|
-
const memory = new PersistentMemory({
|
262
|
-
host: "http://localhost:7700",
|
263
|
-
apiKey: "YOUR_API_KEY",
|
264
|
-
});
|
236
|
+
### State Management
|
265
237
|
|
266
|
-
|
267
|
-
[
|
268
|
-
getChainsTVL,
|
269
|
-
getRssNews,
|
270
|
-
// other tools...
|
271
|
-
],
|
272
|
-
memory
|
273
|
-
);
|
238
|
+
The state (`State`) includes:
|
274
239
|
|
275
|
-
|
276
|
-
|
277
|
-
orchestrator,
|
278
|
-
persistentMemory: memory,
|
279
|
-
stream: false,
|
280
|
-
maxEvaluatorIteration: 1,
|
281
|
-
});
|
240
|
+
- `currentContext`: The current context of the user request.
|
241
|
+
- `previousActions`: A list of previously executed actions.
|
282
242
|
|
283
|
-
|
284
|
-
const result = await agent.process(prompt, context, {
|
285
|
-
onMessage: (message) => {
|
286
|
-
console.log({ message });
|
287
|
-
},
|
288
|
-
});
|
289
|
-
```
|
243
|
+
When an action is completed, the state is updated to include:
|
290
244
|
|
291
|
-
|
245
|
+
- Results from previous actions.
|
246
|
+
- Remaining context to be processed.
|
292
247
|
|
293
|
-
|
294
|
-
2. Agent analyzes the prompt and context
|
295
|
-
3. Orchestrator executes required tools/actions
|
296
|
-
4. Evaluator assesses results
|
297
|
-
5. Agent generates final response
|
248
|
+
### Controlled Recursion
|
298
249
|
|
299
|
-
|
250
|
+
To prevent infinite loops, the system limits the number of iterations via the `maxIterations` configuration.
|
300
251
|
|
301
|
-
|
252
|
+
**Workflow:**
|
302
253
|
|
303
|
-
|
254
|
+
1. **Initialization:** At each iteration, the agent:
|
304
255
|
|
305
|
-
|
256
|
+
- Executes actions in the queue.
|
257
|
+
- Updates the state with new results.
|
306
258
|
|
307
|
-
**
|
259
|
+
2. **Limit Validation:**
|
308
260
|
|
309
|
-
|
310
|
-
efficiency and quality of results. It also enables better resource management and faster adaptation to changes.
|
261
|
+
- If the number of iterations exceeds `maxIterations`, processing is stopped with a "Max iterations reached" message.
|
311
262
|
|
312
|
-
**
|
263
|
+
3. **Recursion:**
|
264
|
+
- If actions remain to be executed, the agent recursively calls the `process` method with the updated state.
|
313
265
|
|
314
|
-
|
315
|
-
- [ ] Shared context management.
|
316
|
-
- [ ] Conflict resolution protocols.
|
266
|
+
**State and Recursion Example:**
|
317
267
|
|
318
|
-
|
268
|
+
```typescript
|
269
|
+
const updatedNextState: State = {
|
270
|
+
...state,
|
271
|
+
currentContext: state.currentContext,
|
272
|
+
previousActions: [...(state.previousActions || []), ...(results || [])],
|
273
|
+
};
|
274
|
+
|
275
|
+
if (countIterations < this.config.maxIterations) {
|
276
|
+
return this.process(updatedNextState);
|
277
|
+
} else {
|
278
|
+
console.log("Max iterations reached");
|
279
|
+
response.shouldContinue = false;
|
280
|
+
}
|
281
|
+
```
|
319
282
|
|
320
283
|
---
|
321
284
|
|
322
|
-
##
|
285
|
+
## Installation and Configuration
|
323
286
|
|
324
|
-
|
287
|
+
### Install Dependencies
|
325
288
|
|
326
|
-
|
327
|
-
|
328
|
-
|
289
|
+
```bash
|
290
|
+
npm install
|
291
|
+
```
|
292
|
+
|
293
|
+
### Configure External Services
|
329
294
|
|
330
|
-
|
295
|
+
#### Redis (Cache Memory)
|
296
|
+
|
297
|
+
```bash
|
298
|
+
docker run --name redis -d -p 6379:6379 redis
|
299
|
+
```
|
331
300
|
|
332
|
-
|
333
|
-
- [ ] Filtering of relevant functions.
|
334
|
-
- [ ] Generation of hypothetical queries in natural language.
|
335
|
-
- [ ] Conversion of queries into vector embeddings.
|
336
|
-
- [ ] Storing embeddings and associated queries.
|
337
|
-
- [ ] Similarity search based on cosine.
|
338
|
-
- [ ] Ranking results based on relevance.
|
301
|
+
#### Meilisearch (Persistent Memory)
|
339
302
|
|
340
|
-
|
303
|
+
```bash
|
304
|
+
curl -L https://install.meilisearch.com | sh
|
305
|
+
./meilisearch --master-key="YOUR_MASTER_KEY"
|
306
|
+
```
|
341
307
|
|
342
308
|
---
|
343
309
|
|
344
|
-
##
|
310
|
+
## Usage Example
|
311
|
+
|
312
|
+
### Initialize the Agent
|
313
|
+
|
314
|
+
```typescript
|
315
|
+
import { deepseek } from "@ai-ntellect/core";
|
316
|
+
import { Agent } from "@ai-ntellect/core";
|
317
|
+
import { checkHoneypot, fetchMarkPrice } from "@ai-ntellect/core/actions";
|
318
|
+
import {
|
319
|
+
generalInterpreterCharacter,
|
320
|
+
marketInterpreterCharacter,
|
321
|
+
securityInterpreterCharacter,
|
322
|
+
} from "@ai-ntellect/core/interpreter/context";
|
345
323
|
|
346
|
-
|
347
|
-
network.
|
324
|
+
const model = deepseek("deepseek-reasoner");
|
348
325
|
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
326
|
+
const agent = new Agent({
|
327
|
+
orchestrator: {
|
328
|
+
model,
|
329
|
+
tools: [checkHoneypot, fetchMarkPrice],
|
330
|
+
},
|
331
|
+
interpreters: [
|
332
|
+
new Interpreter({
|
333
|
+
name: "security",
|
334
|
+
model,
|
335
|
+
character: securityInterpreterCharacter,
|
336
|
+
}),
|
337
|
+
new Interpreter({
|
338
|
+
name: "market",
|
339
|
+
model,
|
340
|
+
character: marketInterpreterCharacter,
|
341
|
+
}),
|
342
|
+
new Interpreter({
|
343
|
+
name: "general",
|
344
|
+
model,
|
345
|
+
character: generalInterpreterCharacter,
|
346
|
+
}),
|
347
|
+
],
|
348
|
+
memoryManager: {
|
349
|
+
model,
|
350
|
+
},
|
351
|
+
maxIterations: 3,
|
352
|
+
});
|
353
|
+
```
|
353
354
|
|
354
|
-
|
355
|
+
### Process a Request
|
355
356
|
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
357
|
+
```typescript
|
358
|
+
const state = {
|
359
|
+
currentContext: "Analyze XRP/USD market trends",
|
360
|
+
previousActions: [],
|
361
|
+
};
|
360
362
|
|
361
|
-
|
362
|
-
|
363
|
+
const result = await agent.process(state);
|
364
|
+
console.log("Result:", result);
|
365
|
+
```
|