@ai.ntellect/core 0.1.93 → 0.1.95

Sign up to get free protection for your applications and to get access to all the features.
package/agent/index.ts CHANGED
@@ -82,7 +82,7 @@ export class Agent {
82
82
  ? this.handleActions(
83
83
  {
84
84
  initialPrompt: prompt,
85
- actions: request.actions as ActionSchema[],
85
+ actions: request.actions,
86
86
  },
87
87
  events
88
88
  )
@@ -95,11 +95,18 @@ export class Agent {
95
95
  actions,
96
96
  }: {
97
97
  initialPrompt: string;
98
- actions: ActionSchema[];
98
+ actions: {
99
+ name: string;
100
+ type: string;
101
+ parameters: {
102
+ name: string;
103
+ value: any;
104
+ }[];
105
+ }[];
99
106
  },
100
107
  events: AgentEvent
101
108
  ): Promise<any> {
102
- const queueItems = this.transformActions(actions);
109
+ const queueItems = this.transformActions(actions as any);
103
110
 
104
111
  const actionsResult = await this.actionHandler.executeActions(
105
112
  queueItems,
@@ -113,11 +120,22 @@ export class Agent {
113
120
  }
114
121
  );
115
122
 
123
+ const isOnChainAction = actions.some(
124
+ (action) => action.type === "on-chain"
125
+ );
126
+
116
127
  this.accumulatedResults = [
117
128
  ...this.accumulatedResults,
118
129
  ...actionsResult.data,
119
130
  ];
120
131
 
132
+ if (isOnChainAction) {
133
+ return {
134
+ data: this.accumulatedResults,
135
+ initialPrompt,
136
+ };
137
+ }
138
+
121
139
  if (this.evaluatorIteration >= this.maxEvaluatorIteration) {
122
140
  return this.handleActionResults({
123
141
  data: this.accumulatedResults,
@@ -151,13 +169,6 @@ export class Agent {
151
169
  );
152
170
  }
153
171
 
154
- if (!this.actionHandler.hasNonPrepareActions(this.accumulatedResults)) {
155
- return {
156
- data: this.accumulatedResults,
157
- initialPrompt,
158
- };
159
- }
160
-
161
172
  return this.handleActionResults({
162
173
  data: this.accumulatedResults,
163
174
  initialPrompt,
@@ -7,7 +7,8 @@ export const orchestratorContext = {
7
7
  "If there is no action to do, you must answer in the 'answer' field.",
8
8
  "If some parameters are not clear or missing, don't add the action, YOU MUST ask the user for them.",
9
9
  "ALWAYS use the same language as user request. (If it's English, use English, if it's French, use French, etc.)",
10
- "For QUESTIONS or ANALYSIS, BEFORE executing ANY actions, you CAN search in memory and internal knowledge base.",
10
+ "For QUESTIONS or ANALYSIS, you CAN search in memory and internal knowledge base.",
11
+ "For ON-CHAIN actions, just use the useful actions.",
11
12
  "NEVER repeat same actions if the user doesn't ask for it.",
12
13
  ],
13
14
  warnings: [],
@@ -124,7 +124,20 @@ export class Orchestrator {
124
124
  return context;
125
125
  }
126
126
 
127
- async process(prompt: string, results: QueueResult[]): Promise<any> {
127
+ async process(
128
+ prompt: string,
129
+ results: QueueResult[]
130
+ ): Promise<{
131
+ actions: {
132
+ name: string;
133
+ type: string;
134
+ parameters: {
135
+ name: string;
136
+ value: any;
137
+ }[];
138
+ }[];
139
+ answer: string;
140
+ }> {
128
141
  const state = this.composeContext({
129
142
  behavior: orchestratorContext.behavior,
130
143
  userRequest: prompt,
@@ -141,6 +154,7 @@ export class Orchestrator {
141
154
  actions: z.array(
142
155
  z.object({
143
156
  name: z.string(),
157
+ type: z.enum(["on-chain", "off-chain", "question", "analysis"]),
144
158
  parameters: z.array(
145
159
  z.object({
146
160
  name: z.string(),
@@ -161,10 +175,13 @@ export class Orchestrator {
161
175
  actions: response.object.actions.map((action) => ({
162
176
  ...action,
163
177
  parameters: Array.isArray(action.parameters)
164
- ? action.parameters
178
+ ? action.parameters.map((param) => ({
179
+ name: param.name,
180
+ value: param.value ?? null,
181
+ }))
165
182
  : Object.entries(action.parameters || {}).map(([name, value]) => ({
166
183
  name,
167
- value,
184
+ value: value ?? null,
168
185
  })),
169
186
  })),
170
187
  };
@@ -173,8 +190,9 @@ export class Orchestrator {
173
190
  console.log("─".repeat(50));
174
191
  console.log(
175
192
  "Actions determined:",
176
- validatedResponse.actions.map((a) => a.name).join(", ") ||
177
- "No actions needed"
193
+ validatedResponse.actions.map((a) => {
194
+ return `${a.name} (${a.type})`;
195
+ })
178
196
  );
179
197
  if (validatedResponse.answer) {
180
198
  console.log("Response:", validatedResponse.answer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai.ntellect/core",
3
- "version": "0.1.93",
3
+ "version": "0.1.95",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {