medpromptjs 0.2.1 → 0.2.3
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/dist/agent.d.ts +3 -3
- package/dist/chain.d.ts +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/medpromptjs.cjs.development.js +195 -227
- package/dist/medpromptjs.cjs.development.js.map +1 -1
- package/dist/medpromptjs.cjs.production.min.js +1 -1
- package/dist/medpromptjs.cjs.production.min.js.map +1 -1
- package/dist/medpromptjs.esm.js +195 -227
- package/dist/medpromptjs.esm.js.map +1 -1
- package/dist/tool.d.ts +1 -1
- package/package.json +18 -5
- package/src/agent.ts +59 -50
- package/src/chain.ts +61 -47
- package/src/index.ts +1 -1
- package/src/mydi.ts +8 -8
- package/src/tool.ts +46 -37
package/dist/agent.d.ts
CHANGED
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { PromptTemplate } from
|
|
17
|
-
import { LLM } from
|
|
18
|
-
import type { ToolInterface } from
|
|
16
|
+
import { PromptTemplate } from '@langchain/core/prompts';
|
|
17
|
+
import { LLM } from '@langchain/core/language_models/llms';
|
|
18
|
+
import type { ToolInterface } from '@langchain/core/tools';
|
|
19
19
|
export declare class BaseAgent {
|
|
20
20
|
container: any;
|
|
21
21
|
tools: ToolInterface[];
|
package/dist/chain.d.ts
CHANGED
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { PromptTemplate } from
|
|
17
|
-
import { LLM } from
|
|
18
|
-
import type { ToolInterface } from
|
|
16
|
+
import { PromptTemplate } from '@langchain/core/prompts';
|
|
17
|
+
import { LLM } from '@langchain/core/language_models/llms';
|
|
18
|
+
import type { ToolInterface } from '@langchain/core/tools';
|
|
19
19
|
export declare class BaseChain {
|
|
20
20
|
container: any;
|
|
21
21
|
tools: ToolInterface[];
|
package/dist/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ var tools = require('langchain/tools');
|
|
|
24
24
|
*/
|
|
25
25
|
var mydi = function mydi(c, m, b) {
|
|
26
26
|
try {
|
|
27
|
-
return c.resolve(m +
|
|
27
|
+
return c.resolve(m + '_' + b);
|
|
28
28
|
} catch (e) {
|
|
29
29
|
return c.resolve(b);
|
|
30
30
|
}
|
|
@@ -55,11 +55,11 @@ var BaseChain = /*#__PURE__*/function () {
|
|
|
55
55
|
this.llm = void 0;
|
|
56
56
|
this.template = "\n Summarize the following text:\n {input}\n ";
|
|
57
57
|
this.container = container;
|
|
58
|
-
this.name = name ===
|
|
59
|
-
this.description = description ===
|
|
60
|
-
this.tools = this.resolve(
|
|
61
|
-
this.prompt = this.resolve(
|
|
62
|
-
this.llm = this.resolve(
|
|
58
|
+
this.name = name === '' ? this.camelize(this.constructor.name) : name;
|
|
59
|
+
this.description = description === '' ? this.snake_case(this.constructor.name) : description;
|
|
60
|
+
this.tools = this.resolve('tools');
|
|
61
|
+
this.prompt = this.resolve('prompt') !== '' ? this.resolve('prompt') : prompts.PromptTemplate.fromTemplate(this.template);
|
|
62
|
+
this.llm = this.resolve('main-llm');
|
|
63
63
|
}
|
|
64
64
|
var _proto = BaseChain.prototype;
|
|
65
65
|
_proto.resolve = function resolve(name) {
|
|
@@ -72,7 +72,7 @@ var BaseChain = /*#__PURE__*/function () {
|
|
|
72
72
|
};
|
|
73
73
|
_proto.snake_case = function snake_case(str) {
|
|
74
74
|
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
|
|
75
|
-
return index === 0 ? word.toLowerCase() :
|
|
75
|
+
return index === 0 ? word.toLowerCase() : '_' + word.toLowerCase();
|
|
76
76
|
}).replace(/\s+/g, '');
|
|
77
77
|
}
|
|
78
78
|
// https://js.langchain.com/v0.1/docs/expression_language/how_to/routing/
|
|
@@ -115,47 +115,77 @@ function _inheritsLoose(t, o) {
|
|
|
115
115
|
}
|
|
116
116
|
function _regeneratorRuntime() {
|
|
117
117
|
_regeneratorRuntime = function () {
|
|
118
|
-
return
|
|
118
|
+
return r;
|
|
119
119
|
};
|
|
120
120
|
var t,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
n =
|
|
124
|
-
o =
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
configurable: !0,
|
|
136
|
-
writable: !0
|
|
137
|
-
}), t[e];
|
|
121
|
+
r = {},
|
|
122
|
+
e = Object.prototype,
|
|
123
|
+
n = e.hasOwnProperty,
|
|
124
|
+
o = "function" == typeof Symbol ? Symbol : {},
|
|
125
|
+
i = o.iterator || "@@iterator",
|
|
126
|
+
a = o.asyncIterator || "@@asyncIterator",
|
|
127
|
+
u = o.toStringTag || "@@toStringTag";
|
|
128
|
+
function c(t, r, e, n) {
|
|
129
|
+
return Object.defineProperty(t, r, {
|
|
130
|
+
value: e,
|
|
131
|
+
enumerable: !n,
|
|
132
|
+
configurable: !n,
|
|
133
|
+
writable: !n
|
|
134
|
+
});
|
|
138
135
|
}
|
|
139
136
|
try {
|
|
140
|
-
|
|
137
|
+
c({}, "");
|
|
141
138
|
} catch (t) {
|
|
142
|
-
|
|
143
|
-
return t[
|
|
139
|
+
c = function (t, r, e) {
|
|
140
|
+
return t[r] = e;
|
|
144
141
|
};
|
|
145
142
|
}
|
|
146
|
-
function
|
|
143
|
+
function h(r, e, n, o) {
|
|
147
144
|
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
148
|
-
a = Object.create(i.prototype)
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
145
|
+
a = Object.create(i.prototype);
|
|
146
|
+
return c(a, "_invoke", function (r, e, n) {
|
|
147
|
+
var o = 1;
|
|
148
|
+
return function (i, a) {
|
|
149
|
+
if (3 === o) throw Error("Generator is already running");
|
|
150
|
+
if (4 === o) {
|
|
151
|
+
if ("throw" === i) throw a;
|
|
152
|
+
return {
|
|
153
|
+
value: t,
|
|
154
|
+
done: !0
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
for (n.method = i, n.arg = a;;) {
|
|
158
|
+
var u = n.delegate;
|
|
159
|
+
if (u) {
|
|
160
|
+
var c = d(u, n);
|
|
161
|
+
if (c) {
|
|
162
|
+
if (c === f) continue;
|
|
163
|
+
return c;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
167
|
+
if (1 === o) throw o = 4, n.arg;
|
|
168
|
+
n.dispatchException(n.arg);
|
|
169
|
+
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
170
|
+
o = 3;
|
|
171
|
+
var h = s(r, e, n);
|
|
172
|
+
if ("normal" === h.type) {
|
|
173
|
+
if (o = n.done ? 4 : 2, h.arg === f) continue;
|
|
174
|
+
return {
|
|
175
|
+
value: h.arg,
|
|
176
|
+
done: n.done
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
"throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
}(r, n, new Context(o || [])), !0), a;
|
|
153
183
|
}
|
|
154
|
-
function
|
|
184
|
+
function s(t, r, e) {
|
|
155
185
|
try {
|
|
156
186
|
return {
|
|
157
187
|
type: "normal",
|
|
158
|
-
arg: t.call(
|
|
188
|
+
arg: t.call(r, e)
|
|
159
189
|
};
|
|
160
190
|
} catch (t) {
|
|
161
191
|
return {
|
|
@@ -164,255 +194,193 @@ function _regeneratorRuntime() {
|
|
|
164
194
|
};
|
|
165
195
|
}
|
|
166
196
|
}
|
|
167
|
-
|
|
168
|
-
var
|
|
169
|
-
l = "suspendedYield",
|
|
170
|
-
f = "executing",
|
|
171
|
-
s = "completed",
|
|
172
|
-
y = {};
|
|
197
|
+
r.wrap = h;
|
|
198
|
+
var f = {};
|
|
173
199
|
function Generator() {}
|
|
174
200
|
function GeneratorFunction() {}
|
|
175
201
|
function GeneratorFunctionPrototype() {}
|
|
176
|
-
var
|
|
177
|
-
|
|
202
|
+
var l = {};
|
|
203
|
+
c(l, i, function () {
|
|
178
204
|
return this;
|
|
179
205
|
});
|
|
180
|
-
var
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
var
|
|
184
|
-
function
|
|
185
|
-
["next", "throw", "return"].forEach(function (
|
|
186
|
-
|
|
187
|
-
return this._invoke(
|
|
206
|
+
var p = Object.getPrototypeOf,
|
|
207
|
+
y = p && p(p(x([])));
|
|
208
|
+
y && y !== e && n.call(y, i) && (l = y);
|
|
209
|
+
var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l);
|
|
210
|
+
function g(t) {
|
|
211
|
+
["next", "throw", "return"].forEach(function (r) {
|
|
212
|
+
c(t, r, function (t) {
|
|
213
|
+
return this._invoke(r, t);
|
|
188
214
|
});
|
|
189
215
|
});
|
|
190
216
|
}
|
|
191
|
-
function AsyncIterator(t,
|
|
192
|
-
function
|
|
193
|
-
var c =
|
|
217
|
+
function AsyncIterator(t, r) {
|
|
218
|
+
function e(o, i, a, u) {
|
|
219
|
+
var c = s(t[o], t, i);
|
|
194
220
|
if ("throw" !== c.type) {
|
|
195
|
-
var
|
|
196
|
-
|
|
197
|
-
return
|
|
198
|
-
|
|
221
|
+
var h = c.arg,
|
|
222
|
+
f = h.value;
|
|
223
|
+
return f && "object" == typeof f && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) {
|
|
224
|
+
e("next", t, a, u);
|
|
199
225
|
}, function (t) {
|
|
200
|
-
|
|
201
|
-
}) :
|
|
202
|
-
|
|
226
|
+
e("throw", t, a, u);
|
|
227
|
+
}) : r.resolve(f).then(function (t) {
|
|
228
|
+
h.value = t, a(h);
|
|
203
229
|
}, function (t) {
|
|
204
|
-
return
|
|
230
|
+
return e("throw", t, a, u);
|
|
205
231
|
});
|
|
206
232
|
}
|
|
207
|
-
|
|
233
|
+
u(c.arg);
|
|
208
234
|
}
|
|
209
|
-
var
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
function
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
function makeInvokeMethod(e, r, n) {
|
|
222
|
-
var o = h;
|
|
223
|
-
return function (i, a) {
|
|
224
|
-
if (o === f) throw Error("Generator is already running");
|
|
225
|
-
if (o === s) {
|
|
226
|
-
if ("throw" === i) throw a;
|
|
227
|
-
return {
|
|
228
|
-
value: t,
|
|
229
|
-
done: !0
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
for (n.method = i, n.arg = a;;) {
|
|
233
|
-
var c = n.delegate;
|
|
234
|
-
if (c) {
|
|
235
|
-
var u = maybeInvokeDelegate(c, n);
|
|
236
|
-
if (u) {
|
|
237
|
-
if (u === y) continue;
|
|
238
|
-
return u;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
242
|
-
if (o === h) throw o = s, n.arg;
|
|
243
|
-
n.dispatchException(n.arg);
|
|
244
|
-
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
245
|
-
o = f;
|
|
246
|
-
var p = tryCatch(e, r, n);
|
|
247
|
-
if ("normal" === p.type) {
|
|
248
|
-
if (o = n.done ? s : l, p.arg === y) continue;
|
|
249
|
-
return {
|
|
250
|
-
value: p.arg,
|
|
251
|
-
done: n.done
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
235
|
+
var o;
|
|
236
|
+
c(this, "_invoke", function (t, n) {
|
|
237
|
+
function i() {
|
|
238
|
+
return new r(function (r, o) {
|
|
239
|
+
e(t, n, r, o);
|
|
240
|
+
});
|
|
255
241
|
}
|
|
256
|
-
|
|
242
|
+
return o = o ? o.then(i, i) : i();
|
|
243
|
+
}, !0);
|
|
257
244
|
}
|
|
258
|
-
function
|
|
259
|
-
var n =
|
|
260
|
-
o =
|
|
261
|
-
if (o === t) return
|
|
262
|
-
var i =
|
|
263
|
-
if ("throw" === i.type) return
|
|
245
|
+
function d(r, e) {
|
|
246
|
+
var n = e.method,
|
|
247
|
+
o = r.i[n];
|
|
248
|
+
if (o === t) return e.delegate = null, "throw" === n && r.i.return && (e.method = "return", e.arg = t, d(r, e), "throw" === e.method) || "return" !== n && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + n + "' method")), f;
|
|
249
|
+
var i = s(o, r.i, e.arg);
|
|
250
|
+
if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f;
|
|
264
251
|
var a = i.arg;
|
|
265
|
-
return a ? a.done ? (r
|
|
252
|
+
return a ? a.done ? (e[r.r] = a.value, e.next = r.n, "return" !== e.method && (e.method = "next", e.arg = t), e.delegate = null, f) : a : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f);
|
|
266
253
|
}
|
|
267
|
-
function
|
|
268
|
-
|
|
269
|
-
tryLoc: t[0]
|
|
270
|
-
};
|
|
271
|
-
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
254
|
+
function w(t) {
|
|
255
|
+
this.tryEntries.push(t);
|
|
272
256
|
}
|
|
273
|
-
function
|
|
274
|
-
var e =
|
|
275
|
-
e.type = "normal",
|
|
257
|
+
function m(r) {
|
|
258
|
+
var e = r[4] || {};
|
|
259
|
+
e.type = "normal", e.arg = t, r[4] = e;
|
|
276
260
|
}
|
|
277
261
|
function Context(t) {
|
|
278
|
-
this.tryEntries = [
|
|
279
|
-
tryLoc: "root"
|
|
280
|
-
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
262
|
+
this.tryEntries = [[-1]], t.forEach(w, this), this.reset(!0);
|
|
281
263
|
}
|
|
282
|
-
function
|
|
283
|
-
if (
|
|
284
|
-
var
|
|
285
|
-
if (
|
|
286
|
-
if ("function" == typeof
|
|
287
|
-
if (!isNaN(
|
|
264
|
+
function x(r) {
|
|
265
|
+
if (null != r) {
|
|
266
|
+
var e = r[i];
|
|
267
|
+
if (e) return e.call(r);
|
|
268
|
+
if ("function" == typeof r.next) return r;
|
|
269
|
+
if (!isNaN(r.length)) {
|
|
288
270
|
var o = -1,
|
|
289
|
-
|
|
290
|
-
for (; ++o <
|
|
291
|
-
return
|
|
271
|
+
a = function e() {
|
|
272
|
+
for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e;
|
|
273
|
+
return e.value = t, e.done = !0, e;
|
|
292
274
|
};
|
|
293
|
-
return
|
|
275
|
+
return a.next = a;
|
|
294
276
|
}
|
|
295
277
|
}
|
|
296
|
-
throw new TypeError(typeof
|
|
278
|
+
throw new TypeError(typeof r + " is not iterable");
|
|
297
279
|
}
|
|
298
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype,
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
305
|
-
var e = "function" == typeof t && t.constructor;
|
|
306
|
-
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
307
|
-
}, e.mark = function (t) {
|
|
308
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
309
|
-
}, e.awrap = function (t) {
|
|
280
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = c(GeneratorFunctionPrototype, u, "GeneratorFunction"), r.isGeneratorFunction = function (t) {
|
|
281
|
+
var r = "function" == typeof t && t.constructor;
|
|
282
|
+
return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name));
|
|
283
|
+
}, r.mark = function (t) {
|
|
284
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t;
|
|
285
|
+
}, r.awrap = function (t) {
|
|
310
286
|
return {
|
|
311
287
|
__await: t
|
|
312
288
|
};
|
|
313
|
-
},
|
|
289
|
+
}, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () {
|
|
314
290
|
return this;
|
|
315
|
-
}),
|
|
291
|
+
}), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) {
|
|
316
292
|
void 0 === i && (i = Promise);
|
|
317
|
-
var a = new AsyncIterator(
|
|
318
|
-
return
|
|
293
|
+
var a = new AsyncIterator(h(t, e, n, o), i);
|
|
294
|
+
return r.isGeneratorFunction(e) ? a : a.next().then(function (t) {
|
|
319
295
|
return t.done ? t.value : a.next();
|
|
320
296
|
});
|
|
321
|
-
},
|
|
297
|
+
}, g(v), c(v, u, "Generator"), c(v, i, function () {
|
|
322
298
|
return this;
|
|
323
|
-
}),
|
|
299
|
+
}), c(v, "toString", function () {
|
|
324
300
|
return "[object Generator]";
|
|
325
|
-
}),
|
|
326
|
-
var
|
|
327
|
-
|
|
328
|
-
for (var n in
|
|
329
|
-
return
|
|
330
|
-
for (;
|
|
331
|
-
|
|
332
|
-
if (t in e) return next.value = t, next.done = !1, next;
|
|
333
|
-
}
|
|
334
|
-
return next.done = !0, next;
|
|
301
|
+
}), r.keys = function (t) {
|
|
302
|
+
var r = Object(t),
|
|
303
|
+
e = [];
|
|
304
|
+
for (var n in r) e.unshift(n);
|
|
305
|
+
return function t() {
|
|
306
|
+
for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t;
|
|
307
|
+
return t.done = !0, t;
|
|
335
308
|
};
|
|
336
|
-
},
|
|
309
|
+
}, r.values = x, Context.prototype = {
|
|
337
310
|
constructor: Context,
|
|
338
|
-
reset: function (
|
|
339
|
-
if (this.prev =
|
|
311
|
+
reset: function (r) {
|
|
312
|
+
if (this.prev = this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(m), !r) for (var e in this) "t" === e.charAt(0) && n.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = t);
|
|
340
313
|
},
|
|
341
314
|
stop: function () {
|
|
342
315
|
this.done = !0;
|
|
343
|
-
var t = this.tryEntries[0]
|
|
316
|
+
var t = this.tryEntries[0][4];
|
|
344
317
|
if ("throw" === t.type) throw t.arg;
|
|
345
318
|
return this.rval;
|
|
346
319
|
},
|
|
347
|
-
dispatchException: function (
|
|
348
|
-
if (this.done) throw
|
|
349
|
-
var
|
|
350
|
-
function
|
|
351
|
-
|
|
320
|
+
dispatchException: function (r) {
|
|
321
|
+
if (this.done) throw r;
|
|
322
|
+
var e = this;
|
|
323
|
+
function n(t) {
|
|
324
|
+
a.type = "throw", a.arg = r, e.next = t;
|
|
352
325
|
}
|
|
353
|
-
for (var o =
|
|
326
|
+
for (var o = e.tryEntries.length - 1; o >= 0; --o) {
|
|
354
327
|
var i = this.tryEntries[o],
|
|
355
|
-
a = i
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
365
|
-
} else {
|
|
366
|
-
if (!u) throw Error("try statement without catch or finally");
|
|
367
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
368
|
-
}
|
|
328
|
+
a = i[4],
|
|
329
|
+
u = this.prev,
|
|
330
|
+
c = i[1],
|
|
331
|
+
h = i[2];
|
|
332
|
+
if (-1 === i[0]) return n("end"), !1;
|
|
333
|
+
if (!c && !h) throw Error("try statement without catch or finally");
|
|
334
|
+
if (null != i[0] && i[0] <= u) {
|
|
335
|
+
if (u < c) return this.method = "next", this.arg = t, n(c), !0;
|
|
336
|
+
if (u < h) return n(h), !1;
|
|
369
337
|
}
|
|
370
338
|
}
|
|
371
339
|
},
|
|
372
|
-
abrupt: function (t,
|
|
373
|
-
for (var
|
|
374
|
-
var
|
|
375
|
-
if (
|
|
376
|
-
var
|
|
340
|
+
abrupt: function (t, r) {
|
|
341
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
342
|
+
var n = this.tryEntries[e];
|
|
343
|
+
if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) {
|
|
344
|
+
var o = n;
|
|
377
345
|
break;
|
|
378
346
|
}
|
|
379
347
|
}
|
|
380
|
-
|
|
381
|
-
var
|
|
382
|
-
return
|
|
348
|
+
o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null);
|
|
349
|
+
var i = o ? o[4] : {};
|
|
350
|
+
return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i);
|
|
383
351
|
},
|
|
384
|
-
complete: function (t,
|
|
352
|
+
complete: function (t, r) {
|
|
385
353
|
if ("throw" === t.type) throw t.arg;
|
|
386
|
-
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type &&
|
|
354
|
+
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && r && (this.next = r), f;
|
|
387
355
|
},
|
|
388
356
|
finish: function (t) {
|
|
389
|
-
for (var
|
|
390
|
-
var
|
|
391
|
-
if (
|
|
357
|
+
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
358
|
+
var e = this.tryEntries[r];
|
|
359
|
+
if (e[2] === t) return this.complete(e[4], e[3]), m(e), f;
|
|
392
360
|
}
|
|
393
361
|
},
|
|
394
362
|
catch: function (t) {
|
|
395
|
-
for (var
|
|
396
|
-
var
|
|
397
|
-
if (
|
|
398
|
-
var n =
|
|
363
|
+
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
364
|
+
var e = this.tryEntries[r];
|
|
365
|
+
if (e[0] === t) {
|
|
366
|
+
var n = e[4];
|
|
399
367
|
if ("throw" === n.type) {
|
|
400
368
|
var o = n.arg;
|
|
401
|
-
|
|
369
|
+
m(e);
|
|
402
370
|
}
|
|
403
371
|
return o;
|
|
404
372
|
}
|
|
405
373
|
}
|
|
406
374
|
throw Error("illegal catch attempt");
|
|
407
375
|
},
|
|
408
|
-
delegateYield: function (
|
|
376
|
+
delegateYield: function (r, e, n) {
|
|
409
377
|
return this.delegate = {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
}, "next" === this.method && (this.arg = t),
|
|
378
|
+
i: x(r),
|
|
379
|
+
r: e,
|
|
380
|
+
n: n
|
|
381
|
+
}, "next" === this.method && (this.arg = t), f;
|
|
414
382
|
}
|
|
415
|
-
},
|
|
383
|
+
}, r;
|
|
416
384
|
}
|
|
417
385
|
function _setPrototypeOf(t, e) {
|
|
418
386
|
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
@@ -430,9 +398,9 @@ var BaseAgent = /*#__PURE__*/function () {
|
|
|
430
398
|
this.template = "\n ## Question: {question}\n ## Answer: {answer}\n Given the above question and answer, generate a chain of thought explanation for the answer.\n First, start with the model generated chain of thought explanation.\n End the chain of though explanation with:\n Therefore, the answer is {answer}.\n ";
|
|
431
399
|
this.container = container;
|
|
432
400
|
this.name = this.camelize(this.constructor.name);
|
|
433
|
-
this.tools = this.resolve(
|
|
434
|
-
this.prompt = this.resolve(
|
|
435
|
-
this.llm = this.resolve(
|
|
401
|
+
this.tools = this.resolve('tools');
|
|
402
|
+
this.prompt = this.resolve('prompt') !== '' ? this.resolve('prompt') : prompts.PromptTemplate.fromTemplate(this.template);
|
|
403
|
+
this.llm = this.resolve('main-llm');
|
|
436
404
|
}
|
|
437
405
|
var _proto = BaseAgent.prototype;
|
|
438
406
|
_proto.resolve = function resolve(name) {
|
|
@@ -445,11 +413,11 @@ var BaseAgent = /*#__PURE__*/function () {
|
|
|
445
413
|
};
|
|
446
414
|
_proto.snake_case = function snake_case(str) {
|
|
447
415
|
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
|
|
448
|
-
return index === 0 ? word.toLowerCase() :
|
|
416
|
+
return index === 0 ? word.toLowerCase() : '_' + word.toLowerCase();
|
|
449
417
|
}).replace(/\s+/g, '');
|
|
450
418
|
};
|
|
451
419
|
_proto.run = /*#__PURE__*/function () {
|
|
452
|
-
var _run = /*#__PURE__*/_asyncToGenerator(
|
|
420
|
+
var _run = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(input) {
|
|
453
421
|
var agent, agentExecutor;
|
|
454
422
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
455
423
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -466,7 +434,7 @@ var BaseAgent = /*#__PURE__*/function () {
|
|
|
466
434
|
agent: agent,
|
|
467
435
|
tools: this.tools,
|
|
468
436
|
// verbose: true,
|
|
469
|
-
handleParsingErrors:
|
|
437
|
+
handleParsingErrors: 'Please try again, paying close attention to the final answer'
|
|
470
438
|
});
|
|
471
439
|
_context.next = 6;
|
|
472
440
|
return agentExecutor.invoke(input);
|
|
@@ -503,11 +471,11 @@ var BaseTool = /*#__PURE__*/function (_DynamicStructuredToo) {
|
|
|
503
471
|
_this.description = void 0;
|
|
504
472
|
_this.schema = void 0;
|
|
505
473
|
_this.func = /*#__PURE__*/function () {
|
|
506
|
-
var _ref = _asyncToGenerator(
|
|
474
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(args) {
|
|
507
475
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
508
476
|
while (1) switch (_context.prev = _context.next) {
|
|
509
477
|
case 0:
|
|
510
|
-
return _context.abrupt("return",
|
|
478
|
+
return _context.abrupt("return", 'override this');
|
|
511
479
|
case 1:
|
|
512
480
|
case "end":
|
|
513
481
|
return _context.stop();
|
|
@@ -519,8 +487,8 @@ var BaseTool = /*#__PURE__*/function (_DynamicStructuredToo) {
|
|
|
519
487
|
};
|
|
520
488
|
}();
|
|
521
489
|
_this.container = container;
|
|
522
|
-
_this.name = name ===
|
|
523
|
-
_this.description = description ===
|
|
490
|
+
_this.name = name === '' ? _this.camelize(_this.constructor.name) : name;
|
|
491
|
+
_this.description = description === '' ? _this.snake_case(_this.constructor.name) : description;
|
|
524
492
|
_this.schema = schema;
|
|
525
493
|
return _this;
|
|
526
494
|
}
|
|
@@ -536,7 +504,7 @@ var BaseTool = /*#__PURE__*/function (_DynamicStructuredToo) {
|
|
|
536
504
|
};
|
|
537
505
|
_proto.snake_case = function snake_case(str) {
|
|
538
506
|
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
|
|
539
|
-
return index === 0 ? word.toLowerCase() :
|
|
507
|
+
return index === 0 ? word.toLowerCase() : '_' + word.toLowerCase();
|
|
540
508
|
}).replace(/\s+/g, '');
|
|
541
509
|
};
|
|
542
510
|
return BaseTool;
|