@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.
Files changed (85) hide show
  1. package/.nvmrc +1 -0
  2. package/README.FR.md +242 -247
  3. package/README.md +249 -246
  4. package/agent/index.ts +199 -215
  5. package/agent/tools/get-rss.ts +64 -0
  6. package/bull.ts +5 -0
  7. package/dist/agent/index.d.ts +29 -26
  8. package/dist/agent/index.js +123 -112
  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 -14
  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 -5
  30. package/dist/memory/cache.js +31 -21
  31. package/dist/memory/persistent.d.ts +5 -3
  32. package/dist/memory/persistent.js +89 -73
  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 +39 -16
  36. package/dist/services/scheduler.js +81 -103
  37. package/dist/services/telegram-monitor.d.ts +0 -15
  38. package/dist/services/telegram-monitor.js +117 -101
  39. package/dist/test.js +106 -172
  40. package/dist/types.d.ts +38 -7
  41. package/dist/utils/generate-object.d.ts +12 -0
  42. package/dist/utils/generate-object.js +90 -0
  43. package/dist/utils/header-builder.d.ts +11 -0
  44. package/dist/utils/header-builder.js +34 -0
  45. package/dist/utils/inject-actions.js +2 -2
  46. package/dist/utils/queue-item-transformer.d.ts +2 -2
  47. package/dist/utils/schema-generator.d.ts +16 -0
  48. package/dist/utils/schema-generator.js +46 -0
  49. package/examples/index.ts +103 -0
  50. package/llm/interpreter/context.ts +20 -8
  51. package/llm/interpreter/index.ts +81 -54
  52. package/llm/memory-manager/context.ts +21 -0
  53. package/llm/memory-manager/index.ts +163 -0
  54. package/llm/orchestrator/context.ts +20 -13
  55. package/llm/orchestrator/index.ts +210 -130
  56. package/llm/orchestrator/types.ts +14 -0
  57. package/memory/cache.ts +37 -31
  58. package/memory/persistent.ts +121 -99
  59. package/package.json +11 -2
  60. package/services/redis-cache.ts +128 -0
  61. package/services/scheduler.ts +102 -141
  62. package/services/telegram-monitor.ts +138 -138
  63. package/t.py +79 -0
  64. package/t.spec +38 -0
  65. package/types.ts +40 -7
  66. package/utils/generate-object.ts +105 -0
  67. package/utils/header-builder.ts +40 -0
  68. package/utils/inject-actions.ts +4 -6
  69. package/utils/queue-item-transformer.ts +2 -1
  70. package/utils/schema-generator.ts +73 -0
  71. package/agent/handlers/ActionHandler.ts +0 -48
  72. package/agent/handlers/ConfirmationHandler.ts +0 -37
  73. package/agent/handlers/EventHandler.ts +0 -35
  74. package/dist/agent/handlers/ActionHandler.d.ts +0 -8
  75. package/dist/agent/handlers/ActionHandler.js +0 -36
  76. package/dist/agent/handlers/ConfirmationHandler.d.ts +0 -7
  77. package/dist/agent/handlers/ConfirmationHandler.js +0 -31
  78. package/dist/agent/handlers/EventHandler.d.ts +0 -10
  79. package/dist/agent/handlers/EventHandler.js +0 -34
  80. package/dist/llm/evaluator/context.d.ts +0 -10
  81. package/dist/llm/evaluator/context.js +0 -24
  82. package/dist/llm/evaluator/index.d.ts +0 -16
  83. package/dist/llm/evaluator/index.js +0 -150
  84. package/llm/evaluator/context.ts +0 -21
  85. package/llm/evaluator/index.ts +0 -193
package/README.md CHANGED
@@ -1,362 +1,365 @@
1
1
  # AI.ntellect Core Framework
2
2
 
3
- ## Table of contents
3
+ ## Overview
4
4
 
5
- 1. [Main components](#main-components)
6
- - [Agent](#agent)
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
- - [Evaluator](#evaluator)
19
+ - [Queue Manager](#queue-manager)
9
20
  - [Interpreter](#interpreter)
10
- - [Memory](#memory-architecture)
11
- 2. [Action creation and management](#action-creation-and-management)
12
- 3. [Agent processing](#agent-processing)
13
- 4. [WIP (Work in Progress)](#wip-work-in-progress)
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
- ## 1. Main components
32
+ ## Architecture Components
18
33
 
19
- The system relies on several key components that ensure smooth and efficient processing of user requests through an AI agent architecture.
34
+ ### Agent Runtime
20
35
 
21
- ### Agent
36
+ The `AgentRuntime` is the main engine coordinating the overall workflow. It connects all components and ensures tasks are executed efficiently.
22
37
 
23
- The agent is the core component that processes user requests and manages the entire interaction flow. It coordinates with other components to understand user needs, execute appropriate actions, and generate relevant responses.
38
+ **Responsibilities:**
24
39
 
25
- - **Main role**: Process user requests and coordinate system components
26
- - **Key features**:
27
- - Processes user prompts
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
- ### Orchestrator
44
+ #### Context Building
34
45
 
35
- The orchestrator works under the agent's direction to manage the execution of actions. It analyzes requirements based on the agent's interpretation of user needs and coordinates the execution of appropriate tools.
46
+ The `buildContext` method creates a complete context by:
36
47
 
37
- - **Main role**: Organize and direct the execution of actions
38
- - **Interactions**:
39
- - Manages available tools/actions
40
- - Executes actions based on agent requests
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
- ### Evaluator
53
+ #### Workflow Processing
45
54
 
46
- The evaluator now collaborates with Interpreters to process action results and determine the next steps in the workflow.
55
+ The `process` method:
47
56
 
48
- - **Main role**: Evaluate action results and coordinate with appropriate Interpreters
49
- - **Main functions**:
50
- - Analyzes results from executed actions
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
- ### Interpreter
61
+ ---
60
62
 
61
- The Interpreter is a specialized component responsible for interpreting action results and generating appropriate responses. Each Interpreter is configured with a specific business context and produces responses in a format adapted to its domain of expertise.
63
+ ### Orchestrator
62
64
 
63
- **Key characteristics**:
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
- - Business-specific context configuration
66
- - Domain-adapted response formatting
67
- - Specialized data processing based on context
67
+ **Key Features:**
68
68
 
69
- **Operation flow**:
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
- - Receives action results via the Evaluator
72
- - Analyzes data according to its specific context
73
- - Produces formatted responses following domain rules
73
+ ---
74
74
 
75
- Examples of Interpreter implementations:
75
+ ### Queue Manager
76
76
 
77
- 1. **MarketInterpreter**
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
- - Specialized in market data analysis
80
- - Format adapted for financial analysis
79
+ **Main Responsibilities:**
81
80
 
82
- 2. **SecurityInterpreter**
81
+ 1. **Action Queueing:**
83
82
 
84
- - Dedicated to security verifications
85
- - Optimized format for security reports
83
+ - Actions are added to a queue for execution, individually or in batches.
84
+ - Includes logging support for debugging and traceability.
86
85
 
87
- 3. **GeneralInterpreter**
88
- - Handles general purpose requests
89
- - Flexible formatting based on context
86
+ 2. **Action Processing:**
90
87
 
91
- These examples demonstrate the system's flexibility, which can be extended with additional Interpreter types as needed.
88
+ - Executes actions while maintaining correct order.
89
+ - Respects dependencies between actions.
90
+ - Handles errors or confirmations via callbacks.
92
91
 
93
- [![Sans-titre-2024-11-08-0220.png](https://i.postimg.cc/nryjsx5y/Sans-titre-2024-11-08-0220.png)](https://postimg.cc/rR9FbBqj)
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
- ### Memory
96
+ **Example:**
96
97
 
97
- The system implements a sophisticated memory architecture that combines different storage solutions for various types of memory:
98
+ ```typescript
99
+ import { ActionQueueManager } from "@ai-ntellect/core";
100
+ import { actions, callbacks } from "@ai-ntellect/core/examples";
98
101
 
99
- #### Installation and setup
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
- ##### Meilisearch (Long-term memory)
108
+ ---
102
109
 
103
- Meilisearch can be self-hosted for complete control over the agent's long-term memory:
110
+ ### Interpreter
104
111
 
105
- ```bash
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
- # Launch Meilisearch with a master key
110
- ./meilisearch --master-key="YOUR_MASTER_KEY"
111
- ```
114
+ **Examples:**
112
115
 
113
- ##### Redis (Short-term memory)
116
+ 1. **MarketInterpreter**: Analyzes financial market data.
117
+ 2. **SecurityInterpreter**: Performs security checks.
118
+ 3. **GeneralInterpreter**: Processes general-purpose requests.
114
119
 
115
- Redis handles the short-term memory components:
120
+ #### Interpretation Workflow
116
121
 
117
- ```bash
118
- # Using Docker
119
- docker run --name redis -d -p 6379:6379 redis
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
- # Or install locally
122
- sudo apt-get install redis-server
123
- ```
126
+ ---
124
127
 
125
- 2. **Configuration**:
126
- - Default port: 6379
127
- - Configure memory limits
128
- - Enable persistence if needed
128
+ ### Memory System
129
129
 
130
- #### Memory types
130
+ The memory architecture combines short-term and long-term memory to provide contextual processing.
131
131
 
132
- #### Short-term memory (Redis)
132
+ #### Memory Types
133
133
 
134
- 1. **Procedural Memory**:
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
- - Stored in Redis for fast access
137
- - Contains reusable action sequences and workflows
138
- - Optimizes performance through caching
139
- - Example: "Common token approval + swap sequence"
141
+ ---
140
142
 
141
- 2. **Short-term episodic memory**:
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
- #### Long-term memory (Meilisearch)
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
- 1. **Semantic memory**:
147
+ **Key Features:**
150
148
 
151
- - Permanent storage of facts and knowledge
152
- - Indexed for efficient retrieval
153
- - Stores relationships between concepts
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
- 2. **Long-term episodic Memory**:
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
- ### Cache Augmented Generation (CAG)
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
- CAG optimizes workflow execution through Redis-based caching:
168
+ ### Schedulers
165
169
 
166
- - **Main role**: Cache frequently used procedural patterns
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
- - Uses Redis for high-performance storage
170
- - Stores action sequences and their results
171
- - Enables quick retrieval of common patterns
172
+ **Key Features:**
172
173
 
173
- - **Benefits**:
174
- - Reduces computation overhead
175
- - Speeds up repeated operations
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
- ### Retrieval Augmented Generation (RAG)
178
+ **Usage Example:**
179
179
 
180
- The RAG system enhances long-term memory access through Meilisearch:
180
+ ```typescript
181
+ const scheduler = new TaskScheduler(agentRuntime, redisCache);
181
182
 
182
- - **Implementation**:
183
+ const taskId = await scheduler.scheduleRequest({
184
+ originalRequest: "Market analysis",
185
+ cronExpression: "0 9 * * *", // Every day at 9 AM
186
+ });
183
187
 
184
- - Vector-based search for semantic similarity
185
- - Dual indexing (global and user-specific)
186
- - Combines with traditional text search
188
+ console.log(`Task scheduled with ID: ${taskId}`);
187
189
 
188
- - **Features**:
189
- - Semantic and episodic memory retrieval
190
- - Context-aware search capabilities
191
- - Relevance-based result ranking
190
+ // Cancel the task if needed
191
+ scheduler.cancelScheduledRequest(taskId);
192
+ ```
192
193
 
193
194
  ---
194
195
 
195
- ## 2. Action creation and management
196
+ ## Defining and Executing Actions
196
197
 
197
- Actions are specific tasks to be performed within a workflow. They can involve interactions with APIs, blockchain transactions, or any other necessary operations.
198
+ ### What is an Action?
198
199
 
199
- Each action is defined as an object containing a name, description, parameters, and an execution function.
200
+ Actions are the fundamental tasks executed by the framework. Each action includes:
200
201
 
201
- ### Example of an action
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: "Prepare a transfer for the user to sign.",
214
+ description: "Prepares a token transfer for user approval.",
211
215
  parameters: z.object({
212
216
  walletAddress: z.string(),
213
- amount: z.string().describe("Amount to send"),
214
- networkId: z.string().describe("Target network (e.g., ethereum, arbitrum)"),
217
+ amount: z.string(),
218
+ networkId: z.string(),
215
219
  }),
216
- execute: async ({
217
- walletAddress,
218
- amount,
219
- network,
220
- }: {
221
- walletAddress: string;
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
- ## 3. Agent processing
232
+ ## State Management and Recursion
257
233
 
258
- The agent handles the entire process of understanding user requests and coordinating responses. Here's an example of how to use 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
- ```typescript
261
- const memory = new PersistentMemory({
262
- host: "http://localhost:7700",
263
- apiKey: "YOUR_API_KEY",
264
- });
236
+ ### State Management
265
237
 
266
- const orchestrator = new Orchestrator(
267
- [
268
- getChainsTVL,
269
- getRssNews,
270
- // other tools...
271
- ],
272
- memory
273
- );
238
+ The state (`State`) includes:
274
239
 
275
- const agent = new Agent({
276
- user: { id: "user_id" },
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
- // Process a user request
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
- ### Agent process flow:
245
+ - Results from previous actions.
246
+ - Remaining context to be processed.
292
247
 
293
- 1. User sends a prompt
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
- ## 4. WIP (Work in Progress)
250
+ To prevent infinite loops, the system limits the number of iterations via the `maxIterations` configuration.
300
251
 
301
- Here are the elements currently in development or improvement:
252
+ **Workflow:**
302
253
 
303
- ---
254
+ 1. **Initialization:** At each iteration, the agent:
304
255
 
305
- ## Multi-agent collaboration
256
+ - Executes actions in the queue.
257
+ - Updates the state with new results.
306
258
 
307
- **Objective**: Enable multiple agents to collaborate on complex tasks with specialization and coordination.
259
+ 2. **Limit Validation:**
308
260
 
309
- **Interest**: Collaboration between agents allows breaking down complex tasks into specialized subtasks, enhancing the
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
- **Steps to implement**:
263
+ 3. **Recursion:**
264
+ - If actions remain to be executed, the agent recursively calls the `process` method with the updated state.
313
265
 
314
- - [ ] Task delegation framework.
315
- - [ ] Shared context management.
316
- - [ ] Conflict resolution protocols.
266
+ **State and Recursion Example:**
317
267
 
318
- **Status**: Research phase, architectural planning in progress.
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
- ## Complex on-chain interactions management
285
+ ## Installation and Configuration
323
286
 
324
- **Objective**: Create a model for recognizing on-chain interactions and creating workflows for complex interactions.
287
+ ### Install Dependencies
325
288
 
326
- **Interest**: This feature allows the agent to understand and interact with smart contracts more intuitively,
327
- facilitating the execution of complex actions on the blockchain. It improves accessibility and efficiency in
328
- interacting with smart contracts.
289
+ ```bash
290
+ npm install
291
+ ```
292
+
293
+ ### Configure External Services
329
294
 
330
- **Steps to implement**:
295
+ #### Redis (Cache Memory)
296
+
297
+ ```bash
298
+ docker run --name redis -d -p 6379:6379 redis
299
+ ```
331
300
 
332
- - [ ] Extraction and processing of relevant contract ABIs.
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
- **Status**: Ongoing study to determine the best approach and technologies to use.
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
- ## Lit Protocol implementation
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
- **Objective**: Add the ability to execute Lit actions, enabling decentralized and secure calculations on the Lit
347
- network.
324
+ const model = deepseek("deepseek-reasoner");
348
325
 
349
- **Interest**: Integrating the Lit Protocol allows executing Lit actions in a decentralized manner, using cryptographic
350
- keys to validate operations. These actions can be used to run JavaScript scripts in a decentralized environment,
351
- offering transparency as all interactions are recorded on the blockchain. The main benefit lies in automation and
352
- security while preserving user privacy, which enhances trust in on-chain interactions.
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
- **Steps to Implement**:
355
+ ### Process a Request
355
356
 
356
- - [x] Study Lit Protocol documentation, especially the section on Lit actions and their implementation.
357
- - [ ] Integrate the protocol into the existing architecture to allow execution of Lit actions.
358
- - [ ] Develop modules for executing Lit actions, including signature management and secure script execution.
359
- - [ ] Test the integration, security, and transparency of Lit actions to ensure they function properly.
357
+ ```typescript
358
+ const state = {
359
+ currentContext: "Analyze XRP/USD market trends",
360
+ previousActions: [],
361
+ };
360
362
 
361
- **Status**: Under study to determine feasibility and technical implications, particularly regarding integrating
362
- decentralization into the existing system.
363
+ const result = await agent.process(state);
364
+ console.log("Result:", result);
365
+ ```