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/medpromptjs.esm.js
CHANGED
|
@@ -20,7 +20,7 @@ import { DynamicStructuredTool } from 'langchain/tools';
|
|
|
20
20
|
*/
|
|
21
21
|
var mydi = function mydi(c, m, b) {
|
|
22
22
|
try {
|
|
23
|
-
return c.resolve(m +
|
|
23
|
+
return c.resolve(m + '_' + b);
|
|
24
24
|
} catch (e) {
|
|
25
25
|
return c.resolve(b);
|
|
26
26
|
}
|
|
@@ -51,11 +51,11 @@ var BaseChain = /*#__PURE__*/function () {
|
|
|
51
51
|
this.llm = void 0;
|
|
52
52
|
this.template = "\n Summarize the following text:\n {input}\n ";
|
|
53
53
|
this.container = container;
|
|
54
|
-
this.name = name ===
|
|
55
|
-
this.description = description ===
|
|
56
|
-
this.tools = this.resolve(
|
|
57
|
-
this.prompt = this.resolve(
|
|
58
|
-
this.llm = this.resolve(
|
|
54
|
+
this.name = name === '' ? this.camelize(this.constructor.name) : name;
|
|
55
|
+
this.description = description === '' ? this.snake_case(this.constructor.name) : description;
|
|
56
|
+
this.tools = this.resolve('tools');
|
|
57
|
+
this.prompt = this.resolve('prompt') !== '' ? this.resolve('prompt') : PromptTemplate.fromTemplate(this.template);
|
|
58
|
+
this.llm = this.resolve('main-llm');
|
|
59
59
|
}
|
|
60
60
|
var _proto = BaseChain.prototype;
|
|
61
61
|
_proto.resolve = function resolve(name) {
|
|
@@ -68,7 +68,7 @@ var BaseChain = /*#__PURE__*/function () {
|
|
|
68
68
|
};
|
|
69
69
|
_proto.snake_case = function snake_case(str) {
|
|
70
70
|
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
|
|
71
|
-
return index === 0 ? word.toLowerCase() :
|
|
71
|
+
return index === 0 ? word.toLowerCase() : '_' + word.toLowerCase();
|
|
72
72
|
}).replace(/\s+/g, '');
|
|
73
73
|
}
|
|
74
74
|
// https://js.langchain.com/v0.1/docs/expression_language/how_to/routing/
|
|
@@ -111,47 +111,77 @@ function _inheritsLoose(t, o) {
|
|
|
111
111
|
}
|
|
112
112
|
function _regeneratorRuntime() {
|
|
113
113
|
_regeneratorRuntime = function () {
|
|
114
|
-
return
|
|
114
|
+
return r;
|
|
115
115
|
};
|
|
116
116
|
var t,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
n =
|
|
120
|
-
o =
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
configurable: !0,
|
|
132
|
-
writable: !0
|
|
133
|
-
}), t[e];
|
|
117
|
+
r = {},
|
|
118
|
+
e = Object.prototype,
|
|
119
|
+
n = e.hasOwnProperty,
|
|
120
|
+
o = "function" == typeof Symbol ? Symbol : {},
|
|
121
|
+
i = o.iterator || "@@iterator",
|
|
122
|
+
a = o.asyncIterator || "@@asyncIterator",
|
|
123
|
+
u = o.toStringTag || "@@toStringTag";
|
|
124
|
+
function c(t, r, e, n) {
|
|
125
|
+
return Object.defineProperty(t, r, {
|
|
126
|
+
value: e,
|
|
127
|
+
enumerable: !n,
|
|
128
|
+
configurable: !n,
|
|
129
|
+
writable: !n
|
|
130
|
+
});
|
|
134
131
|
}
|
|
135
132
|
try {
|
|
136
|
-
|
|
133
|
+
c({}, "");
|
|
137
134
|
} catch (t) {
|
|
138
|
-
|
|
139
|
-
return t[
|
|
135
|
+
c = function (t, r, e) {
|
|
136
|
+
return t[r] = e;
|
|
140
137
|
};
|
|
141
138
|
}
|
|
142
|
-
function
|
|
139
|
+
function h(r, e, n, o) {
|
|
143
140
|
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
144
|
-
a = Object.create(i.prototype)
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
141
|
+
a = Object.create(i.prototype);
|
|
142
|
+
return c(a, "_invoke", function (r, e, n) {
|
|
143
|
+
var o = 1;
|
|
144
|
+
return function (i, a) {
|
|
145
|
+
if (3 === o) throw Error("Generator is already running");
|
|
146
|
+
if (4 === o) {
|
|
147
|
+
if ("throw" === i) throw a;
|
|
148
|
+
return {
|
|
149
|
+
value: t,
|
|
150
|
+
done: !0
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
for (n.method = i, n.arg = a;;) {
|
|
154
|
+
var u = n.delegate;
|
|
155
|
+
if (u) {
|
|
156
|
+
var c = d(u, n);
|
|
157
|
+
if (c) {
|
|
158
|
+
if (c === f) continue;
|
|
159
|
+
return c;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
163
|
+
if (1 === o) throw o = 4, n.arg;
|
|
164
|
+
n.dispatchException(n.arg);
|
|
165
|
+
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
166
|
+
o = 3;
|
|
167
|
+
var h = s(r, e, n);
|
|
168
|
+
if ("normal" === h.type) {
|
|
169
|
+
if (o = n.done ? 4 : 2, h.arg === f) continue;
|
|
170
|
+
return {
|
|
171
|
+
value: h.arg,
|
|
172
|
+
done: n.done
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
"throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}(r, n, new Context(o || [])), !0), a;
|
|
149
179
|
}
|
|
150
|
-
function
|
|
180
|
+
function s(t, r, e) {
|
|
151
181
|
try {
|
|
152
182
|
return {
|
|
153
183
|
type: "normal",
|
|
154
|
-
arg: t.call(
|
|
184
|
+
arg: t.call(r, e)
|
|
155
185
|
};
|
|
156
186
|
} catch (t) {
|
|
157
187
|
return {
|
|
@@ -160,255 +190,193 @@ function _regeneratorRuntime() {
|
|
|
160
190
|
};
|
|
161
191
|
}
|
|
162
192
|
}
|
|
163
|
-
|
|
164
|
-
var
|
|
165
|
-
l = "suspendedYield",
|
|
166
|
-
f = "executing",
|
|
167
|
-
s = "completed",
|
|
168
|
-
y = {};
|
|
193
|
+
r.wrap = h;
|
|
194
|
+
var f = {};
|
|
169
195
|
function Generator() {}
|
|
170
196
|
function GeneratorFunction() {}
|
|
171
197
|
function GeneratorFunctionPrototype() {}
|
|
172
|
-
var
|
|
173
|
-
|
|
198
|
+
var l = {};
|
|
199
|
+
c(l, i, function () {
|
|
174
200
|
return this;
|
|
175
201
|
});
|
|
176
|
-
var
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
var
|
|
180
|
-
function
|
|
181
|
-
["next", "throw", "return"].forEach(function (
|
|
182
|
-
|
|
183
|
-
return this._invoke(
|
|
202
|
+
var p = Object.getPrototypeOf,
|
|
203
|
+
y = p && p(p(x([])));
|
|
204
|
+
y && y !== e && n.call(y, i) && (l = y);
|
|
205
|
+
var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l);
|
|
206
|
+
function g(t) {
|
|
207
|
+
["next", "throw", "return"].forEach(function (r) {
|
|
208
|
+
c(t, r, function (t) {
|
|
209
|
+
return this._invoke(r, t);
|
|
184
210
|
});
|
|
185
211
|
});
|
|
186
212
|
}
|
|
187
|
-
function AsyncIterator(t,
|
|
188
|
-
function
|
|
189
|
-
var c =
|
|
213
|
+
function AsyncIterator(t, r) {
|
|
214
|
+
function e(o, i, a, u) {
|
|
215
|
+
var c = s(t[o], t, i);
|
|
190
216
|
if ("throw" !== c.type) {
|
|
191
|
-
var
|
|
192
|
-
|
|
193
|
-
return
|
|
194
|
-
|
|
217
|
+
var h = c.arg,
|
|
218
|
+
f = h.value;
|
|
219
|
+
return f && "object" == typeof f && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) {
|
|
220
|
+
e("next", t, a, u);
|
|
195
221
|
}, function (t) {
|
|
196
|
-
|
|
197
|
-
}) :
|
|
198
|
-
|
|
222
|
+
e("throw", t, a, u);
|
|
223
|
+
}) : r.resolve(f).then(function (t) {
|
|
224
|
+
h.value = t, a(h);
|
|
199
225
|
}, function (t) {
|
|
200
|
-
return
|
|
226
|
+
return e("throw", t, a, u);
|
|
201
227
|
});
|
|
202
228
|
}
|
|
203
|
-
|
|
229
|
+
u(c.arg);
|
|
204
230
|
}
|
|
205
|
-
var
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
function
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
function makeInvokeMethod(e, r, n) {
|
|
218
|
-
var o = h;
|
|
219
|
-
return function (i, a) {
|
|
220
|
-
if (o === f) throw Error("Generator is already running");
|
|
221
|
-
if (o === s) {
|
|
222
|
-
if ("throw" === i) throw a;
|
|
223
|
-
return {
|
|
224
|
-
value: t,
|
|
225
|
-
done: !0
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
for (n.method = i, n.arg = a;;) {
|
|
229
|
-
var c = n.delegate;
|
|
230
|
-
if (c) {
|
|
231
|
-
var u = maybeInvokeDelegate(c, n);
|
|
232
|
-
if (u) {
|
|
233
|
-
if (u === y) continue;
|
|
234
|
-
return u;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
238
|
-
if (o === h) throw o = s, n.arg;
|
|
239
|
-
n.dispatchException(n.arg);
|
|
240
|
-
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
241
|
-
o = f;
|
|
242
|
-
var p = tryCatch(e, r, n);
|
|
243
|
-
if ("normal" === p.type) {
|
|
244
|
-
if (o = n.done ? s : l, p.arg === y) continue;
|
|
245
|
-
return {
|
|
246
|
-
value: p.arg,
|
|
247
|
-
done: n.done
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
231
|
+
var o;
|
|
232
|
+
c(this, "_invoke", function (t, n) {
|
|
233
|
+
function i() {
|
|
234
|
+
return new r(function (r, o) {
|
|
235
|
+
e(t, n, r, o);
|
|
236
|
+
});
|
|
251
237
|
}
|
|
252
|
-
|
|
238
|
+
return o = o ? o.then(i, i) : i();
|
|
239
|
+
}, !0);
|
|
253
240
|
}
|
|
254
|
-
function
|
|
255
|
-
var n =
|
|
256
|
-
o =
|
|
257
|
-
if (o === t) return
|
|
258
|
-
var i =
|
|
259
|
-
if ("throw" === i.type) return
|
|
241
|
+
function d(r, e) {
|
|
242
|
+
var n = e.method,
|
|
243
|
+
o = r.i[n];
|
|
244
|
+
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;
|
|
245
|
+
var i = s(o, r.i, e.arg);
|
|
246
|
+
if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f;
|
|
260
247
|
var a = i.arg;
|
|
261
|
-
return a ? a.done ? (r
|
|
248
|
+
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);
|
|
262
249
|
}
|
|
263
|
-
function
|
|
264
|
-
|
|
265
|
-
tryLoc: t[0]
|
|
266
|
-
};
|
|
267
|
-
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
250
|
+
function w(t) {
|
|
251
|
+
this.tryEntries.push(t);
|
|
268
252
|
}
|
|
269
|
-
function
|
|
270
|
-
var e =
|
|
271
|
-
e.type = "normal",
|
|
253
|
+
function m(r) {
|
|
254
|
+
var e = r[4] || {};
|
|
255
|
+
e.type = "normal", e.arg = t, r[4] = e;
|
|
272
256
|
}
|
|
273
257
|
function Context(t) {
|
|
274
|
-
this.tryEntries = [
|
|
275
|
-
tryLoc: "root"
|
|
276
|
-
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
258
|
+
this.tryEntries = [[-1]], t.forEach(w, this), this.reset(!0);
|
|
277
259
|
}
|
|
278
|
-
function
|
|
279
|
-
if (
|
|
280
|
-
var
|
|
281
|
-
if (
|
|
282
|
-
if ("function" == typeof
|
|
283
|
-
if (!isNaN(
|
|
260
|
+
function x(r) {
|
|
261
|
+
if (null != r) {
|
|
262
|
+
var e = r[i];
|
|
263
|
+
if (e) return e.call(r);
|
|
264
|
+
if ("function" == typeof r.next) return r;
|
|
265
|
+
if (!isNaN(r.length)) {
|
|
284
266
|
var o = -1,
|
|
285
|
-
|
|
286
|
-
for (; ++o <
|
|
287
|
-
return
|
|
267
|
+
a = function e() {
|
|
268
|
+
for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e;
|
|
269
|
+
return e.value = t, e.done = !0, e;
|
|
288
270
|
};
|
|
289
|
-
return
|
|
271
|
+
return a.next = a;
|
|
290
272
|
}
|
|
291
273
|
}
|
|
292
|
-
throw new TypeError(typeof
|
|
274
|
+
throw new TypeError(typeof r + " is not iterable");
|
|
293
275
|
}
|
|
294
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype,
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
301
|
-
var e = "function" == typeof t && t.constructor;
|
|
302
|
-
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
303
|
-
}, e.mark = function (t) {
|
|
304
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
305
|
-
}, e.awrap = function (t) {
|
|
276
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = c(GeneratorFunctionPrototype, u, "GeneratorFunction"), r.isGeneratorFunction = function (t) {
|
|
277
|
+
var r = "function" == typeof t && t.constructor;
|
|
278
|
+
return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name));
|
|
279
|
+
}, r.mark = function (t) {
|
|
280
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t;
|
|
281
|
+
}, r.awrap = function (t) {
|
|
306
282
|
return {
|
|
307
283
|
__await: t
|
|
308
284
|
};
|
|
309
|
-
},
|
|
285
|
+
}, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () {
|
|
310
286
|
return this;
|
|
311
|
-
}),
|
|
287
|
+
}), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) {
|
|
312
288
|
void 0 === i && (i = Promise);
|
|
313
|
-
var a = new AsyncIterator(
|
|
314
|
-
return
|
|
289
|
+
var a = new AsyncIterator(h(t, e, n, o), i);
|
|
290
|
+
return r.isGeneratorFunction(e) ? a : a.next().then(function (t) {
|
|
315
291
|
return t.done ? t.value : a.next();
|
|
316
292
|
});
|
|
317
|
-
},
|
|
293
|
+
}, g(v), c(v, u, "Generator"), c(v, i, function () {
|
|
318
294
|
return this;
|
|
319
|
-
}),
|
|
295
|
+
}), c(v, "toString", function () {
|
|
320
296
|
return "[object Generator]";
|
|
321
|
-
}),
|
|
322
|
-
var
|
|
323
|
-
|
|
324
|
-
for (var n in
|
|
325
|
-
return
|
|
326
|
-
for (;
|
|
327
|
-
|
|
328
|
-
if (t in e) return next.value = t, next.done = !1, next;
|
|
329
|
-
}
|
|
330
|
-
return next.done = !0, next;
|
|
297
|
+
}), r.keys = function (t) {
|
|
298
|
+
var r = Object(t),
|
|
299
|
+
e = [];
|
|
300
|
+
for (var n in r) e.unshift(n);
|
|
301
|
+
return function t() {
|
|
302
|
+
for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t;
|
|
303
|
+
return t.done = !0, t;
|
|
331
304
|
};
|
|
332
|
-
},
|
|
305
|
+
}, r.values = x, Context.prototype = {
|
|
333
306
|
constructor: Context,
|
|
334
|
-
reset: function (
|
|
335
|
-
if (this.prev =
|
|
307
|
+
reset: function (r) {
|
|
308
|
+
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);
|
|
336
309
|
},
|
|
337
310
|
stop: function () {
|
|
338
311
|
this.done = !0;
|
|
339
|
-
var t = this.tryEntries[0]
|
|
312
|
+
var t = this.tryEntries[0][4];
|
|
340
313
|
if ("throw" === t.type) throw t.arg;
|
|
341
314
|
return this.rval;
|
|
342
315
|
},
|
|
343
|
-
dispatchException: function (
|
|
344
|
-
if (this.done) throw
|
|
345
|
-
var
|
|
346
|
-
function
|
|
347
|
-
|
|
316
|
+
dispatchException: function (r) {
|
|
317
|
+
if (this.done) throw r;
|
|
318
|
+
var e = this;
|
|
319
|
+
function n(t) {
|
|
320
|
+
a.type = "throw", a.arg = r, e.next = t;
|
|
348
321
|
}
|
|
349
|
-
for (var o =
|
|
322
|
+
for (var o = e.tryEntries.length - 1; o >= 0; --o) {
|
|
350
323
|
var i = this.tryEntries[o],
|
|
351
|
-
a = i
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
361
|
-
} else {
|
|
362
|
-
if (!u) throw Error("try statement without catch or finally");
|
|
363
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
364
|
-
}
|
|
324
|
+
a = i[4],
|
|
325
|
+
u = this.prev,
|
|
326
|
+
c = i[1],
|
|
327
|
+
h = i[2];
|
|
328
|
+
if (-1 === i[0]) return n("end"), !1;
|
|
329
|
+
if (!c && !h) throw Error("try statement without catch or finally");
|
|
330
|
+
if (null != i[0] && i[0] <= u) {
|
|
331
|
+
if (u < c) return this.method = "next", this.arg = t, n(c), !0;
|
|
332
|
+
if (u < h) return n(h), !1;
|
|
365
333
|
}
|
|
366
334
|
}
|
|
367
335
|
},
|
|
368
|
-
abrupt: function (t,
|
|
369
|
-
for (var
|
|
370
|
-
var
|
|
371
|
-
if (
|
|
372
|
-
var
|
|
336
|
+
abrupt: function (t, r) {
|
|
337
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
338
|
+
var n = this.tryEntries[e];
|
|
339
|
+
if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) {
|
|
340
|
+
var o = n;
|
|
373
341
|
break;
|
|
374
342
|
}
|
|
375
343
|
}
|
|
376
|
-
|
|
377
|
-
var
|
|
378
|
-
return
|
|
344
|
+
o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null);
|
|
345
|
+
var i = o ? o[4] : {};
|
|
346
|
+
return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i);
|
|
379
347
|
},
|
|
380
|
-
complete: function (t,
|
|
348
|
+
complete: function (t, r) {
|
|
381
349
|
if ("throw" === t.type) throw t.arg;
|
|
382
|
-
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 &&
|
|
350
|
+
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;
|
|
383
351
|
},
|
|
384
352
|
finish: function (t) {
|
|
385
|
-
for (var
|
|
386
|
-
var
|
|
387
|
-
if (
|
|
353
|
+
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
354
|
+
var e = this.tryEntries[r];
|
|
355
|
+
if (e[2] === t) return this.complete(e[4], e[3]), m(e), f;
|
|
388
356
|
}
|
|
389
357
|
},
|
|
390
358
|
catch: function (t) {
|
|
391
|
-
for (var
|
|
392
|
-
var
|
|
393
|
-
if (
|
|
394
|
-
var n =
|
|
359
|
+
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
360
|
+
var e = this.tryEntries[r];
|
|
361
|
+
if (e[0] === t) {
|
|
362
|
+
var n = e[4];
|
|
395
363
|
if ("throw" === n.type) {
|
|
396
364
|
var o = n.arg;
|
|
397
|
-
|
|
365
|
+
m(e);
|
|
398
366
|
}
|
|
399
367
|
return o;
|
|
400
368
|
}
|
|
401
369
|
}
|
|
402
370
|
throw Error("illegal catch attempt");
|
|
403
371
|
},
|
|
404
|
-
delegateYield: function (
|
|
372
|
+
delegateYield: function (r, e, n) {
|
|
405
373
|
return this.delegate = {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
}, "next" === this.method && (this.arg = t),
|
|
374
|
+
i: x(r),
|
|
375
|
+
r: e,
|
|
376
|
+
n: n
|
|
377
|
+
}, "next" === this.method && (this.arg = t), f;
|
|
410
378
|
}
|
|
411
|
-
},
|
|
379
|
+
}, r;
|
|
412
380
|
}
|
|
413
381
|
function _setPrototypeOf(t, e) {
|
|
414
382
|
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
@@ -426,9 +394,9 @@ var BaseAgent = /*#__PURE__*/function () {
|
|
|
426
394
|
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 ";
|
|
427
395
|
this.container = container;
|
|
428
396
|
this.name = this.camelize(this.constructor.name);
|
|
429
|
-
this.tools = this.resolve(
|
|
430
|
-
this.prompt = this.resolve(
|
|
431
|
-
this.llm = this.resolve(
|
|
397
|
+
this.tools = this.resolve('tools');
|
|
398
|
+
this.prompt = this.resolve('prompt') !== '' ? this.resolve('prompt') : PromptTemplate.fromTemplate(this.template);
|
|
399
|
+
this.llm = this.resolve('main-llm');
|
|
432
400
|
}
|
|
433
401
|
var _proto = BaseAgent.prototype;
|
|
434
402
|
_proto.resolve = function resolve(name) {
|
|
@@ -441,11 +409,11 @@ var BaseAgent = /*#__PURE__*/function () {
|
|
|
441
409
|
};
|
|
442
410
|
_proto.snake_case = function snake_case(str) {
|
|
443
411
|
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
|
|
444
|
-
return index === 0 ? word.toLowerCase() :
|
|
412
|
+
return index === 0 ? word.toLowerCase() : '_' + word.toLowerCase();
|
|
445
413
|
}).replace(/\s+/g, '');
|
|
446
414
|
};
|
|
447
415
|
_proto.run = /*#__PURE__*/function () {
|
|
448
|
-
var _run = /*#__PURE__*/_asyncToGenerator(
|
|
416
|
+
var _run = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(input) {
|
|
449
417
|
var agent, agentExecutor;
|
|
450
418
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
451
419
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -462,7 +430,7 @@ var BaseAgent = /*#__PURE__*/function () {
|
|
|
462
430
|
agent: agent,
|
|
463
431
|
tools: this.tools,
|
|
464
432
|
// verbose: true,
|
|
465
|
-
handleParsingErrors:
|
|
433
|
+
handleParsingErrors: 'Please try again, paying close attention to the final answer'
|
|
466
434
|
});
|
|
467
435
|
_context.next = 6;
|
|
468
436
|
return agentExecutor.invoke(input);
|
|
@@ -499,11 +467,11 @@ var BaseTool = /*#__PURE__*/function (_DynamicStructuredToo) {
|
|
|
499
467
|
_this.description = void 0;
|
|
500
468
|
_this.schema = void 0;
|
|
501
469
|
_this.func = /*#__PURE__*/function () {
|
|
502
|
-
var _ref = _asyncToGenerator(
|
|
470
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(args) {
|
|
503
471
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
504
472
|
while (1) switch (_context.prev = _context.next) {
|
|
505
473
|
case 0:
|
|
506
|
-
return _context.abrupt("return",
|
|
474
|
+
return _context.abrupt("return", 'override this');
|
|
507
475
|
case 1:
|
|
508
476
|
case "end":
|
|
509
477
|
return _context.stop();
|
|
@@ -515,8 +483,8 @@ var BaseTool = /*#__PURE__*/function (_DynamicStructuredToo) {
|
|
|
515
483
|
};
|
|
516
484
|
}();
|
|
517
485
|
_this.container = container;
|
|
518
|
-
_this.name = name ===
|
|
519
|
-
_this.description = description ===
|
|
486
|
+
_this.name = name === '' ? _this.camelize(_this.constructor.name) : name;
|
|
487
|
+
_this.description = description === '' ? _this.snake_case(_this.constructor.name) : description;
|
|
520
488
|
_this.schema = schema;
|
|
521
489
|
return _this;
|
|
522
490
|
}
|
|
@@ -532,7 +500,7 @@ var BaseTool = /*#__PURE__*/function (_DynamicStructuredToo) {
|
|
|
532
500
|
};
|
|
533
501
|
_proto.snake_case = function snake_case(str) {
|
|
534
502
|
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
|
|
535
|
-
return index === 0 ? word.toLowerCase() :
|
|
503
|
+
return index === 0 ? word.toLowerCase() : '_' + word.toLowerCase();
|
|
536
504
|
}).replace(/\s+/g, '');
|
|
537
505
|
};
|
|
538
506
|
return BaseTool;
|