@digipair/skill-ollama 0.41.4 → 0.43.2
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/index.cjs.js +447 -103
- package/index.esm.js +447 -103
- package/package.json +1 -1
package/index.cjs.js
CHANGED
@@ -89,7 +89,7 @@ function _array_like_to_array$G(arr, len) {
|
|
89
89
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
90
90
|
return arr2;
|
91
91
|
}
|
92
|
-
function _array_with_holes$
|
92
|
+
function _array_with_holes$m(arr) {
|
93
93
|
if (Array.isArray(arr)) return arr;
|
94
94
|
}
|
95
95
|
function _array_without_holes$y(arr) {
|
@@ -111,7 +111,7 @@ function _define_property$L(obj, key, value) {
|
|
111
111
|
function _iterable_to_array$y(iter) {
|
112
112
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
113
113
|
}
|
114
|
-
function _iterable_to_array_limit$
|
114
|
+
function _iterable_to_array_limit$m(arr, i) {
|
115
115
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
116
116
|
if (_i == null) return;
|
117
117
|
var _arr = [];
|
@@ -135,7 +135,7 @@ function _iterable_to_array_limit$n(arr, i) {
|
|
135
135
|
}
|
136
136
|
return _arr;
|
137
137
|
}
|
138
|
-
function _non_iterable_rest$
|
138
|
+
function _non_iterable_rest$m() {
|
139
139
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
140
140
|
}
|
141
141
|
function _non_iterable_spread$y() {
|
@@ -180,8 +180,8 @@ function _object_spread_props$v(target, source) {
|
|
180
180
|
}
|
181
181
|
return target;
|
182
182
|
}
|
183
|
-
function _sliced_to_array$
|
184
|
-
return _array_with_holes$
|
183
|
+
function _sliced_to_array$m(arr, i) {
|
184
|
+
return _array_with_holes$m(arr) || _iterable_to_array_limit$m(arr, i) || _unsupported_iterable_to_array$G(arr, i) || _non_iterable_rest$m();
|
185
185
|
}
|
186
186
|
function _to_consumable_array$y(arr) {
|
187
187
|
return _array_without_holes$y(arr) || _iterable_to_array$y(arr) || _unsupported_iterable_to_array$G(arr) || _non_iterable_spread$y();
|
@@ -204,7 +204,7 @@ var getRefs = function(options) {
|
|
204
204
|
currentPath: currentPath,
|
205
205
|
propertyPath: undefined,
|
206
206
|
seen: new Map(Object.entries(_options.definitions).map(function(param) {
|
207
|
-
var _param = _sliced_to_array$
|
207
|
+
var _param = _sliced_to_array$m(param, 2), name = _param[0], def = _param[1];
|
208
208
|
return [
|
209
209
|
def._def,
|
210
210
|
{
|
@@ -289,7 +289,7 @@ function _array_like_to_array$F(arr, len) {
|
|
289
289
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
290
290
|
return arr2;
|
291
291
|
}
|
292
|
-
function _array_with_holes$
|
292
|
+
function _array_with_holes$l(arr) {
|
293
293
|
if (Array.isArray(arr)) return arr;
|
294
294
|
}
|
295
295
|
function _array_without_holes$x(arr) {
|
@@ -411,7 +411,7 @@ function _is_native_function$6(fn) {
|
|
411
411
|
function _iterable_to_array$x(iter) {
|
412
412
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
413
413
|
}
|
414
|
-
function _iterable_to_array_limit$
|
414
|
+
function _iterable_to_array_limit$l(arr, i) {
|
415
415
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
416
416
|
if (_i == null) return;
|
417
417
|
var _arr = [];
|
@@ -435,7 +435,7 @@ function _iterable_to_array_limit$m(arr, i) {
|
|
435
435
|
}
|
436
436
|
return _arr;
|
437
437
|
}
|
438
|
-
function _non_iterable_rest$
|
438
|
+
function _non_iterable_rest$l() {
|
439
439
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
440
440
|
}
|
441
441
|
function _non_iterable_spread$x() {
|
@@ -493,8 +493,8 @@ function _set_prototype_of$u(o, p) {
|
|
493
493
|
};
|
494
494
|
return _set_prototype_of$u(o, p);
|
495
495
|
}
|
496
|
-
function _sliced_to_array$
|
497
|
-
return _array_with_holes$
|
496
|
+
function _sliced_to_array$l(arr, i) {
|
497
|
+
return _array_with_holes$l(arr) || _iterable_to_array_limit$l(arr, i) || _unsupported_iterable_to_array$F(arr, i) || _non_iterable_rest$l();
|
498
498
|
}
|
499
499
|
function _to_consumable_array$x(arr) {
|
500
500
|
return _array_without_holes$x(arr) || _iterable_to_array$x(arr) || _unsupported_iterable_to_array$F(arr) || _non_iterable_spread$x();
|
@@ -1953,7 +1953,7 @@ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-
|
|
1953
1953
|
// /^[a-z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-z0-9-]+(?:\.[a-z0-9\-]+)*$/i;
|
1954
1954
|
// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
|
1955
1955
|
var _emojiRegex = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
1956
|
-
var emojiRegex;
|
1956
|
+
var emojiRegex$1;
|
1957
1957
|
// faster, simpler, safer
|
1958
1958
|
var ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
1959
1959
|
var ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
|
@@ -2090,10 +2090,10 @@ var ZodString = /*#__PURE__*/ function(ZodType) {
|
|
2090
2090
|
status.dirty();
|
2091
2091
|
}
|
2092
2092
|
} else if (check.kind === "emoji") {
|
2093
|
-
if (!emojiRegex) {
|
2094
|
-
emojiRegex = new RegExp(_emojiRegex, "u");
|
2093
|
+
if (!emojiRegex$1) {
|
2094
|
+
emojiRegex$1 = new RegExp(_emojiRegex, "u");
|
2095
2095
|
}
|
2096
|
-
if (!emojiRegex.test(input.data)) {
|
2096
|
+
if (!emojiRegex$1.test(input.data)) {
|
2097
2097
|
ctx1 = this._getOrReturnCtx(input, ctx1);
|
2098
2098
|
addIssueToContext(ctx1, {
|
2099
2099
|
validation: "emoji",
|
@@ -5042,7 +5042,7 @@ var ZodIntersection = /*#__PURE__*/ function(ZodType) {
|
|
5042
5042
|
parent: ctx
|
5043
5043
|
})
|
5044
5044
|
]).then(function(param) {
|
5045
|
-
var _param = _sliced_to_array$
|
5045
|
+
var _param = _sliced_to_array$l(param, 2), left = _param[0], right = _param[1];
|
5046
5046
|
return handleParsed(left, right);
|
5047
5047
|
});
|
5048
5048
|
} else {
|
@@ -5264,7 +5264,7 @@ var ZodMap = /*#__PURE__*/ function(ZodType) {
|
|
5264
5264
|
var keyType = this._def.keyType;
|
5265
5265
|
var valueType = this._def.valueType;
|
5266
5266
|
var pairs = _to_consumable_array$x(ctx.data.entries()).map(function(param, index) {
|
5267
|
-
var _param = _sliced_to_array$
|
5267
|
+
var _param = _sliced_to_array$l(param, 2), key = _param[0], value = _param[1];
|
5268
5268
|
return {
|
5269
5269
|
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [
|
5270
5270
|
index,
|
@@ -6998,11 +6998,11 @@ function _unsupported_iterable_to_array$E(o, minLen) {
|
|
6998
6998
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$E(o, minLen);
|
6999
6999
|
}
|
7000
7000
|
function parseArrayDef(def, refs) {
|
7001
|
-
var _def_type__def,
|
7001
|
+
var _def_type, _def_type__def, _def_type1;
|
7002
7002
|
var res = {
|
7003
7003
|
type: "array"
|
7004
7004
|
};
|
7005
|
-
if (((_def_type = def.type) === null || _def_type === void 0 ? void 0 : (_def_type__def =
|
7005
|
+
if (((_def_type = def.type) === null || _def_type === void 0 ? void 0 : _def_type._def) && ((_def_type1 = def.type) === null || _def_type1 === void 0 ? void 0 : (_def_type__def = _def_type1._def) === null || _def_type__def === void 0 ? void 0 : _def_type__def.typeName) !== ZodFirstPartyTypeKind.ZodAny) {
|
7006
7006
|
res.items = parseDef(def.type._def, _object_spread_props$s(_object_spread$H({}, refs), {
|
7007
7007
|
currentPath: _to_consumable_array$w(refs.currentPath).concat([
|
7008
7008
|
"items"
|
@@ -7295,9 +7295,9 @@ function _object_spread_props$q(target, source) {
|
|
7295
7295
|
}
|
7296
7296
|
return target;
|
7297
7297
|
}
|
7298
|
-
function _object_without_properties$
|
7298
|
+
function _object_without_properties$7(source, excluded) {
|
7299
7299
|
if (source == null) return {};
|
7300
|
-
var target = _object_without_properties_loose$
|
7300
|
+
var target = _object_without_properties_loose$7(source, excluded);
|
7301
7301
|
var key, i;
|
7302
7302
|
if (Object.getOwnPropertySymbols) {
|
7303
7303
|
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
@@ -7310,7 +7310,7 @@ function _object_without_properties$6(source, excluded) {
|
|
7310
7310
|
}
|
7311
7311
|
return target;
|
7312
7312
|
}
|
7313
|
-
function _object_without_properties_loose$
|
7313
|
+
function _object_without_properties_loose$7(source, excluded) {
|
7314
7314
|
if (source == null) return {};
|
7315
7315
|
var target = {};
|
7316
7316
|
var sourceKeys = Object.keys(source);
|
@@ -7371,7 +7371,7 @@ function parseIntersectionDef(def, refs) {
|
|
7371
7371
|
} else {
|
7372
7372
|
var nestedSchema = schema;
|
7373
7373
|
if ("additionalProperties" in schema && schema.additionalProperties === false) {
|
7374
|
-
schema.additionalProperties; var rest = _object_without_properties$
|
7374
|
+
schema.additionalProperties; var rest = _object_without_properties$7(schema, [
|
7375
7375
|
"additionalProperties"
|
7376
7376
|
]);
|
7377
7377
|
nestedSchema = rest;
|
@@ -7440,6 +7440,7 @@ function _object_spread$E(target) {
|
|
7440
7440
|
}
|
7441
7441
|
return target;
|
7442
7442
|
}
|
7443
|
+
var emojiRegex;
|
7443
7444
|
/**
|
7444
7445
|
* Generated from the regular expressions found here as of 2024-05-22:
|
7445
7446
|
* https://github.com/colinhacks/zod/blob/master/src/types.ts.
|
@@ -7456,7 +7457,20 @@ function _object_spread$E(target) {
|
|
7456
7457
|
*/ email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
7457
7458
|
/**
|
7458
7459
|
* Constructed a valid Unicode RegExp
|
7459
|
-
|
7460
|
+
*
|
7461
|
+
* Lazily instantiate since this type of regex isn't supported
|
7462
|
+
* in all envs (e.g. React Native).
|
7463
|
+
*
|
7464
|
+
* See:
|
7465
|
+
* https://github.com/colinhacks/zod/issues/2433
|
7466
|
+
* Fix in Zod:
|
7467
|
+
* https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
|
7468
|
+
*/ emoji: function() {
|
7469
|
+
if (emojiRegex === undefined) {
|
7470
|
+
emojiRegex = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
|
7471
|
+
}
|
7472
|
+
return emojiRegex;
|
7473
|
+
},
|
7460
7474
|
/**
|
7461
7475
|
* Unused
|
7462
7476
|
*/ uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
|
@@ -7591,7 +7605,7 @@ function parseStringDef(def, refs) {
|
|
7591
7605
|
case "trim":
|
7592
7606
|
break;
|
7593
7607
|
default:
|
7594
|
-
(function(_) {})(check);
|
7608
|
+
/* c8 ignore next */ (function(_) {})(check);
|
7595
7609
|
}
|
7596
7610
|
}
|
7597
7611
|
} catch (err) {
|
@@ -7687,7 +7701,8 @@ var addPattern = function(schema, regex, message, refs) {
|
|
7687
7701
|
}
|
7688
7702
|
};
|
7689
7703
|
// Mutate z.string.regex() in a best attempt to accommodate for regex flags when applyRegexFlags is true
|
7690
|
-
var processRegExp = function(
|
7704
|
+
var processRegExp = function(regexOrFunction, refs) {
|
7705
|
+
var regex = typeof regexOrFunction === "function" ? regexOrFunction() : regexOrFunction;
|
7691
7706
|
if (!refs.applyRegexFlags || !regex.flags) return regex.source;
|
7692
7707
|
// Currently handled flags
|
7693
7708
|
var flags = {
|
@@ -7764,9 +7779,6 @@ function _array_like_to_array$C(arr, len) {
|
|
7764
7779
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
7765
7780
|
return arr2;
|
7766
7781
|
}
|
7767
|
-
function _array_with_holes$l(arr) {
|
7768
|
-
if (Array.isArray(arr)) return arr;
|
7769
|
-
}
|
7770
7782
|
function _array_without_holes$u(arr) {
|
7771
7783
|
if (Array.isArray(arr)) return _array_like_to_array$C(arr);
|
7772
7784
|
}
|
@@ -7786,33 +7798,6 @@ function _define_property$E(obj, key, value) {
|
|
7786
7798
|
function _iterable_to_array$u(iter) {
|
7787
7799
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
7788
7800
|
}
|
7789
|
-
function _iterable_to_array_limit$l(arr, i) {
|
7790
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
7791
|
-
if (_i == null) return;
|
7792
|
-
var _arr = [];
|
7793
|
-
var _n = true;
|
7794
|
-
var _d = false;
|
7795
|
-
var _s, _e;
|
7796
|
-
try {
|
7797
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
7798
|
-
_arr.push(_s.value);
|
7799
|
-
if (i && _arr.length === i) break;
|
7800
|
-
}
|
7801
|
-
} catch (err) {
|
7802
|
-
_d = true;
|
7803
|
-
_e = err;
|
7804
|
-
} finally{
|
7805
|
-
try {
|
7806
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
7807
|
-
} finally{
|
7808
|
-
if (_d) throw _e;
|
7809
|
-
}
|
7810
|
-
}
|
7811
|
-
return _arr;
|
7812
|
-
}
|
7813
|
-
function _non_iterable_rest$l() {
|
7814
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
7815
|
-
}
|
7816
7801
|
function _non_iterable_spread$u() {
|
7817
7802
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
7818
7803
|
}
|
@@ -7855,8 +7840,32 @@ function _object_spread_props$p(target, source) {
|
|
7855
7840
|
}
|
7856
7841
|
return target;
|
7857
7842
|
}
|
7858
|
-
function
|
7859
|
-
|
7843
|
+
function _object_without_properties$6(source, excluded) {
|
7844
|
+
if (source == null) return {};
|
7845
|
+
var target = _object_without_properties_loose$6(source, excluded);
|
7846
|
+
var key, i;
|
7847
|
+
if (Object.getOwnPropertySymbols) {
|
7848
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
7849
|
+
for(i = 0; i < sourceSymbolKeys.length; i++){
|
7850
|
+
key = sourceSymbolKeys[i];
|
7851
|
+
if (excluded.indexOf(key) >= 0) continue;
|
7852
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
7853
|
+
target[key] = source[key];
|
7854
|
+
}
|
7855
|
+
}
|
7856
|
+
return target;
|
7857
|
+
}
|
7858
|
+
function _object_without_properties_loose$6(source, excluded) {
|
7859
|
+
if (source == null) return {};
|
7860
|
+
var target = {};
|
7861
|
+
var sourceKeys = Object.keys(source);
|
7862
|
+
var key, i;
|
7863
|
+
for(i = 0; i < sourceKeys.length; i++){
|
7864
|
+
key = sourceKeys[i];
|
7865
|
+
if (excluded.indexOf(key) >= 0) continue;
|
7866
|
+
target[key] = source[key];
|
7867
|
+
}
|
7868
|
+
return target;
|
7860
7869
|
}
|
7861
7870
|
function _to_consumable_array$u(arr) {
|
7862
7871
|
return _array_without_holes$u(arr) || _iterable_to_array$u(arr) || _unsupported_iterable_to_array$C(arr) || _non_iterable_spread$u();
|
@@ -7870,7 +7879,7 @@ function _unsupported_iterable_to_array$C(o, minLen) {
|
|
7870
7879
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$C(o, minLen);
|
7871
7880
|
}
|
7872
7881
|
function parseRecordDef(def, refs) {
|
7873
|
-
var _def_keyType, _def_keyType1, _def_keyType__def_checks, _def_keyType2;
|
7882
|
+
var _def_keyType, _def_keyType1, _def_keyType__def_checks, _def_keyType2, _def_keyType3, _def_keyType__def_type__def_checks;
|
7874
7883
|
if (refs.target === "openApi3" && ((_def_keyType = def.keyType) === null || _def_keyType === void 0 ? void 0 : _def_keyType._def.typeName) === ZodFirstPartyTypeKind.ZodEnum) {
|
7875
7884
|
return {
|
7876
7885
|
type: "object",
|
@@ -7900,10 +7909,9 @@ function parseRecordDef(def, refs) {
|
|
7900
7909
|
return schema;
|
7901
7910
|
}
|
7902
7911
|
if (((_def_keyType1 = def.keyType) === null || _def_keyType1 === void 0 ? void 0 : _def_keyType1._def.typeName) === ZodFirstPartyTypeKind.ZodString && ((_def_keyType__def_checks = def.keyType._def.checks) === null || _def_keyType__def_checks === void 0 ? void 0 : _def_keyType__def_checks.length)) {
|
7903
|
-
var
|
7904
|
-
|
7905
|
-
|
7906
|
-
}, {});
|
7912
|
+
var _parseStringDef = parseStringDef(def.keyType._def, refs); _parseStringDef.type; var keyType = _object_without_properties$6(_parseStringDef, [
|
7913
|
+
"type"
|
7914
|
+
]);
|
7907
7915
|
return _object_spread_props$p(_object_spread$D({}, schema), {
|
7908
7916
|
propertyNames: keyType
|
7909
7917
|
});
|
@@ -7913,6 +7921,13 @@ function parseRecordDef(def, refs) {
|
|
7913
7921
|
enum: def.keyType._def.values
|
7914
7922
|
}
|
7915
7923
|
});
|
7924
|
+
} else if (((_def_keyType3 = def.keyType) === null || _def_keyType3 === void 0 ? void 0 : _def_keyType3._def.typeName) === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && ((_def_keyType__def_type__def_checks = def.keyType._def.type._def.checks) === null || _def_keyType__def_type__def_checks === void 0 ? void 0 : _def_keyType__def_type__def_checks.length)) {
|
7925
|
+
var _parseBrandedDef = parseBrandedDef(def.keyType._def, refs); _parseBrandedDef.type; var keyType1 = _object_without_properties$6(_parseBrandedDef, [
|
7926
|
+
"type"
|
7927
|
+
]);
|
7928
|
+
return _object_spread_props$p(_object_spread$D({}, schema), {
|
7929
|
+
propertyNames: keyType1
|
7930
|
+
});
|
7916
7931
|
}
|
7917
7932
|
return schema;
|
7918
7933
|
}
|
@@ -9200,7 +9215,7 @@ var selectParser = function(def, typeName, refs) {
|
|
9200
9215
|
case ZodFirstPartyTypeKind.ZodSymbol:
|
9201
9216
|
return undefined;
|
9202
9217
|
default:
|
9203
|
-
return function(_) {
|
9218
|
+
/* c8 ignore next */ return function(_) {
|
9204
9219
|
return undefined;
|
9205
9220
|
}();
|
9206
9221
|
}
|
@@ -18538,17 +18553,11 @@ var Client = /*#__PURE__*/ function() {
|
|
18538
18553
|
writable: true,
|
18539
18554
|
value: void 0
|
18540
18555
|
});
|
18541
|
-
Object.defineProperty(this, "autoBatchInitialDelayMs", {
|
18542
|
-
enumerable: true,
|
18543
|
-
configurable: true,
|
18544
|
-
writable: true,
|
18545
|
-
value: 250
|
18546
|
-
});
|
18547
18556
|
Object.defineProperty(this, "autoBatchAggregationDelayMs", {
|
18548
18557
|
enumerable: true,
|
18549
18558
|
configurable: true,
|
18550
18559
|
writable: true,
|
18551
|
-
value:
|
18560
|
+
value: 250
|
18552
18561
|
});
|
18553
18562
|
Object.defineProperty(this, "batchSizeBytesLimit", {
|
18554
18563
|
enumerable: true,
|
@@ -19130,11 +19139,10 @@ var Client = /*#__PURE__*/ function() {
|
|
19130
19139
|
value: function processRunOperation(item) {
|
19131
19140
|
var _this = this;
|
19132
19141
|
return _async_to_generator$n(function() {
|
19133
|
-
var
|
19142
|
+
var itemPromise, sizeLimitBytes;
|
19134
19143
|
return _ts_generator$p(this, function(_state) {
|
19135
19144
|
switch(_state.label){
|
19136
19145
|
case 0:
|
19137
|
-
oldTimeout = _this.autoBatchTimeout;
|
19138
19146
|
clearTimeout(_this.autoBatchTimeout);
|
19139
19147
|
_this.autoBatchTimeout = undefined;
|
19140
19148
|
if (item.action === "create") {
|
@@ -19154,7 +19162,7 @@ var Client = /*#__PURE__*/ function() {
|
|
19154
19162
|
_this.autoBatchTimeout = setTimeout(function() {
|
19155
19163
|
_this.autoBatchTimeout = undefined;
|
19156
19164
|
_this.drainAutoBatchQueue(sizeLimitBytes);
|
19157
|
-
},
|
19165
|
+
}, _this.autoBatchAggregationDelayMs);
|
19158
19166
|
}
|
19159
19167
|
return [
|
19160
19168
|
2,
|
@@ -19636,7 +19644,7 @@ var Client = /*#__PURE__*/ function() {
|
|
19636
19644
|
var runCreates = param.runCreates, runUpdates = param.runUpdates;
|
19637
19645
|
var _this = this;
|
19638
19646
|
return _async_to_generator$n(function() {
|
19639
|
-
var allAttachments, preparedCreateParams, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, create, preparedCreate, preparedUpdateParams, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, update, invalidRunCreate, invalidRunUpdate, createById, standaloneUpdates, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, updateParam, accumulatedContext, accumulatedParts, _i, _iter, _ref, _ref1, method, payloads, _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, _ref2, originalPayload, inputs, outputs, events, payload, fields, stringifiedPayload, _iteratorNormalCompletion4, _didIteratorError4, _iteratorError4, _iterator4, _step4, _step_value, key, value, stringifiedValue,
|
19647
|
+
var allAttachments, preparedCreateParams, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, create, preparedCreate, preparedUpdateParams, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, update, invalidRunCreate, invalidRunUpdate, createById, standaloneUpdates, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, updateParam, accumulatedContext, accumulatedParts, _i, _iter, _ref, _ref1, method, payloads, _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, _ref2, originalPayload, inputs, outputs, events, attachments, payload, fields, stringifiedPayload, _iteratorNormalCompletion4, _didIteratorError4, _iteratorError4, _iterator4, _step4, _step_value, key, value, stringifiedValue, attachments1, _iteratorNormalCompletion5, _didIteratorError5, _iteratorError5, _iterator5, _step5, _step_value1, name, _step_value_, contentType, content;
|
19640
19648
|
return _ts_generator$p(this, function(_state) {
|
19641
19649
|
switch(_state.label){
|
19642
19650
|
case 0:
|
@@ -19770,10 +19778,11 @@ var Client = /*#__PURE__*/ function() {
|
|
19770
19778
|
_ref2 = _step3.value;
|
19771
19779
|
originalPayload = _ref2;
|
19772
19780
|
// collect fields to be sent as separate parts
|
19773
|
-
inputs = originalPayload.inputs, outputs = originalPayload.outputs, events = originalPayload.events, payload = _object_without_properties$4(originalPayload, [
|
19781
|
+
inputs = originalPayload.inputs, outputs = originalPayload.outputs, events = originalPayload.events, attachments = originalPayload.attachments, payload = _object_without_properties$4(originalPayload, [
|
19774
19782
|
"inputs",
|
19775
19783
|
"outputs",
|
19776
|
-
"events"
|
19784
|
+
"events",
|
19785
|
+
"attachments"
|
19777
19786
|
]);
|
19778
19787
|
fields = {
|
19779
19788
|
inputs: inputs,
|
@@ -19824,19 +19833,24 @@ var Client = /*#__PURE__*/ function() {
|
|
19824
19833
|
}
|
19825
19834
|
// encode the attachments
|
19826
19835
|
if (payload.id !== undefined) {
|
19827
|
-
|
19828
|
-
if (
|
19836
|
+
attachments1 = allAttachments[payload.id];
|
19837
|
+
if (attachments1) {
|
19829
19838
|
delete allAttachments[payload.id];
|
19830
19839
|
_iteratorNormalCompletion5 = true, _didIteratorError5 = false, _iteratorError5 = undefined;
|
19831
19840
|
try {
|
19832
|
-
for(_iterator5 = Object.entries(
|
19841
|
+
for(_iterator5 = Object.entries(attachments1)[Symbol.iterator](); !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true){
|
19833
19842
|
_step_value1 = _sliced_to_array$c(_step5.value, 2), name = _step_value1[0], _step_value_ = _sliced_to_array$c(_step_value1[1], 2), contentType = _step_value_[0], content = _step_value_[1];
|
19843
|
+
// Validate that the attachment name doesn't contain a '.'
|
19844
|
+
if (name.includes(".")) {
|
19845
|
+
console.warn("Skipping attachment '".concat(name, "' for run ").concat(payload.id, ": Invalid attachment name. ") + "Attachment names must not contain periods ('.'). Please rename the attachment and try again.");
|
19846
|
+
continue;
|
19847
|
+
}
|
19834
19848
|
accumulatedParts.push({
|
19835
19849
|
name: "attachment.".concat(payload.id, ".").concat(name),
|
19836
19850
|
payload: new Blob([
|
19837
19851
|
content
|
19838
19852
|
], {
|
19839
|
-
type: "".concat(contentType, "; length=").concat(content.
|
19853
|
+
type: "".concat(contentType, "; length=").concat(content.byteLength)
|
19840
19854
|
})
|
19841
19855
|
});
|
19842
19856
|
}
|
@@ -19924,6 +19938,7 @@ var Client = /*#__PURE__*/ function() {
|
|
19924
19938
|
}
|
19925
19939
|
}
|
19926
19940
|
}
|
19941
|
+
// Log the form data
|
19927
19942
|
return [
|
19928
19943
|
4,
|
19929
19944
|
_this.batchIngestCaller.call(_getFetchImplementation(), "".concat(_this.apiUrl, "/runs/multipart"), _object_spread$k({
|
@@ -25661,7 +25676,7 @@ var Client = /*#__PURE__*/ function() {
|
|
25661
25676
|
}();
|
25662
25677
|
|
25663
25678
|
// Update using yarn bump-version
|
25664
|
-
var __version__ = "0.2.
|
25679
|
+
var __version__ = "0.2.4";
|
25665
25680
|
|
25666
25681
|
// Inlined from https://github.com/flexdinesh/browser-or-node
|
25667
25682
|
function _array_like_to_array$g(arr, len) {
|
@@ -26447,6 +26462,15 @@ var RunTree = /*#__PURE__*/ function() {
|
|
26447
26462
|
writable: true,
|
26448
26463
|
value: void 0
|
26449
26464
|
});
|
26465
|
+
/**
|
26466
|
+
* Attachments associated with the run.
|
26467
|
+
* Each entry is a tuple of [mime_type, bytes]
|
26468
|
+
*/ Object.defineProperty(this, "attachments", {
|
26469
|
+
enumerable: true,
|
26470
|
+
configurable: true,
|
26471
|
+
writable: true,
|
26472
|
+
value: void 0
|
26473
|
+
});
|
26450
26474
|
// If you pass in a run tree directly, return a shallow clone
|
26451
26475
|
if (isRunTree(originalConfig)) {
|
26452
26476
|
Object.assign(this, _object_spread$i({}, originalConfig));
|
@@ -26625,7 +26649,8 @@ var RunTree = /*#__PURE__*/ function() {
|
|
26625
26649
|
parent_run_id: parent_run_id,
|
26626
26650
|
trace_id: run.trace_id,
|
26627
26651
|
dotted_order: run.dotted_order,
|
26628
|
-
tags: run.tags
|
26652
|
+
tags: run.tags,
|
26653
|
+
attachments: run.attachments
|
26629
26654
|
};
|
26630
26655
|
return persistedRun;
|
26631
26656
|
}
|
@@ -26767,7 +26792,8 @@ var RunTree = /*#__PURE__*/ function() {
|
|
26767
26792
|
events: _this.events,
|
26768
26793
|
dotted_order: _this.dotted_order,
|
26769
26794
|
trace_id: _this.trace_id,
|
26770
|
-
tags: _this.tags
|
26795
|
+
tags: _this.tags,
|
26796
|
+
attachments: _this.attachments
|
26771
26797
|
};
|
26772
26798
|
return [
|
26773
26799
|
4,
|
@@ -29590,6 +29616,14 @@ var BaseTracer = /*#__PURE__*/ function(BaseCallbackHandler) {
|
|
29590
29616
|
return BaseTracer;
|
29591
29617
|
}(BaseCallbackHandler);
|
29592
29618
|
|
29619
|
+
var TRACING_ALS_KEY = Symbol.for("ls:tracing_async_local_storage");
|
29620
|
+
var setGlobalAsyncLocalStorageInstance = function(instance) {
|
29621
|
+
globalThis[TRACING_ALS_KEY] = instance;
|
29622
|
+
};
|
29623
|
+
var getGlobalAsyncLocalStorageInstance = function() {
|
29624
|
+
return globalThis[TRACING_ALS_KEY];
|
29625
|
+
};
|
29626
|
+
|
29593
29627
|
var ansiStyles = {
|
29594
29628
|
exports: {}
|
29595
29629
|
};
|
@@ -30345,6 +30379,18 @@ var color = styles.color;
|
|
30345
30379
|
return ConsoleCallbackHandler;
|
30346
30380
|
}(BaseTracer);
|
30347
30381
|
|
30382
|
+
var client;
|
30383
|
+
var getDefaultLangChainClientSingleton = function() {
|
30384
|
+
if (client === undefined) {
|
30385
|
+
var clientParams = getEnvironmentVariable("LANGCHAIN_CALLBACKS_BACKGROUND") === "false" ? {
|
30386
|
+
// LangSmith has its own backgrounding system
|
30387
|
+
blockOnRootRunFinalization: true
|
30388
|
+
} : {};
|
30389
|
+
client = new Client(clientParams);
|
30390
|
+
}
|
30391
|
+
return client;
|
30392
|
+
};
|
30393
|
+
|
30348
30394
|
function _array_like_to_array$c(arr, len) {
|
30349
30395
|
if (len == null || len > arr.length) len = arr.length;
|
30350
30396
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
@@ -30700,10 +30746,7 @@ var LangChainTracer = /*#__PURE__*/ function(BaseTracer) {
|
|
30700
30746
|
var _ref;
|
30701
30747
|
_this.projectName = (_ref = projectName !== null && projectName !== void 0 ? projectName : getEnvironmentVariable("LANGCHAIN_PROJECT")) !== null && _ref !== void 0 ? _ref : getEnvironmentVariable("LANGCHAIN_SESSION");
|
30702
30748
|
_this.exampleId = exampleId;
|
30703
|
-
_this.client = client !== null && client !== void 0 ? client :
|
30704
|
-
// LangChain has its own backgrounding system
|
30705
|
-
blockOnRootRunFinalization: true
|
30706
|
-
});
|
30749
|
+
_this.client = client !== null && client !== void 0 ? client : getDefaultLangChainClientSingleton();
|
30707
30750
|
var traceableTree = LangChainTracer.getTraceableRunTree();
|
30708
30751
|
if (traceableTree) {
|
30709
30752
|
_this.updateFromRunTree(traceableTree);
|
@@ -30954,7 +30997,7 @@ var LangChainTracer = /*#__PURE__*/ function(BaseTracer) {
|
|
30954
30997
|
return LangChainTracer;
|
30955
30998
|
}(BaseTracer);
|
30956
30999
|
|
30957
|
-
function asyncGeneratorStep$i(gen, resolve, reject, _next, _throw, key, arg) {
|
31000
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */ function asyncGeneratorStep$i(gen, resolve, reject, _next, _throw, key, arg) {
|
30958
31001
|
try {
|
30959
31002
|
var info = gen[key](arg);
|
30960
31003
|
var value = info.value;
|
@@ -31090,6 +31133,12 @@ var queue;
|
|
31090
31133
|
concurrency: 1
|
31091
31134
|
});
|
31092
31135
|
}
|
31136
|
+
function getQueue() {
|
31137
|
+
if (typeof queue === "undefined") {
|
31138
|
+
queue = createQueue();
|
31139
|
+
}
|
31140
|
+
return queue;
|
31141
|
+
}
|
31093
31142
|
/**
|
31094
31143
|
* Consume a promise, either adding it to the queue or waiting for it to resolve
|
31095
31144
|
* @param promiseFn Promise to consume
|
@@ -31103,26 +31152,87 @@ function _consumeCallback() {
|
|
31103
31152
|
switch(_state.label){
|
31104
31153
|
case 0:
|
31105
31154
|
if (!(wait === true)) return [
|
31155
|
+
3,
|
31156
|
+
5
|
31157
|
+
];
|
31158
|
+
if (!(getGlobalAsyncLocalStorageInstance() !== undefined)) return [
|
31106
31159
|
3,
|
31107
31160
|
2
|
31108
31161
|
];
|
31109
31162
|
return [
|
31110
31163
|
4,
|
31111
|
-
|
31164
|
+
getGlobalAsyncLocalStorageInstance().run(undefined, /*#__PURE__*/ _async_to_generator$i(function() {
|
31165
|
+
return _ts_generator$k(this, function(_state) {
|
31166
|
+
return [
|
31167
|
+
2,
|
31168
|
+
promiseFn()
|
31169
|
+
];
|
31170
|
+
});
|
31171
|
+
}))
|
31112
31172
|
];
|
31113
31173
|
case 1:
|
31114
31174
|
_state.sent();
|
31115
31175
|
return [
|
31116
31176
|
3,
|
31117
|
-
|
31177
|
+
4
|
31118
31178
|
];
|
31119
31179
|
case 2:
|
31120
|
-
|
31121
|
-
|
31122
|
-
|
31123
|
-
|
31124
|
-
_state.label = 3;
|
31180
|
+
return [
|
31181
|
+
4,
|
31182
|
+
promiseFn()
|
31183
|
+
];
|
31125
31184
|
case 3:
|
31185
|
+
_state.sent();
|
31186
|
+
_state.label = 4;
|
31187
|
+
case 4:
|
31188
|
+
return [
|
31189
|
+
3,
|
31190
|
+
6
|
31191
|
+
];
|
31192
|
+
case 5:
|
31193
|
+
queue = getQueue();
|
31194
|
+
void queue.add(/*#__PURE__*/ _async_to_generator$i(function() {
|
31195
|
+
return _ts_generator$k(this, function(_state) {
|
31196
|
+
switch(_state.label){
|
31197
|
+
case 0:
|
31198
|
+
if (!(getGlobalAsyncLocalStorageInstance() !== undefined)) return [
|
31199
|
+
3,
|
31200
|
+
2
|
31201
|
+
];
|
31202
|
+
return [
|
31203
|
+
4,
|
31204
|
+
getGlobalAsyncLocalStorageInstance().run(undefined, /*#__PURE__*/ _async_to_generator$i(function() {
|
31205
|
+
return _ts_generator$k(this, function(_state) {
|
31206
|
+
return [
|
31207
|
+
2,
|
31208
|
+
promiseFn()
|
31209
|
+
];
|
31210
|
+
});
|
31211
|
+
}))
|
31212
|
+
];
|
31213
|
+
case 1:
|
31214
|
+
_state.sent();
|
31215
|
+
return [
|
31216
|
+
3,
|
31217
|
+
4
|
31218
|
+
];
|
31219
|
+
case 2:
|
31220
|
+
return [
|
31221
|
+
4,
|
31222
|
+
promiseFn()
|
31223
|
+
];
|
31224
|
+
case 3:
|
31225
|
+
_state.sent();
|
31226
|
+
_state.label = 4;
|
31227
|
+
case 4:
|
31228
|
+
return [
|
31229
|
+
2
|
31230
|
+
];
|
31231
|
+
}
|
31232
|
+
});
|
31233
|
+
}));
|
31234
|
+
_state.label = 6;
|
31235
|
+
case 6:
|
31126
31236
|
return [
|
31127
31237
|
2
|
31128
31238
|
];
|
@@ -33469,7 +33579,6 @@ var MockAsyncLocalStorage = /*#__PURE__*/ function() {
|
|
33469
33579
|
return MockAsyncLocalStorage;
|
33470
33580
|
}();
|
33471
33581
|
var mockAsyncLocalStorage = new MockAsyncLocalStorage();
|
33472
|
-
var TRACING_ALS_KEY = Symbol.for("ls:tracing_async_local_storage");
|
33473
33582
|
var LC_CHILD_KEY = Symbol.for("lc:child_config");
|
33474
33583
|
var _CONTEXT_VARIABLES_KEY = Symbol.for("lc:context_variables");
|
33475
33584
|
var AsyncLocalStorageProvider = /*#__PURE__*/ function() {
|
@@ -33480,8 +33589,8 @@ var AsyncLocalStorageProvider = /*#__PURE__*/ function() {
|
|
33480
33589
|
{
|
33481
33590
|
key: "getInstance",
|
33482
33591
|
value: function getInstance() {
|
33483
|
-
var
|
33484
|
-
return (
|
33592
|
+
var _getGlobalAsyncLocalStorageInstance;
|
33593
|
+
return (_getGlobalAsyncLocalStorageInstance = getGlobalAsyncLocalStorageInstance()) !== null && _getGlobalAsyncLocalStorageInstance !== void 0 ? _getGlobalAsyncLocalStorageInstance : mockAsyncLocalStorage;
|
33485
33594
|
}
|
33486
33595
|
},
|
33487
33596
|
{
|
@@ -33527,8 +33636,8 @@ var AsyncLocalStorageProvider = /*#__PURE__*/ function() {
|
|
33527
33636
|
{
|
33528
33637
|
key: "initializeGlobalInstance",
|
33529
33638
|
value: function initializeGlobalInstance(instance) {
|
33530
|
-
if (
|
33531
|
-
|
33639
|
+
if (getGlobalAsyncLocalStorageInstance() === undefined) {
|
33640
|
+
setGlobalAsyncLocalStorageInstance(instance);
|
33532
33641
|
}
|
33533
33642
|
}
|
33534
33643
|
}
|
@@ -42858,6 +42967,43 @@ function _coerceToDict(value, defaultKey) {
|
|
42858
42967
|
}(Serializable);
|
42859
42968
|
/**
|
42860
42969
|
* A runnable that delegates calls to another runnable with a set of kwargs.
|
42970
|
+
* @example
|
42971
|
+
* ```typescript
|
42972
|
+
* import {
|
42973
|
+
* type RunnableConfig,
|
42974
|
+
* RunnableLambda,
|
42975
|
+
* } from "@langchain/core/runnables";
|
42976
|
+
*
|
42977
|
+
* const enhanceProfile = (
|
42978
|
+
* profile: Record<string, any>,
|
42979
|
+
* config?: RunnableConfig
|
42980
|
+
* ) => {
|
42981
|
+
* if (config?.configurable?.role) {
|
42982
|
+
* return { ...profile, role: config.configurable.role };
|
42983
|
+
* }
|
42984
|
+
* return profile;
|
42985
|
+
* };
|
42986
|
+
*
|
42987
|
+
* const runnable = RunnableLambda.from(enhanceProfile);
|
42988
|
+
*
|
42989
|
+
* // Bind configuration to the runnable to set the user's role dynamically
|
42990
|
+
* const adminRunnable = runnable.bind({ configurable: { role: "Admin" } });
|
42991
|
+
* const userRunnable = runnable.bind({ configurable: { role: "User" } });
|
42992
|
+
*
|
42993
|
+
* const result1 = await adminRunnable.invoke({
|
42994
|
+
* name: "Alice",
|
42995
|
+
* email: "alice@example.com"
|
42996
|
+
* });
|
42997
|
+
*
|
42998
|
+
* // { name: "Alice", email: "alice@example.com", role: "Admin" }
|
42999
|
+
*
|
43000
|
+
* const result2 = await userRunnable.invoke({
|
43001
|
+
* name: "Bob",
|
43002
|
+
* email: "bob@example.com"
|
43003
|
+
* });
|
43004
|
+
*
|
43005
|
+
* // { name: "Bob", email: "bob@example.com", role: "User" }
|
43006
|
+
* ```
|
42861
43007
|
*/ var RunnableBinding = /*#__PURE__*/ function(Runnable1) {
|
42862
43008
|
_inherits$7(RunnableBinding, Runnable1);
|
42863
43009
|
var _super = _create_super$7(RunnableBinding);
|
@@ -43327,6 +43473,24 @@ function _coerceToDict(value, defaultKey) {
|
|
43327
43473
|
/**
|
43328
43474
|
* A runnable that delegates calls to another runnable
|
43329
43475
|
* with each element of the input sequence.
|
43476
|
+
* @example
|
43477
|
+
* ```typescript
|
43478
|
+
* import { RunnableEach, RunnableLambda } from "@langchain/core/runnables";
|
43479
|
+
*
|
43480
|
+
* const toUpperCase = (input: string): string => input.toUpperCase();
|
43481
|
+
* const addGreeting = (input: string): string => `Hello, ${input}!`;
|
43482
|
+
*
|
43483
|
+
* const upperCaseLambda = RunnableLambda.from(toUpperCase);
|
43484
|
+
* const greetingLambda = RunnableLambda.from(addGreeting);
|
43485
|
+
*
|
43486
|
+
* const chain = new RunnableEach({
|
43487
|
+
* bound: upperCaseLambda.pipe(greetingLambda),
|
43488
|
+
* });
|
43489
|
+
*
|
43490
|
+
* const result = await chain.invoke(["alice", "bob", "carol"])
|
43491
|
+
*
|
43492
|
+
* // ["Hello, ALICE!", "Hello, BOB!", "Hello, CAROL!"]
|
43493
|
+
* ```
|
43330
43494
|
*/ var RunnableEach = /*#__PURE__*/ function(Runnable) {
|
43331
43495
|
_inherits$7(RunnableEach, Runnable);
|
43332
43496
|
var _super = _create_super$7(RunnableEach);
|
@@ -43447,6 +43611,45 @@ function _coerceToDict(value, defaultKey) {
|
|
43447
43611
|
/**
|
43448
43612
|
* Base class for runnables that can be retried a
|
43449
43613
|
* specified number of times.
|
43614
|
+
* @example
|
43615
|
+
* ```typescript
|
43616
|
+
* import {
|
43617
|
+
* RunnableLambda,
|
43618
|
+
* RunnableRetry,
|
43619
|
+
* } from "@langchain/core/runnables";
|
43620
|
+
*
|
43621
|
+
* // Simulate an API call that fails
|
43622
|
+
* const simulateApiCall = (input: string): string => {
|
43623
|
+
* console.log(`Attempting API call with input: ${input}`);
|
43624
|
+
* throw new Error("API call failed due to network issue");
|
43625
|
+
* };
|
43626
|
+
*
|
43627
|
+
* const apiCallLambda = RunnableLambda.from(simulateApiCall);
|
43628
|
+
*
|
43629
|
+
* // Apply retry logic using the .withRetry() method
|
43630
|
+
* const apiCallWithRetry = apiCallLambda.withRetry({ stopAfterAttempt: 3 });
|
43631
|
+
*
|
43632
|
+
* // Alternatively, create a RunnableRetry instance manually
|
43633
|
+
* const manualRetry = new RunnableRetry({
|
43634
|
+
* bound: apiCallLambda,
|
43635
|
+
* maxAttemptNumber: 3,
|
43636
|
+
* config: {},
|
43637
|
+
* });
|
43638
|
+
*
|
43639
|
+
* // Example invocation using the .withRetry() method
|
43640
|
+
* const res = await apiCallWithRetry
|
43641
|
+
* .invoke("Request 1")
|
43642
|
+
* .catch((error) => {
|
43643
|
+
* console.error("Failed after multiple retries:", error.message);
|
43644
|
+
* });
|
43645
|
+
*
|
43646
|
+
* // Example invocation using the manual retry instance
|
43647
|
+
* const res2 = await manualRetry
|
43648
|
+
* .invoke("Request 2")
|
43649
|
+
* .catch((error) => {
|
43650
|
+
* console.error("Failed after multiple retries:", error.message);
|
43651
|
+
* });
|
43652
|
+
* ```
|
43450
43653
|
*/ var RunnableRetry = /*#__PURE__*/ function(RunnableBinding) {
|
43451
43654
|
_inherits$7(RunnableRetry, RunnableBinding);
|
43452
43655
|
var _super = _create_super$7(RunnableRetry);
|
@@ -44860,7 +45063,30 @@ function assertNonTraceableFunction(func) {
|
|
44860
45063
|
}
|
44861
45064
|
}
|
44862
45065
|
/**
|
44863
|
-
* A runnable that
|
45066
|
+
* A runnable that wraps an arbitrary function that takes a single argument.
|
45067
|
+
* @example
|
45068
|
+
* ```typescript
|
45069
|
+
* import { RunnableLambda } from "@langchain/core/runnables";
|
45070
|
+
*
|
45071
|
+
* const add = (input: { x: number; y: number }) => input.x + input.y;
|
45072
|
+
*
|
45073
|
+
* const multiply = (input: { value: number; multiplier: number }) =>
|
45074
|
+
* input.value * input.multiplier;
|
45075
|
+
*
|
45076
|
+
* // Create runnables for the functions
|
45077
|
+
* const addLambda = RunnableLambda.from(add);
|
45078
|
+
* const multiplyLambda = RunnableLambda.from(multiply);
|
45079
|
+
*
|
45080
|
+
* // Chain the lambdas for a mathematical operation
|
45081
|
+
* const chainedLambda = addLambda.pipe((result) =>
|
45082
|
+
* multiplyLambda.invoke({ value: result, multiplier: 2 })
|
45083
|
+
* );
|
45084
|
+
*
|
45085
|
+
* // Example invocation of the chainedLambda
|
45086
|
+
* const result = await chainedLambda.invoke({ x: 2, y: 3 });
|
45087
|
+
*
|
45088
|
+
* // Will log "10" (since (2 + 3) * 2 = 10)
|
45089
|
+
* ```
|
44864
45090
|
*/ var RunnableLambda = /*#__PURE__*/ function(Runnable1) {
|
44865
45091
|
_inherits$7(RunnableLambda, Runnable1);
|
44866
45092
|
var _super = _create_super$7(RunnableLambda);
|
@@ -45638,6 +45864,55 @@ function assertNonTraceableFunction(func) {
|
|
45638
45864
|
* When streaming, fallbacks will only be called on failures during the initial
|
45639
45865
|
* stream creation. Errors that occur after a stream starts will not fallback
|
45640
45866
|
* to the next Runnable.
|
45867
|
+
*
|
45868
|
+
* @example
|
45869
|
+
* ```typescript
|
45870
|
+
* import {
|
45871
|
+
* RunnableLambda,
|
45872
|
+
* RunnableWithFallbacks,
|
45873
|
+
* } from "@langchain/core/runnables";
|
45874
|
+
*
|
45875
|
+
* const primaryOperation = (input: string): string => {
|
45876
|
+
* if (input !== "safe") {
|
45877
|
+
* throw new Error("Primary operation failed due to unsafe input");
|
45878
|
+
* }
|
45879
|
+
* return `Processed: ${input}`;
|
45880
|
+
* };
|
45881
|
+
*
|
45882
|
+
* // Define a fallback operation that processes the input differently
|
45883
|
+
* const fallbackOperation = (input: string): string =>
|
45884
|
+
* `Fallback processed: ${input}`;
|
45885
|
+
*
|
45886
|
+
* const primaryRunnable = RunnableLambda.from(primaryOperation);
|
45887
|
+
* const fallbackRunnable = RunnableLambda.from(fallbackOperation);
|
45888
|
+
*
|
45889
|
+
* // Apply the fallback logic using the .withFallbacks() method
|
45890
|
+
* const runnableWithFallback = primaryRunnable.withFallbacks([fallbackRunnable]);
|
45891
|
+
*
|
45892
|
+
* // Alternatively, create a RunnableWithFallbacks instance manually
|
45893
|
+
* const manualFallbackChain = new RunnableWithFallbacks({
|
45894
|
+
* runnable: primaryRunnable,
|
45895
|
+
* fallbacks: [fallbackRunnable],
|
45896
|
+
* });
|
45897
|
+
*
|
45898
|
+
* // Example invocation using .withFallbacks()
|
45899
|
+
* const res = await runnableWithFallback
|
45900
|
+
* .invoke("unsafe input")
|
45901
|
+
* .catch((error) => {
|
45902
|
+
* console.error("Failed after all attempts:", error.message);
|
45903
|
+
* });
|
45904
|
+
*
|
45905
|
+
* // "Fallback processed: unsafe input"
|
45906
|
+
*
|
45907
|
+
* // Example invocation using manual instantiation
|
45908
|
+
* const res = await manualFallbackChain
|
45909
|
+
* .invoke("safe")
|
45910
|
+
* .catch((error) => {
|
45911
|
+
* console.error("Failed after all attempts:", error.message);
|
45912
|
+
* });
|
45913
|
+
*
|
45914
|
+
* // "Processed: safe"
|
45915
|
+
* ```
|
45641
45916
|
*/ var RunnableWithFallbacks = /*#__PURE__*/ function(Runnable) {
|
45642
45917
|
_inherits$7(RunnableWithFallbacks, Runnable);
|
45643
45918
|
var _super = _create_super$7(RunnableWithFallbacks);
|
@@ -46353,6 +46628,34 @@ function _coerceToRunnable(coerceable) {
|
|
46353
46628
|
}
|
46354
46629
|
/**
|
46355
46630
|
* A runnable that assigns key-value pairs to inputs of type `Record<string, unknown>`.
|
46631
|
+
* @example
|
46632
|
+
* ```typescript
|
46633
|
+
* import {
|
46634
|
+
* RunnableAssign,
|
46635
|
+
* RunnableLambda,
|
46636
|
+
* RunnableParallel,
|
46637
|
+
* } from "@langchain/core/runnables";
|
46638
|
+
*
|
46639
|
+
* const calculateAge = (x: { birthYear: number }): { age: number } => {
|
46640
|
+
* const currentYear = new Date().getFullYear();
|
46641
|
+
* return { age: currentYear - x.birthYear };
|
46642
|
+
* };
|
46643
|
+
*
|
46644
|
+
* const createGreeting = (x: { name: string }): { greeting: string } => {
|
46645
|
+
* return { greeting: `Hello, ${x.name}!` };
|
46646
|
+
* };
|
46647
|
+
*
|
46648
|
+
* const mapper = RunnableParallel.from({
|
46649
|
+
* age_step: RunnableLambda.from(calculateAge),
|
46650
|
+
* greeting_step: RunnableLambda.from(createGreeting),
|
46651
|
+
* });
|
46652
|
+
*
|
46653
|
+
* const runnableAssign = new RunnableAssign({ mapper });
|
46654
|
+
*
|
46655
|
+
* const res = await runnableAssign.invoke({ name: "Alice", birthYear: 1990 });
|
46656
|
+
*
|
46657
|
+
* // { name: "Alice", birthYear: 1990, age_step: { age: 34 }, greeting_step: { greeting: "Hello, Alice!" } }
|
46658
|
+
* ```
|
46356
46659
|
*/ var RunnableAssign = /*#__PURE__*/ function(Runnable) {
|
46357
46660
|
_inherits$7(RunnableAssign, Runnable);
|
46358
46661
|
var _super = _create_super$7(RunnableAssign);
|
@@ -46703,6 +47006,27 @@ function _coerceToRunnable(coerceable) {
|
|
46703
47006
|
}(Runnable);
|
46704
47007
|
/**
|
46705
47008
|
* A runnable that assigns key-value pairs to inputs of type `Record<string, unknown>`.
|
47009
|
+
* Useful for streaming, can be automatically created and chained by calling `runnable.pick();`.
|
47010
|
+
* @example
|
47011
|
+
* ```typescript
|
47012
|
+
* import { RunnablePick } from "@langchain/core/runnables";
|
47013
|
+
*
|
47014
|
+
* const inputData = {
|
47015
|
+
* name: "John",
|
47016
|
+
* age: 30,
|
47017
|
+
* city: "New York",
|
47018
|
+
* country: "USA",
|
47019
|
+
* email: "john.doe@example.com",
|
47020
|
+
* phone: "+1234567890",
|
47021
|
+
* };
|
47022
|
+
*
|
47023
|
+
* const basicInfoRunnable = new RunnablePick(["name", "city"]);
|
47024
|
+
*
|
47025
|
+
* // Example invocation
|
47026
|
+
* const res = await basicInfoRunnable.invoke(inputData);
|
47027
|
+
*
|
47028
|
+
* // { name: 'John', city: 'New York' }
|
47029
|
+
* ```
|
46706
47030
|
*/ var RunnablePick = /*#__PURE__*/ function(Runnable) {
|
46707
47031
|
_inherits$7(RunnablePick, Runnable);
|
46708
47032
|
var _super = _create_super$7(RunnablePick);
|
@@ -48406,11 +48730,23 @@ function getEncodingNameForModel(model) {
|
|
48406
48730
|
case "gpt-4-turbo-preview":
|
48407
48731
|
case "gpt-4-0125-preview":
|
48408
48732
|
case "text-embedding-ada-002":
|
48733
|
+
case "text-embedding-3-small":
|
48734
|
+
case "text-embedding-3-large":
|
48409
48735
|
{
|
48410
48736
|
return "cl100k_base";
|
48411
48737
|
}
|
48412
48738
|
case "gpt-4o":
|
48413
48739
|
case "gpt-4o-2024-05-13":
|
48740
|
+
case "gpt-4o-2024-08-06":
|
48741
|
+
case "gpt-4o-mini-2024-07-18":
|
48742
|
+
case "gpt-4o-mini":
|
48743
|
+
case "o1-mini":
|
48744
|
+
case "o1-preview":
|
48745
|
+
case "o1-preview-2024-09-12":
|
48746
|
+
case "o1-mini-2024-09-12":
|
48747
|
+
case "chatgpt-4o-latest":
|
48748
|
+
case "gpt-4o-realtime":
|
48749
|
+
case "gpt-4o-realtime-preview-2024-10-01":
|
48414
48750
|
{
|
48415
48751
|
return "o200k_base";
|
48416
48752
|
}
|
@@ -50595,9 +50931,11 @@ function _ts_generator$3(thisArg, body) {
|
|
50595
50931
|
{
|
50596
50932
|
key: "getLsParams",
|
50597
50933
|
value: function getLsParams(options) {
|
50934
|
+
var providerName = this.getName().startsWith("Chat") ? this.getName().replace("Chat", "") : this.getName();
|
50598
50935
|
return {
|
50599
50936
|
ls_model_type: "chat",
|
50600
|
-
ls_stop: options.stop
|
50937
|
+
ls_stop: options.stop,
|
50938
|
+
ls_provider: providerName
|
50601
50939
|
};
|
50602
50940
|
}
|
50603
50941
|
},
|
@@ -51345,6 +51683,9 @@ function _ts_generator$3(thisArg, body) {
|
|
51345
51683
|
if (typeof this.bindTools !== "function") {
|
51346
51684
|
throw new Error('Chat model must implement ".bindTools()" to use withStructuredOutput.');
|
51347
51685
|
}
|
51686
|
+
if (config === null || config === void 0 ? void 0 : config.strict) {
|
51687
|
+
throw new Error('"strict" mode is not supported for this model by default.');
|
51688
|
+
}
|
51348
51689
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
51349
51690
|
var schema = outputSchema;
|
51350
51691
|
var name = config === null || config === void 0 ? void 0 : config.name;
|
@@ -53817,6 +54158,9 @@ function _ts_generator(thisArg, body) {
|
|
53817
54158
|
var snakeCasedOption = mapping[key];
|
53818
54159
|
if (snakeCasedOption) {
|
53819
54160
|
snakeCasedOptions[snakeCasedOption] = value;
|
54161
|
+
} else {
|
54162
|
+
// Just pass unknown options through
|
54163
|
+
snakeCasedOptions[key] = value;
|
53820
54164
|
}
|
53821
54165
|
}
|
53822
54166
|
} catch (err) {
|