@caretakerai/agent 0.0.19 → 0.0.21-beta.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/LICENSE ADDED
@@ -0,0 +1,73 @@
1
+ ### **CaretakerAI License Agreement**
2
+
3
+ **From Viktor Zhakhalov (zhakhalov@gmail.com)**
4
+
5
+ **Based on Apache License Version 2.0**
6
+
7
+ **Copyright 2024 Viktor Zhakhalov**
8
+
9
+ #### **Terms and Conditions for Use, Reproduction, and Distribution**
10
+
11
+ 1. **Definitions:**
12
+ - "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
13
+ - "Licensor" shall mean Viktor Zhakhalov, the copyright owner that is granting the License.
14
+ - "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
15
+ - "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
16
+ - "Object" form shall mean any compiled or executable form of the Source form, including but not limited to binaries, DLLs, or other machine code.
17
+ - "Work" shall mean the work of authorship, known as CaretakerAI, whether in Source or Object form, made available under the License.
18
+ - "Output Data" shall mean all data, text, information, or data, text, information transformation or other content produced or generated by the Work, including but not limited to:
19
+ - Input data transformed into prompts containing text or other forms of media.
20
+ - Text or other media generated by the Large Language Model (LLM) in response to such prompts.
21
+
22
+ 2. **Grant of Copyright License:**
23
+ - Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
24
+
25
+ 3. **Grant of Patent License:**
26
+ - Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work.
27
+
28
+ 4. **Restrictions:**
29
+ - You may not use the Work or Output Data for any unlawful or unauthorized purpose.
30
+ - You may not use the Work or Output Data for commercial purposes without obtaining a separate business license from Viktor Zhakhalov.
31
+ - For the purposes of this License, "commercial purposes" includes, but is not limited to, using the Work or Output Data in a business, organization, or other entity that generates revenue or income.
32
+
33
+ 5. **Redistribution:**
34
+ - You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
35
+ - You must give any recipients of the Work or Derivative Works a copy of this License; and
36
+ - You must cause any modified files to carry prominent notices stating that You changed the files; and
37
+ - You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work.
38
+
39
+ 6. **Disclaimer of Warranty:**
40
+ - Unless required by applicable law or agreed to in writing, the Work is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
41
+
42
+ 7. **Limitation of Liability:**
43
+ - In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
44
+
45
+ 8. **Accepting Warranty or Additional Liability.**
46
+ - While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License.
47
+
48
+ 9. **Commercial Use:**
49
+ - The Work and Output Data are licensed for non-commercial use only. Any use of the Work or Output Data for commercial purposes requires a separate business license from Viktor Zhakhalov.
50
+ - A business license is required for any use of the Work or Output Data that generates revenue or income, including but not limited to:
51
+ - Using the Work or Output Data in a business, organization, or other entity that generates revenue or income.
52
+ - Selling, licensing, or distributing the Work or Output Data.
53
+ - Using the Work or Output Data to provide a service or product that generates revenue or income.
54
+
55
+ **END OF TERMS AND CONDITIONS**
56
+
57
+ **How to Apply This License to Your Work:**
58
+ To apply the Apache License to your work, include the following boilerplate notice, replaced with your own identifying information:
59
+ ```plaintext
60
+ Copyright 2024 Viktor Zhakhalov
61
+
62
+ Licensed under the Apache License, Version 2.0 (the "License");
63
+ you may not use this file except in compliance with the License.
64
+ You may obtain a copy of the License at
65
+
66
+ http://www.apache.org/licenses/LICENSE-2.0
67
+
68
+ Unless required by applicable law or agreed to in writing, software
69
+ distributed under the License is distributed on an "AS IS" BASIS,
70
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
71
+ See the License for the specific language governing permissions and
72
+ limitations under the License.
73
+ ```
package/dist/agent.d.ts CHANGED
@@ -2,10 +2,10 @@ import { Logger } from 'pino';
2
2
  import { PromptTemplate } from '@langchain/core/prompts';
3
3
  import { BaseLanguageModel } from '@langchain/core/language_models/base';
4
4
  import type { TypeSource, IResolvers } from '@graphql-tools/utils';
5
- import { GraphQLSchema } from 'graphql';
5
+ import { ExecutionResult, GraphQLSchema } from 'graphql';
6
6
  import { Activity } from './activity';
7
7
  import { Optimizer } from './types';
8
- type GraphQLExecutor = (query: string) => Promise<Record<string, unknown>>;
8
+ type GraphQLExecutor = (query: string) => Promise<ExecutionResult>;
9
9
  interface AgentPrams {
10
10
  name: string;
11
11
  description: string;
@@ -26,6 +26,10 @@ interface AgentPrams {
26
26
  stop?: string[];
27
27
  logger?: Logger;
28
28
  }
29
+ export declare class AgentRetryError extends Error {
30
+ errors: Error[];
31
+ constructor(message: string, errors: Error[]);
32
+ }
29
33
  export declare class Agent implements AgentPrams {
30
34
  name: string;
31
35
  description: string;
package/dist/agent.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Agent = void 0;
6
+ exports.Agent = exports.AgentRetryError = void 0;
7
7
  const dedent_1 = __importDefault(require("dedent"));
8
8
  const yaml_1 = require("yaml");
9
9
  const pino_1 = __importDefault(require("pino"));
@@ -13,6 +13,14 @@ const graphql_1 = require("graphql");
13
13
  const constants_1 = require("./constants");
14
14
  const activity_1 = require("./activity");
15
15
  const messages_1 = require("@langchain/core/messages");
16
+ class AgentRetryError extends Error {
17
+ errors;
18
+ constructor(message, errors) {
19
+ super(message);
20
+ this.errors = errors;
21
+ }
22
+ }
23
+ exports.AgentRetryError = AgentRetryError;
16
24
  class Agent {
17
25
  name;
18
26
  description;
@@ -43,9 +51,6 @@ class Agent {
43
51
  {schema}
44
52
  \`\`\`
45
53
 
46
- **Continue the History with your thoughts and actions following format in your response as shown in the example:**
47
- {examples}
48
-
49
54
  {instruction}
50
55
  `),
51
56
  objective: 'You are helpful assistant.',
@@ -54,7 +59,6 @@ class Agent {
54
59
  Always explain your choice in your thoughts.
55
60
  Use only actions listed in the Actions section.
56
61
  Reject any requests that are not related to your objective and cannot be fulfilled within the given list of actions.
57
- Continue history with Thought and Action in response to the Observation.
58
62
  `,
59
63
  maxRetries: 7,
60
64
  isChatModel: false,
@@ -98,36 +102,47 @@ class Agent {
98
102
  }
99
103
  async prompt(params) {
100
104
  let activities = [];
101
- const history = await this.optimizer.optimize(this.history);
102
- const messages = [];
103
- let aiActivities = [];
104
- history.forEach(activity => {
105
- if (activity.kind === activity_1.ActivityKind.Observation) {
106
- aiActivities.length && messages.push(new messages_1.AIMessage(aiActivities.map(a => a.prompt()).join(constants_1.ACTIVITY_SEP)));
107
- aiActivities = [];
108
- messages.push(new messages_1.HumanMessage(activity.prompt()));
105
+ const retryErrors = [];
106
+ for (let i = 0; i < this.maxRetries; ++i) {
107
+ let history = [...this.history];
108
+ if (history.length < this.examples.length) {
109
+ history = [...this.examples, ...history];
109
110
  }
110
- else {
111
- aiActivities.push(activity);
111
+ history = await this.optimizer.optimize(history);
112
+ const messages = [];
113
+ let aiActivities = [];
114
+ history.forEach(activity => {
115
+ if (activity.kind === activity_1.ActivityKind.Observation) {
116
+ aiActivities.length && messages.push(new messages_1.AIMessage(aiActivities.map(a => a.prompt()).join(constants_1.ACTIVITY_SEP)));
117
+ aiActivities = [];
118
+ messages.push(new messages_1.HumanMessage(activity.prompt()));
119
+ }
120
+ else {
121
+ aiActivities.push(activity);
122
+ }
123
+ });
124
+ if (aiActivities.length) {
125
+ messages.push(new messages_1.AIMessage(aiActivities.map(a => a.prompt()).join(constants_1.ACTIVITY_SEP)));
112
126
  }
113
- });
114
- if (aiActivities.length) {
115
- messages.push(new messages_1.AIMessage(aiActivities.map(a => a.prompt()).join(constants_1.ACTIVITY_SEP)));
116
- }
117
- const systemPrompt = await this.template.partial({
118
- objective: this.objective,
119
- schema: this.typeDefs.toString(),
120
- instruction: this.instruction,
121
- examples: async () => this.examples.map(h => h.prompt()).join(constants_1.ACTIVITY_SEP),
122
- });
123
- const { value: systemPromptValue } = await systemPrompt.invoke(params ?? {});
124
- for (let i = 0; i < this.maxRetries; ++i) {
125
- let { content } = await this.llm
127
+ const systemPrompt = await this.template.partial({
128
+ objective: this.objective,
129
+ schema: this.typeDefs.toString(),
130
+ instruction: this.instruction,
131
+ examples: async () => this.examples.map(h => h.prompt()).join(constants_1.ACTIVITY_SEP),
132
+ });
133
+ const { value: systemPromptValue } = await systemPrompt.invoke(params ?? {});
134
+ const res = await this.llm
126
135
  .bind({ stop: [`<${activity_1.ActivityKind.Observation}>`] })
127
136
  .invoke([
128
137
  new messages_1.SystemMessage(systemPromptValue),
129
138
  ...messages
130
139
  ]);
140
+ let { content } = res;
141
+ const { response_metadata } = res;
142
+ if (response_metadata?.finish_reason == 'length') {
143
+ retryErrors.push(new Error('Generation finished due to length reason.'));
144
+ continue;
145
+ }
131
146
  [, content] = content.split(`<${activity_1.ActivityKind.Thought}>`);
132
147
  content = `<${activity_1.ActivityKind.Thought}>` + content;
133
148
  [content] = content.split(`</${activity_1.ActivityKind.Action}>`);
@@ -147,12 +162,14 @@ class Agent {
147
162
  catch (e) {
148
163
  const err = e;
149
164
  this.logger.warn(err.message);
165
+ retryErrors.push(err);
150
166
  this.logger.debug(`Retry ${i + 1} due to malformed output: ${err.message}`);
151
167
  continue;
152
168
  }
153
169
  const activity = activities.at(-1);
154
170
  if (activity.kind === activity_1.ActivityKind.Thought) {
155
171
  this.logger.debug(`Retry ${i + 1} due to missing action`);
172
+ retryErrors.push(new Error('Missing action'));
156
173
  continue;
157
174
  }
158
175
  try {
@@ -164,6 +181,10 @@ class Agent {
164
181
  kind: activity_1.ActivityKind.Observation,
165
182
  input: (0, yaml_1.stringify)(result),
166
183
  }));
184
+ if (result.errors) {
185
+ retryErrors.push(...result.errors);
186
+ continue;
187
+ }
167
188
  return;
168
189
  }
169
190
  catch (e) {
@@ -174,16 +195,30 @@ class Agent {
174
195
  }));
175
196
  this.addActivities(...activities);
176
197
  activities = [];
177
- this.logger.debug(`Retry ${i + 1} due to action error: ${err}`);
198
+ const message = `Retry ${i + 1} due to action error: ${err}`;
199
+ this.logger.debug(message);
200
+ retryErrors.push(err);
178
201
  continue;
179
202
  }
180
203
  }
181
- throw new Error('Max number of retries reached.');
204
+ throw new AgentRetryError('Max number of retries reached.', retryErrors);
182
205
  }
183
206
  async invoke(params) {
184
207
  if (!this.history.length) {
185
208
  throw new Error('History must not be empty.');
186
209
  }
210
+ this.history.slice(0, -1).forEach((activity, index) => {
211
+ const next = this.history[index + 1];
212
+ if (activity.kind === activity_1.ActivityKind.Observation && next.kind !== activity_1.ActivityKind.Thought) {
213
+ throw new Error(`Observation at index ${index} must be followed by Thought`);
214
+ }
215
+ if (activity.kind === activity_1.ActivityKind.Thought && next.kind !== activity_1.ActivityKind.Action) {
216
+ throw new Error(`Thought at index ${index} must be followed by Action`);
217
+ }
218
+ if (activity.kind === activity_1.ActivityKind.Action && next.kind !== activity_1.ActivityKind.Observation) {
219
+ throw new Error(`Action at index ${index} must be followed by Observation`);
220
+ }
221
+ });
187
222
  if (this.history.at(-1)?.kind !== activity_1.ActivityKind.Observation) {
188
223
  throw new Error('Latest experience must be of Observation kind');
189
224
  }
package/dist/agent.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,+BAAiC;AACjC,gDAAoC;AAEpC,qDAA4E;AAG5E,kDAA6D;AAE7D,qCAAiD;AAEjD,2CAA2C;AAC3C,yCAAoD;AAEpD,uDAA+F;AA8C/F,MAAa,KAAK;IAChB,IAAI,CAAU;IACd,WAAW,CAAU;IACrB,GAAG,CAAqB;IACxB,QAAQ,CAAc;IACtB,SAAS,CAAa;IACtB,OAAO,CAAc;IACrB,QAAQ,CAAa;IACrB,SAAS,CAAS;IAClB,WAAW,CAAS;IACpB,aAAa,CAAS;IACtB,UAAU,CAAS;IACnB,WAAW,CAAU;IACrB,MAAM,CAAc;IACpB,SAAS,CAAa;IACtB,MAAM,CAAU;IAChB,QAAQ,CAAkB;IAC1B,QAAQ,CAAmB;IAElB,MAAM,CAAgB;IAE/B,MAAM,CAAC,QAAQ,GAAwB;QACrC,QAAQ,EAAE,wBAAc,CAAC,YAAY,CAAC,IAAA,gBAAM,EAAA;;;;;;;;;;;;;;KAc3C,CAAC;QACF,SAAS,EAAE,4BAA4B;QACvC,WAAW,EAAE,IAAA,gBAAM,EAAA;;;;;;KAMlB;QACD,UAAU,EAAE,CAAC;QACb,WAAW,EAAE,KAAK;QAClB,aAAa,EAAE,MAAM,CAAC,gBAAgB;QACtC,MAAM,EAAE,IAAA,cAAI,GAAE;QACd,QAAQ,EAAE;YACR,IAAI,mBAAQ,CAAC;gBACX,IAAI,EAAE,uBAAY,CAAC,WAAW;gBAC9B,KAAK,EAAE,IAAA,gBAAM,EAAA;;;;SAIZ,CAAC,IAAI,EAAE;aACT,CAAC;YACF,IAAI,mBAAQ,CAAC;gBACX,IAAI,EAAE,uBAAY,CAAC,OAAO;gBAC1B,KAAK,EAAE,mGAAmG;aAC3G,CAAC;YACF,IAAI,mBAAQ,CAAC;gB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,IAAI,KAAK,CAAC,oBAAoB,KAAK,6BAA6B,CAAC,CAAC;aACzE;YAED,IAAI,QAAQ,CAAC,IAAI,KAAK,uBAAY,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,KAAK,uBAAY,CAAC,WAAW,EAAE;gBACnF,MAAM,IAAI,KAAK,CAAC,mBAAmB,KAAK,kCAAkC,CAAC,CAAC;aAC7E;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,uBAAY,CAAC,WAAW,EAAE;YAC1D,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;SAClE;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC,EAAE;YAC3C,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC1B,IAAI,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;SAC/B;QAED,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;;AAtQH,sBAuQC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caretakerai/agent",
3
- "version": "0.0.19",
3
+ "version": "0.0.21-beta.1",
4
4
  "description": "Single framework for building text-agents",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",