@digipair/skill-ollama 0.42.0 → 0.43.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/index.cjs.js +447 -103
- package/index.esm.js +447 -103
- package/package.json +1 -1
package/index.esm.js
CHANGED
@@ -85,7 +85,7 @@ function _array_like_to_array$G(arr, len) {
|
|
85
85
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
86
86
|
return arr2;
|
87
87
|
}
|
88
|
-
function _array_with_holes$
|
88
|
+
function _array_with_holes$m(arr) {
|
89
89
|
if (Array.isArray(arr)) return arr;
|
90
90
|
}
|
91
91
|
function _array_without_holes$y(arr) {
|
@@ -107,7 +107,7 @@ function _define_property$L(obj, key, value) {
|
|
107
107
|
function _iterable_to_array$y(iter) {
|
108
108
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
109
109
|
}
|
110
|
-
function _iterable_to_array_limit$
|
110
|
+
function _iterable_to_array_limit$m(arr, i) {
|
111
111
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
112
112
|
if (_i == null) return;
|
113
113
|
var _arr = [];
|
@@ -131,7 +131,7 @@ function _iterable_to_array_limit$n(arr, i) {
|
|
131
131
|
}
|
132
132
|
return _arr;
|
133
133
|
}
|
134
|
-
function _non_iterable_rest$
|
134
|
+
function _non_iterable_rest$m() {
|
135
135
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
136
136
|
}
|
137
137
|
function _non_iterable_spread$y() {
|
@@ -176,8 +176,8 @@ function _object_spread_props$v(target, source) {
|
|
176
176
|
}
|
177
177
|
return target;
|
178
178
|
}
|
179
|
-
function _sliced_to_array$
|
180
|
-
return _array_with_holes$
|
179
|
+
function _sliced_to_array$m(arr, i) {
|
180
|
+
return _array_with_holes$m(arr) || _iterable_to_array_limit$m(arr, i) || _unsupported_iterable_to_array$G(arr, i) || _non_iterable_rest$m();
|
181
181
|
}
|
182
182
|
function _to_consumable_array$y(arr) {
|
183
183
|
return _array_without_holes$y(arr) || _iterable_to_array$y(arr) || _unsupported_iterable_to_array$G(arr) || _non_iterable_spread$y();
|
@@ -200,7 +200,7 @@ var getRefs = function(options) {
|
|
200
200
|
currentPath: currentPath,
|
201
201
|
propertyPath: undefined,
|
202
202
|
seen: new Map(Object.entries(_options.definitions).map(function(param) {
|
203
|
-
var _param = _sliced_to_array$
|
203
|
+
var _param = _sliced_to_array$m(param, 2), name = _param[0], def = _param[1];
|
204
204
|
return [
|
205
205
|
def._def,
|
206
206
|
{
|
@@ -285,7 +285,7 @@ function _array_like_to_array$F(arr, len) {
|
|
285
285
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
286
286
|
return arr2;
|
287
287
|
}
|
288
|
-
function _array_with_holes$
|
288
|
+
function _array_with_holes$l(arr) {
|
289
289
|
if (Array.isArray(arr)) return arr;
|
290
290
|
}
|
291
291
|
function _array_without_holes$x(arr) {
|
@@ -407,7 +407,7 @@ function _is_native_function$6(fn) {
|
|
407
407
|
function _iterable_to_array$x(iter) {
|
408
408
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
409
409
|
}
|
410
|
-
function _iterable_to_array_limit$
|
410
|
+
function _iterable_to_array_limit$l(arr, i) {
|
411
411
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
412
412
|
if (_i == null) return;
|
413
413
|
var _arr = [];
|
@@ -431,7 +431,7 @@ function _iterable_to_array_limit$m(arr, i) {
|
|
431
431
|
}
|
432
432
|
return _arr;
|
433
433
|
}
|
434
|
-
function _non_iterable_rest$
|
434
|
+
function _non_iterable_rest$l() {
|
435
435
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
436
436
|
}
|
437
437
|
function _non_iterable_spread$x() {
|
@@ -489,8 +489,8 @@ function _set_prototype_of$u(o, p) {
|
|
489
489
|
};
|
490
490
|
return _set_prototype_of$u(o, p);
|
491
491
|
}
|
492
|
-
function _sliced_to_array$
|
493
|
-
return _array_with_holes$
|
492
|
+
function _sliced_to_array$l(arr, i) {
|
493
|
+
return _array_with_holes$l(arr) || _iterable_to_array_limit$l(arr, i) || _unsupported_iterable_to_array$F(arr, i) || _non_iterable_rest$l();
|
494
494
|
}
|
495
495
|
function _to_consumable_array$x(arr) {
|
496
496
|
return _array_without_holes$x(arr) || _iterable_to_array$x(arr) || _unsupported_iterable_to_array$F(arr) || _non_iterable_spread$x();
|
@@ -1949,7 +1949,7 @@ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-
|
|
1949
1949
|
// /^[a-z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-z0-9-]+(?:\.[a-z0-9\-]+)*$/i;
|
1950
1950
|
// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
|
1951
1951
|
var _emojiRegex = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
1952
|
-
var emojiRegex;
|
1952
|
+
var emojiRegex$1;
|
1953
1953
|
// faster, simpler, safer
|
1954
1954
|
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])$/;
|
1955
1955
|
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})))$/;
|
@@ -2086,10 +2086,10 @@ var ZodString = /*#__PURE__*/ function(ZodType) {
|
|
2086
2086
|
status.dirty();
|
2087
2087
|
}
|
2088
2088
|
} else if (check.kind === "emoji") {
|
2089
|
-
if (!emojiRegex) {
|
2090
|
-
emojiRegex = new RegExp(_emojiRegex, "u");
|
2089
|
+
if (!emojiRegex$1) {
|
2090
|
+
emojiRegex$1 = new RegExp(_emojiRegex, "u");
|
2091
2091
|
}
|
2092
|
-
if (!emojiRegex.test(input.data)) {
|
2092
|
+
if (!emojiRegex$1.test(input.data)) {
|
2093
2093
|
ctx1 = this._getOrReturnCtx(input, ctx1);
|
2094
2094
|
addIssueToContext(ctx1, {
|
2095
2095
|
validation: "emoji",
|
@@ -5038,7 +5038,7 @@ var ZodIntersection = /*#__PURE__*/ function(ZodType) {
|
|
5038
5038
|
parent: ctx
|
5039
5039
|
})
|
5040
5040
|
]).then(function(param) {
|
5041
|
-
var _param = _sliced_to_array$
|
5041
|
+
var _param = _sliced_to_array$l(param, 2), left = _param[0], right = _param[1];
|
5042
5042
|
return handleParsed(left, right);
|
5043
5043
|
});
|
5044
5044
|
} else {
|
@@ -5260,7 +5260,7 @@ var ZodMap = /*#__PURE__*/ function(ZodType) {
|
|
5260
5260
|
var keyType = this._def.keyType;
|
5261
5261
|
var valueType = this._def.valueType;
|
5262
5262
|
var pairs = _to_consumable_array$x(ctx.data.entries()).map(function(param, index) {
|
5263
|
-
var _param = _sliced_to_array$
|
5263
|
+
var _param = _sliced_to_array$l(param, 2), key = _param[0], value = _param[1];
|
5264
5264
|
return {
|
5265
5265
|
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [
|
5266
5266
|
index,
|
@@ -6994,11 +6994,11 @@ function _unsupported_iterable_to_array$E(o, minLen) {
|
|
6994
6994
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$E(o, minLen);
|
6995
6995
|
}
|
6996
6996
|
function parseArrayDef(def, refs) {
|
6997
|
-
var _def_type__def,
|
6997
|
+
var _def_type, _def_type__def, _def_type1;
|
6998
6998
|
var res = {
|
6999
6999
|
type: "array"
|
7000
7000
|
};
|
7001
|
-
if (((_def_type = def.type) === null || _def_type === void 0 ? void 0 : (_def_type__def =
|
7001
|
+
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) {
|
7002
7002
|
res.items = parseDef(def.type._def, _object_spread_props$s(_object_spread$H({}, refs), {
|
7003
7003
|
currentPath: _to_consumable_array$w(refs.currentPath).concat([
|
7004
7004
|
"items"
|
@@ -7291,9 +7291,9 @@ function _object_spread_props$q(target, source) {
|
|
7291
7291
|
}
|
7292
7292
|
return target;
|
7293
7293
|
}
|
7294
|
-
function _object_without_properties$
|
7294
|
+
function _object_without_properties$7(source, excluded) {
|
7295
7295
|
if (source == null) return {};
|
7296
|
-
var target = _object_without_properties_loose$
|
7296
|
+
var target = _object_without_properties_loose$7(source, excluded);
|
7297
7297
|
var key, i;
|
7298
7298
|
if (Object.getOwnPropertySymbols) {
|
7299
7299
|
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
@@ -7306,7 +7306,7 @@ function _object_without_properties$6(source, excluded) {
|
|
7306
7306
|
}
|
7307
7307
|
return target;
|
7308
7308
|
}
|
7309
|
-
function _object_without_properties_loose$
|
7309
|
+
function _object_without_properties_loose$7(source, excluded) {
|
7310
7310
|
if (source == null) return {};
|
7311
7311
|
var target = {};
|
7312
7312
|
var sourceKeys = Object.keys(source);
|
@@ -7367,7 +7367,7 @@ function parseIntersectionDef(def, refs) {
|
|
7367
7367
|
} else {
|
7368
7368
|
var nestedSchema = schema;
|
7369
7369
|
if ("additionalProperties" in schema && schema.additionalProperties === false) {
|
7370
|
-
schema.additionalProperties; var rest = _object_without_properties$
|
7370
|
+
schema.additionalProperties; var rest = _object_without_properties$7(schema, [
|
7371
7371
|
"additionalProperties"
|
7372
7372
|
]);
|
7373
7373
|
nestedSchema = rest;
|
@@ -7436,6 +7436,7 @@ function _object_spread$E(target) {
|
|
7436
7436
|
}
|
7437
7437
|
return target;
|
7438
7438
|
}
|
7439
|
+
var emojiRegex;
|
7439
7440
|
/**
|
7440
7441
|
* Generated from the regular expressions found here as of 2024-05-22:
|
7441
7442
|
* https://github.com/colinhacks/zod/blob/master/src/types.ts.
|
@@ -7452,7 +7453,20 @@ function _object_spread$E(target) {
|
|
7452
7453
|
*/ email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
7453
7454
|
/**
|
7454
7455
|
* Constructed a valid Unicode RegExp
|
7455
|
-
|
7456
|
+
*
|
7457
|
+
* Lazily instantiate since this type of regex isn't supported
|
7458
|
+
* in all envs (e.g. React Native).
|
7459
|
+
*
|
7460
|
+
* See:
|
7461
|
+
* https://github.com/colinhacks/zod/issues/2433
|
7462
|
+
* Fix in Zod:
|
7463
|
+
* https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
|
7464
|
+
*/ emoji: function() {
|
7465
|
+
if (emojiRegex === undefined) {
|
7466
|
+
emojiRegex = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
|
7467
|
+
}
|
7468
|
+
return emojiRegex;
|
7469
|
+
},
|
7456
7470
|
/**
|
7457
7471
|
* Unused
|
7458
7472
|
*/ 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}$/,
|
@@ -7587,7 +7601,7 @@ function parseStringDef(def, refs) {
|
|
7587
7601
|
case "trim":
|
7588
7602
|
break;
|
7589
7603
|
default:
|
7590
|
-
(function(_) {})(check);
|
7604
|
+
/* c8 ignore next */ (function(_) {})(check);
|
7591
7605
|
}
|
7592
7606
|
}
|
7593
7607
|
} catch (err) {
|
@@ -7683,7 +7697,8 @@ var addPattern = function(schema, regex, message, refs) {
|
|
7683
7697
|
}
|
7684
7698
|
};
|
7685
7699
|
// Mutate z.string.regex() in a best attempt to accommodate for regex flags when applyRegexFlags is true
|
7686
|
-
var processRegExp = function(
|
7700
|
+
var processRegExp = function(regexOrFunction, refs) {
|
7701
|
+
var regex = typeof regexOrFunction === "function" ? regexOrFunction() : regexOrFunction;
|
7687
7702
|
if (!refs.applyRegexFlags || !regex.flags) return regex.source;
|
7688
7703
|
// Currently handled flags
|
7689
7704
|
var flags = {
|
@@ -7760,9 +7775,6 @@ function _array_like_to_array$C(arr, len) {
|
|
7760
7775
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
7761
7776
|
return arr2;
|
7762
7777
|
}
|
7763
|
-
function _array_with_holes$l(arr) {
|
7764
|
-
if (Array.isArray(arr)) return arr;
|
7765
|
-
}
|
7766
7778
|
function _array_without_holes$u(arr) {
|
7767
7779
|
if (Array.isArray(arr)) return _array_like_to_array$C(arr);
|
7768
7780
|
}
|
@@ -7782,33 +7794,6 @@ function _define_property$E(obj, key, value) {
|
|
7782
7794
|
function _iterable_to_array$u(iter) {
|
7783
7795
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
7784
7796
|
}
|
7785
|
-
function _iterable_to_array_limit$l(arr, i) {
|
7786
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
7787
|
-
if (_i == null) return;
|
7788
|
-
var _arr = [];
|
7789
|
-
var _n = true;
|
7790
|
-
var _d = false;
|
7791
|
-
var _s, _e;
|
7792
|
-
try {
|
7793
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
7794
|
-
_arr.push(_s.value);
|
7795
|
-
if (i && _arr.length === i) break;
|
7796
|
-
}
|
7797
|
-
} catch (err) {
|
7798
|
-
_d = true;
|
7799
|
-
_e = err;
|
7800
|
-
} finally{
|
7801
|
-
try {
|
7802
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
7803
|
-
} finally{
|
7804
|
-
if (_d) throw _e;
|
7805
|
-
}
|
7806
|
-
}
|
7807
|
-
return _arr;
|
7808
|
-
}
|
7809
|
-
function _non_iterable_rest$l() {
|
7810
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
7811
|
-
}
|
7812
7797
|
function _non_iterable_spread$u() {
|
7813
7798
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
7814
7799
|
}
|
@@ -7851,8 +7836,32 @@ function _object_spread_props$p(target, source) {
|
|
7851
7836
|
}
|
7852
7837
|
return target;
|
7853
7838
|
}
|
7854
|
-
function
|
7855
|
-
|
7839
|
+
function _object_without_properties$6(source, excluded) {
|
7840
|
+
if (source == null) return {};
|
7841
|
+
var target = _object_without_properties_loose$6(source, excluded);
|
7842
|
+
var key, i;
|
7843
|
+
if (Object.getOwnPropertySymbols) {
|
7844
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
7845
|
+
for(i = 0; i < sourceSymbolKeys.length; i++){
|
7846
|
+
key = sourceSymbolKeys[i];
|
7847
|
+
if (excluded.indexOf(key) >= 0) continue;
|
7848
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
7849
|
+
target[key] = source[key];
|
7850
|
+
}
|
7851
|
+
}
|
7852
|
+
return target;
|
7853
|
+
}
|
7854
|
+
function _object_without_properties_loose$6(source, excluded) {
|
7855
|
+
if (source == null) return {};
|
7856
|
+
var target = {};
|
7857
|
+
var sourceKeys = Object.keys(source);
|
7858
|
+
var key, i;
|
7859
|
+
for(i = 0; i < sourceKeys.length; i++){
|
7860
|
+
key = sourceKeys[i];
|
7861
|
+
if (excluded.indexOf(key) >= 0) continue;
|
7862
|
+
target[key] = source[key];
|
7863
|
+
}
|
7864
|
+
return target;
|
7856
7865
|
}
|
7857
7866
|
function _to_consumable_array$u(arr) {
|
7858
7867
|
return _array_without_holes$u(arr) || _iterable_to_array$u(arr) || _unsupported_iterable_to_array$C(arr) || _non_iterable_spread$u();
|
@@ -7866,7 +7875,7 @@ function _unsupported_iterable_to_array$C(o, minLen) {
|
|
7866
7875
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$C(o, minLen);
|
7867
7876
|
}
|
7868
7877
|
function parseRecordDef(def, refs) {
|
7869
|
-
var _def_keyType, _def_keyType1, _def_keyType__def_checks, _def_keyType2;
|
7878
|
+
var _def_keyType, _def_keyType1, _def_keyType__def_checks, _def_keyType2, _def_keyType3, _def_keyType__def_type__def_checks;
|
7870
7879
|
if (refs.target === "openApi3" && ((_def_keyType = def.keyType) === null || _def_keyType === void 0 ? void 0 : _def_keyType._def.typeName) === ZodFirstPartyTypeKind.ZodEnum) {
|
7871
7880
|
return {
|
7872
7881
|
type: "object",
|
@@ -7896,10 +7905,9 @@ function parseRecordDef(def, refs) {
|
|
7896
7905
|
return schema;
|
7897
7906
|
}
|
7898
7907
|
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)) {
|
7899
|
-
var
|
7900
|
-
|
7901
|
-
|
7902
|
-
}, {});
|
7908
|
+
var _parseStringDef = parseStringDef(def.keyType._def, refs); _parseStringDef.type; var keyType = _object_without_properties$6(_parseStringDef, [
|
7909
|
+
"type"
|
7910
|
+
]);
|
7903
7911
|
return _object_spread_props$p(_object_spread$D({}, schema), {
|
7904
7912
|
propertyNames: keyType
|
7905
7913
|
});
|
@@ -7909,6 +7917,13 @@ function parseRecordDef(def, refs) {
|
|
7909
7917
|
enum: def.keyType._def.values
|
7910
7918
|
}
|
7911
7919
|
});
|
7920
|
+
} 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)) {
|
7921
|
+
var _parseBrandedDef = parseBrandedDef(def.keyType._def, refs); _parseBrandedDef.type; var keyType1 = _object_without_properties$6(_parseBrandedDef, [
|
7922
|
+
"type"
|
7923
|
+
]);
|
7924
|
+
return _object_spread_props$p(_object_spread$D({}, schema), {
|
7925
|
+
propertyNames: keyType1
|
7926
|
+
});
|
7912
7927
|
}
|
7913
7928
|
return schema;
|
7914
7929
|
}
|
@@ -9196,7 +9211,7 @@ var selectParser = function(def, typeName, refs) {
|
|
9196
9211
|
case ZodFirstPartyTypeKind.ZodSymbol:
|
9197
9212
|
return undefined;
|
9198
9213
|
default:
|
9199
|
-
return function(_) {
|
9214
|
+
/* c8 ignore next */ return function(_) {
|
9200
9215
|
return undefined;
|
9201
9216
|
}();
|
9202
9217
|
}
|
@@ -18534,17 +18549,11 @@ var Client = /*#__PURE__*/ function() {
|
|
18534
18549
|
writable: true,
|
18535
18550
|
value: void 0
|
18536
18551
|
});
|
18537
|
-
Object.defineProperty(this, "autoBatchInitialDelayMs", {
|
18538
|
-
enumerable: true,
|
18539
|
-
configurable: true,
|
18540
|
-
writable: true,
|
18541
|
-
value: 250
|
18542
|
-
});
|
18543
18552
|
Object.defineProperty(this, "autoBatchAggregationDelayMs", {
|
18544
18553
|
enumerable: true,
|
18545
18554
|
configurable: true,
|
18546
18555
|
writable: true,
|
18547
|
-
value:
|
18556
|
+
value: 250
|
18548
18557
|
});
|
18549
18558
|
Object.defineProperty(this, "batchSizeBytesLimit", {
|
18550
18559
|
enumerable: true,
|
@@ -19126,11 +19135,10 @@ var Client = /*#__PURE__*/ function() {
|
|
19126
19135
|
value: function processRunOperation(item) {
|
19127
19136
|
var _this = this;
|
19128
19137
|
return _async_to_generator$n(function() {
|
19129
|
-
var
|
19138
|
+
var itemPromise, sizeLimitBytes;
|
19130
19139
|
return _ts_generator$p(this, function(_state) {
|
19131
19140
|
switch(_state.label){
|
19132
19141
|
case 0:
|
19133
|
-
oldTimeout = _this.autoBatchTimeout;
|
19134
19142
|
clearTimeout(_this.autoBatchTimeout);
|
19135
19143
|
_this.autoBatchTimeout = undefined;
|
19136
19144
|
if (item.action === "create") {
|
@@ -19150,7 +19158,7 @@ var Client = /*#__PURE__*/ function() {
|
|
19150
19158
|
_this.autoBatchTimeout = setTimeout(function() {
|
19151
19159
|
_this.autoBatchTimeout = undefined;
|
19152
19160
|
_this.drainAutoBatchQueue(sizeLimitBytes);
|
19153
|
-
},
|
19161
|
+
}, _this.autoBatchAggregationDelayMs);
|
19154
19162
|
}
|
19155
19163
|
return [
|
19156
19164
|
2,
|
@@ -19632,7 +19640,7 @@ var Client = /*#__PURE__*/ function() {
|
|
19632
19640
|
var runCreates = param.runCreates, runUpdates = param.runUpdates;
|
19633
19641
|
var _this = this;
|
19634
19642
|
return _async_to_generator$n(function() {
|
19635
|
-
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,
|
19643
|
+
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;
|
19636
19644
|
return _ts_generator$p(this, function(_state) {
|
19637
19645
|
switch(_state.label){
|
19638
19646
|
case 0:
|
@@ -19766,10 +19774,11 @@ var Client = /*#__PURE__*/ function() {
|
|
19766
19774
|
_ref2 = _step3.value;
|
19767
19775
|
originalPayload = _ref2;
|
19768
19776
|
// collect fields to be sent as separate parts
|
19769
|
-
inputs = originalPayload.inputs, outputs = originalPayload.outputs, events = originalPayload.events, payload = _object_without_properties$4(originalPayload, [
|
19777
|
+
inputs = originalPayload.inputs, outputs = originalPayload.outputs, events = originalPayload.events, attachments = originalPayload.attachments, payload = _object_without_properties$4(originalPayload, [
|
19770
19778
|
"inputs",
|
19771
19779
|
"outputs",
|
19772
|
-
"events"
|
19780
|
+
"events",
|
19781
|
+
"attachments"
|
19773
19782
|
]);
|
19774
19783
|
fields = {
|
19775
19784
|
inputs: inputs,
|
@@ -19820,19 +19829,24 @@ var Client = /*#__PURE__*/ function() {
|
|
19820
19829
|
}
|
19821
19830
|
// encode the attachments
|
19822
19831
|
if (payload.id !== undefined) {
|
19823
|
-
|
19824
|
-
if (
|
19832
|
+
attachments1 = allAttachments[payload.id];
|
19833
|
+
if (attachments1) {
|
19825
19834
|
delete allAttachments[payload.id];
|
19826
19835
|
_iteratorNormalCompletion5 = true, _didIteratorError5 = false, _iteratorError5 = undefined;
|
19827
19836
|
try {
|
19828
|
-
for(_iterator5 = Object.entries(
|
19837
|
+
for(_iterator5 = Object.entries(attachments1)[Symbol.iterator](); !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true){
|
19829
19838
|
_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];
|
19839
|
+
// Validate that the attachment name doesn't contain a '.'
|
19840
|
+
if (name.includes(".")) {
|
19841
|
+
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.");
|
19842
|
+
continue;
|
19843
|
+
}
|
19830
19844
|
accumulatedParts.push({
|
19831
19845
|
name: "attachment.".concat(payload.id, ".").concat(name),
|
19832
19846
|
payload: new Blob([
|
19833
19847
|
content
|
19834
19848
|
], {
|
19835
|
-
type: "".concat(contentType, "; length=").concat(content.
|
19849
|
+
type: "".concat(contentType, "; length=").concat(content.byteLength)
|
19836
19850
|
})
|
19837
19851
|
});
|
19838
19852
|
}
|
@@ -19920,6 +19934,7 @@ var Client = /*#__PURE__*/ function() {
|
|
19920
19934
|
}
|
19921
19935
|
}
|
19922
19936
|
}
|
19937
|
+
// Log the form data
|
19923
19938
|
return [
|
19924
19939
|
4,
|
19925
19940
|
_this.batchIngestCaller.call(_getFetchImplementation(), "".concat(_this.apiUrl, "/runs/multipart"), _object_spread$k({
|
@@ -25657,7 +25672,7 @@ var Client = /*#__PURE__*/ function() {
|
|
25657
25672
|
}();
|
25658
25673
|
|
25659
25674
|
// Update using yarn bump-version
|
25660
|
-
var __version__ = "0.2.
|
25675
|
+
var __version__ = "0.2.4";
|
25661
25676
|
|
25662
25677
|
// Inlined from https://github.com/flexdinesh/browser-or-node
|
25663
25678
|
function _array_like_to_array$g(arr, len) {
|
@@ -26443,6 +26458,15 @@ var RunTree = /*#__PURE__*/ function() {
|
|
26443
26458
|
writable: true,
|
26444
26459
|
value: void 0
|
26445
26460
|
});
|
26461
|
+
/**
|
26462
|
+
* Attachments associated with the run.
|
26463
|
+
* Each entry is a tuple of [mime_type, bytes]
|
26464
|
+
*/ Object.defineProperty(this, "attachments", {
|
26465
|
+
enumerable: true,
|
26466
|
+
configurable: true,
|
26467
|
+
writable: true,
|
26468
|
+
value: void 0
|
26469
|
+
});
|
26446
26470
|
// If you pass in a run tree directly, return a shallow clone
|
26447
26471
|
if (isRunTree(originalConfig)) {
|
26448
26472
|
Object.assign(this, _object_spread$i({}, originalConfig));
|
@@ -26621,7 +26645,8 @@ var RunTree = /*#__PURE__*/ function() {
|
|
26621
26645
|
parent_run_id: parent_run_id,
|
26622
26646
|
trace_id: run.trace_id,
|
26623
26647
|
dotted_order: run.dotted_order,
|
26624
|
-
tags: run.tags
|
26648
|
+
tags: run.tags,
|
26649
|
+
attachments: run.attachments
|
26625
26650
|
};
|
26626
26651
|
return persistedRun;
|
26627
26652
|
}
|
@@ -26763,7 +26788,8 @@ var RunTree = /*#__PURE__*/ function() {
|
|
26763
26788
|
events: _this.events,
|
26764
26789
|
dotted_order: _this.dotted_order,
|
26765
26790
|
trace_id: _this.trace_id,
|
26766
|
-
tags: _this.tags
|
26791
|
+
tags: _this.tags,
|
26792
|
+
attachments: _this.attachments
|
26767
26793
|
};
|
26768
26794
|
return [
|
26769
26795
|
4,
|
@@ -29586,6 +29612,14 @@ var BaseTracer = /*#__PURE__*/ function(BaseCallbackHandler) {
|
|
29586
29612
|
return BaseTracer;
|
29587
29613
|
}(BaseCallbackHandler);
|
29588
29614
|
|
29615
|
+
var TRACING_ALS_KEY = Symbol.for("ls:tracing_async_local_storage");
|
29616
|
+
var setGlobalAsyncLocalStorageInstance = function(instance) {
|
29617
|
+
globalThis[TRACING_ALS_KEY] = instance;
|
29618
|
+
};
|
29619
|
+
var getGlobalAsyncLocalStorageInstance = function() {
|
29620
|
+
return globalThis[TRACING_ALS_KEY];
|
29621
|
+
};
|
29622
|
+
|
29589
29623
|
var ansiStyles = {
|
29590
29624
|
exports: {}
|
29591
29625
|
};
|
@@ -30341,6 +30375,18 @@ var color = styles.color;
|
|
30341
30375
|
return ConsoleCallbackHandler;
|
30342
30376
|
}(BaseTracer);
|
30343
30377
|
|
30378
|
+
var client;
|
30379
|
+
var getDefaultLangChainClientSingleton = function() {
|
30380
|
+
if (client === undefined) {
|
30381
|
+
var clientParams = getEnvironmentVariable("LANGCHAIN_CALLBACKS_BACKGROUND") === "false" ? {
|
30382
|
+
// LangSmith has its own backgrounding system
|
30383
|
+
blockOnRootRunFinalization: true
|
30384
|
+
} : {};
|
30385
|
+
client = new Client(clientParams);
|
30386
|
+
}
|
30387
|
+
return client;
|
30388
|
+
};
|
30389
|
+
|
30344
30390
|
function _array_like_to_array$c(arr, len) {
|
30345
30391
|
if (len == null || len > arr.length) len = arr.length;
|
30346
30392
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
@@ -30696,10 +30742,7 @@ var LangChainTracer = /*#__PURE__*/ function(BaseTracer) {
|
|
30696
30742
|
var _ref;
|
30697
30743
|
_this.projectName = (_ref = projectName !== null && projectName !== void 0 ? projectName : getEnvironmentVariable("LANGCHAIN_PROJECT")) !== null && _ref !== void 0 ? _ref : getEnvironmentVariable("LANGCHAIN_SESSION");
|
30698
30744
|
_this.exampleId = exampleId;
|
30699
|
-
_this.client = client !== null && client !== void 0 ? client :
|
30700
|
-
// LangChain has its own backgrounding system
|
30701
|
-
blockOnRootRunFinalization: true
|
30702
|
-
});
|
30745
|
+
_this.client = client !== null && client !== void 0 ? client : getDefaultLangChainClientSingleton();
|
30703
30746
|
var traceableTree = LangChainTracer.getTraceableRunTree();
|
30704
30747
|
if (traceableTree) {
|
30705
30748
|
_this.updateFromRunTree(traceableTree);
|
@@ -30950,7 +30993,7 @@ var LangChainTracer = /*#__PURE__*/ function(BaseTracer) {
|
|
30950
30993
|
return LangChainTracer;
|
30951
30994
|
}(BaseTracer);
|
30952
30995
|
|
30953
|
-
function asyncGeneratorStep$i(gen, resolve, reject, _next, _throw, key, arg) {
|
30996
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */ function asyncGeneratorStep$i(gen, resolve, reject, _next, _throw, key, arg) {
|
30954
30997
|
try {
|
30955
30998
|
var info = gen[key](arg);
|
30956
30999
|
var value = info.value;
|
@@ -31086,6 +31129,12 @@ var queue;
|
|
31086
31129
|
concurrency: 1
|
31087
31130
|
});
|
31088
31131
|
}
|
31132
|
+
function getQueue() {
|
31133
|
+
if (typeof queue === "undefined") {
|
31134
|
+
queue = createQueue();
|
31135
|
+
}
|
31136
|
+
return queue;
|
31137
|
+
}
|
31089
31138
|
/**
|
31090
31139
|
* Consume a promise, either adding it to the queue or waiting for it to resolve
|
31091
31140
|
* @param promiseFn Promise to consume
|
@@ -31099,26 +31148,87 @@ function _consumeCallback() {
|
|
31099
31148
|
switch(_state.label){
|
31100
31149
|
case 0:
|
31101
31150
|
if (!(wait === true)) return [
|
31151
|
+
3,
|
31152
|
+
5
|
31153
|
+
];
|
31154
|
+
if (!(getGlobalAsyncLocalStorageInstance() !== undefined)) return [
|
31102
31155
|
3,
|
31103
31156
|
2
|
31104
31157
|
];
|
31105
31158
|
return [
|
31106
31159
|
4,
|
31107
|
-
|
31160
|
+
getGlobalAsyncLocalStorageInstance().run(undefined, /*#__PURE__*/ _async_to_generator$i(function() {
|
31161
|
+
return _ts_generator$k(this, function(_state) {
|
31162
|
+
return [
|
31163
|
+
2,
|
31164
|
+
promiseFn()
|
31165
|
+
];
|
31166
|
+
});
|
31167
|
+
}))
|
31108
31168
|
];
|
31109
31169
|
case 1:
|
31110
31170
|
_state.sent();
|
31111
31171
|
return [
|
31112
31172
|
3,
|
31113
|
-
|
31173
|
+
4
|
31114
31174
|
];
|
31115
31175
|
case 2:
|
31116
|
-
|
31117
|
-
|
31118
|
-
|
31119
|
-
|
31120
|
-
_state.label = 3;
|
31176
|
+
return [
|
31177
|
+
4,
|
31178
|
+
promiseFn()
|
31179
|
+
];
|
31121
31180
|
case 3:
|
31181
|
+
_state.sent();
|
31182
|
+
_state.label = 4;
|
31183
|
+
case 4:
|
31184
|
+
return [
|
31185
|
+
3,
|
31186
|
+
6
|
31187
|
+
];
|
31188
|
+
case 5:
|
31189
|
+
queue = getQueue();
|
31190
|
+
void queue.add(/*#__PURE__*/ _async_to_generator$i(function() {
|
31191
|
+
return _ts_generator$k(this, function(_state) {
|
31192
|
+
switch(_state.label){
|
31193
|
+
case 0:
|
31194
|
+
if (!(getGlobalAsyncLocalStorageInstance() !== undefined)) return [
|
31195
|
+
3,
|
31196
|
+
2
|
31197
|
+
];
|
31198
|
+
return [
|
31199
|
+
4,
|
31200
|
+
getGlobalAsyncLocalStorageInstance().run(undefined, /*#__PURE__*/ _async_to_generator$i(function() {
|
31201
|
+
return _ts_generator$k(this, function(_state) {
|
31202
|
+
return [
|
31203
|
+
2,
|
31204
|
+
promiseFn()
|
31205
|
+
];
|
31206
|
+
});
|
31207
|
+
}))
|
31208
|
+
];
|
31209
|
+
case 1:
|
31210
|
+
_state.sent();
|
31211
|
+
return [
|
31212
|
+
3,
|
31213
|
+
4
|
31214
|
+
];
|
31215
|
+
case 2:
|
31216
|
+
return [
|
31217
|
+
4,
|
31218
|
+
promiseFn()
|
31219
|
+
];
|
31220
|
+
case 3:
|
31221
|
+
_state.sent();
|
31222
|
+
_state.label = 4;
|
31223
|
+
case 4:
|
31224
|
+
return [
|
31225
|
+
2
|
31226
|
+
];
|
31227
|
+
}
|
31228
|
+
});
|
31229
|
+
}));
|
31230
|
+
_state.label = 6;
|
31231
|
+
case 6:
|
31122
31232
|
return [
|
31123
31233
|
2
|
31124
31234
|
];
|
@@ -33465,7 +33575,6 @@ var MockAsyncLocalStorage = /*#__PURE__*/ function() {
|
|
33465
33575
|
return MockAsyncLocalStorage;
|
33466
33576
|
}();
|
33467
33577
|
var mockAsyncLocalStorage = new MockAsyncLocalStorage();
|
33468
|
-
var TRACING_ALS_KEY = Symbol.for("ls:tracing_async_local_storage");
|
33469
33578
|
var LC_CHILD_KEY = Symbol.for("lc:child_config");
|
33470
33579
|
var _CONTEXT_VARIABLES_KEY = Symbol.for("lc:context_variables");
|
33471
33580
|
var AsyncLocalStorageProvider = /*#__PURE__*/ function() {
|
@@ -33476,8 +33585,8 @@ var AsyncLocalStorageProvider = /*#__PURE__*/ function() {
|
|
33476
33585
|
{
|
33477
33586
|
key: "getInstance",
|
33478
33587
|
value: function getInstance() {
|
33479
|
-
var
|
33480
|
-
return (
|
33588
|
+
var _getGlobalAsyncLocalStorageInstance;
|
33589
|
+
return (_getGlobalAsyncLocalStorageInstance = getGlobalAsyncLocalStorageInstance()) !== null && _getGlobalAsyncLocalStorageInstance !== void 0 ? _getGlobalAsyncLocalStorageInstance : mockAsyncLocalStorage;
|
33481
33590
|
}
|
33482
33591
|
},
|
33483
33592
|
{
|
@@ -33523,8 +33632,8 @@ var AsyncLocalStorageProvider = /*#__PURE__*/ function() {
|
|
33523
33632
|
{
|
33524
33633
|
key: "initializeGlobalInstance",
|
33525
33634
|
value: function initializeGlobalInstance(instance) {
|
33526
|
-
if (
|
33527
|
-
|
33635
|
+
if (getGlobalAsyncLocalStorageInstance() === undefined) {
|
33636
|
+
setGlobalAsyncLocalStorageInstance(instance);
|
33528
33637
|
}
|
33529
33638
|
}
|
33530
33639
|
}
|
@@ -42854,6 +42963,43 @@ function _coerceToDict(value, defaultKey) {
|
|
42854
42963
|
}(Serializable);
|
42855
42964
|
/**
|
42856
42965
|
* A runnable that delegates calls to another runnable with a set of kwargs.
|
42966
|
+
* @example
|
42967
|
+
* ```typescript
|
42968
|
+
* import {
|
42969
|
+
* type RunnableConfig,
|
42970
|
+
* RunnableLambda,
|
42971
|
+
* } from "@langchain/core/runnables";
|
42972
|
+
*
|
42973
|
+
* const enhanceProfile = (
|
42974
|
+
* profile: Record<string, any>,
|
42975
|
+
* config?: RunnableConfig
|
42976
|
+
* ) => {
|
42977
|
+
* if (config?.configurable?.role) {
|
42978
|
+
* return { ...profile, role: config.configurable.role };
|
42979
|
+
* }
|
42980
|
+
* return profile;
|
42981
|
+
* };
|
42982
|
+
*
|
42983
|
+
* const runnable = RunnableLambda.from(enhanceProfile);
|
42984
|
+
*
|
42985
|
+
* // Bind configuration to the runnable to set the user's role dynamically
|
42986
|
+
* const adminRunnable = runnable.bind({ configurable: { role: "Admin" } });
|
42987
|
+
* const userRunnable = runnable.bind({ configurable: { role: "User" } });
|
42988
|
+
*
|
42989
|
+
* const result1 = await adminRunnable.invoke({
|
42990
|
+
* name: "Alice",
|
42991
|
+
* email: "alice@example.com"
|
42992
|
+
* });
|
42993
|
+
*
|
42994
|
+
* // { name: "Alice", email: "alice@example.com", role: "Admin" }
|
42995
|
+
*
|
42996
|
+
* const result2 = await userRunnable.invoke({
|
42997
|
+
* name: "Bob",
|
42998
|
+
* email: "bob@example.com"
|
42999
|
+
* });
|
43000
|
+
*
|
43001
|
+
* // { name: "Bob", email: "bob@example.com", role: "User" }
|
43002
|
+
* ```
|
42857
43003
|
*/ var RunnableBinding = /*#__PURE__*/ function(Runnable1) {
|
42858
43004
|
_inherits$7(RunnableBinding, Runnable1);
|
42859
43005
|
var _super = _create_super$7(RunnableBinding);
|
@@ -43323,6 +43469,24 @@ function _coerceToDict(value, defaultKey) {
|
|
43323
43469
|
/**
|
43324
43470
|
* A runnable that delegates calls to another runnable
|
43325
43471
|
* with each element of the input sequence.
|
43472
|
+
* @example
|
43473
|
+
* ```typescript
|
43474
|
+
* import { RunnableEach, RunnableLambda } from "@langchain/core/runnables";
|
43475
|
+
*
|
43476
|
+
* const toUpperCase = (input: string): string => input.toUpperCase();
|
43477
|
+
* const addGreeting = (input: string): string => `Hello, ${input}!`;
|
43478
|
+
*
|
43479
|
+
* const upperCaseLambda = RunnableLambda.from(toUpperCase);
|
43480
|
+
* const greetingLambda = RunnableLambda.from(addGreeting);
|
43481
|
+
*
|
43482
|
+
* const chain = new RunnableEach({
|
43483
|
+
* bound: upperCaseLambda.pipe(greetingLambda),
|
43484
|
+
* });
|
43485
|
+
*
|
43486
|
+
* const result = await chain.invoke(["alice", "bob", "carol"])
|
43487
|
+
*
|
43488
|
+
* // ["Hello, ALICE!", "Hello, BOB!", "Hello, CAROL!"]
|
43489
|
+
* ```
|
43326
43490
|
*/ var RunnableEach = /*#__PURE__*/ function(Runnable) {
|
43327
43491
|
_inherits$7(RunnableEach, Runnable);
|
43328
43492
|
var _super = _create_super$7(RunnableEach);
|
@@ -43443,6 +43607,45 @@ function _coerceToDict(value, defaultKey) {
|
|
43443
43607
|
/**
|
43444
43608
|
* Base class for runnables that can be retried a
|
43445
43609
|
* specified number of times.
|
43610
|
+
* @example
|
43611
|
+
* ```typescript
|
43612
|
+
* import {
|
43613
|
+
* RunnableLambda,
|
43614
|
+
* RunnableRetry,
|
43615
|
+
* } from "@langchain/core/runnables";
|
43616
|
+
*
|
43617
|
+
* // Simulate an API call that fails
|
43618
|
+
* const simulateApiCall = (input: string): string => {
|
43619
|
+
* console.log(`Attempting API call with input: ${input}`);
|
43620
|
+
* throw new Error("API call failed due to network issue");
|
43621
|
+
* };
|
43622
|
+
*
|
43623
|
+
* const apiCallLambda = RunnableLambda.from(simulateApiCall);
|
43624
|
+
*
|
43625
|
+
* // Apply retry logic using the .withRetry() method
|
43626
|
+
* const apiCallWithRetry = apiCallLambda.withRetry({ stopAfterAttempt: 3 });
|
43627
|
+
*
|
43628
|
+
* // Alternatively, create a RunnableRetry instance manually
|
43629
|
+
* const manualRetry = new RunnableRetry({
|
43630
|
+
* bound: apiCallLambda,
|
43631
|
+
* maxAttemptNumber: 3,
|
43632
|
+
* config: {},
|
43633
|
+
* });
|
43634
|
+
*
|
43635
|
+
* // Example invocation using the .withRetry() method
|
43636
|
+
* const res = await apiCallWithRetry
|
43637
|
+
* .invoke("Request 1")
|
43638
|
+
* .catch((error) => {
|
43639
|
+
* console.error("Failed after multiple retries:", error.message);
|
43640
|
+
* });
|
43641
|
+
*
|
43642
|
+
* // Example invocation using the manual retry instance
|
43643
|
+
* const res2 = await manualRetry
|
43644
|
+
* .invoke("Request 2")
|
43645
|
+
* .catch((error) => {
|
43646
|
+
* console.error("Failed after multiple retries:", error.message);
|
43647
|
+
* });
|
43648
|
+
* ```
|
43446
43649
|
*/ var RunnableRetry = /*#__PURE__*/ function(RunnableBinding) {
|
43447
43650
|
_inherits$7(RunnableRetry, RunnableBinding);
|
43448
43651
|
var _super = _create_super$7(RunnableRetry);
|
@@ -44856,7 +45059,30 @@ function assertNonTraceableFunction(func) {
|
|
44856
45059
|
}
|
44857
45060
|
}
|
44858
45061
|
/**
|
44859
|
-
* A runnable that
|
45062
|
+
* A runnable that wraps an arbitrary function that takes a single argument.
|
45063
|
+
* @example
|
45064
|
+
* ```typescript
|
45065
|
+
* import { RunnableLambda } from "@langchain/core/runnables";
|
45066
|
+
*
|
45067
|
+
* const add = (input: { x: number; y: number }) => input.x + input.y;
|
45068
|
+
*
|
45069
|
+
* const multiply = (input: { value: number; multiplier: number }) =>
|
45070
|
+
* input.value * input.multiplier;
|
45071
|
+
*
|
45072
|
+
* // Create runnables for the functions
|
45073
|
+
* const addLambda = RunnableLambda.from(add);
|
45074
|
+
* const multiplyLambda = RunnableLambda.from(multiply);
|
45075
|
+
*
|
45076
|
+
* // Chain the lambdas for a mathematical operation
|
45077
|
+
* const chainedLambda = addLambda.pipe((result) =>
|
45078
|
+
* multiplyLambda.invoke({ value: result, multiplier: 2 })
|
45079
|
+
* );
|
45080
|
+
*
|
45081
|
+
* // Example invocation of the chainedLambda
|
45082
|
+
* const result = await chainedLambda.invoke({ x: 2, y: 3 });
|
45083
|
+
*
|
45084
|
+
* // Will log "10" (since (2 + 3) * 2 = 10)
|
45085
|
+
* ```
|
44860
45086
|
*/ var RunnableLambda = /*#__PURE__*/ function(Runnable1) {
|
44861
45087
|
_inherits$7(RunnableLambda, Runnable1);
|
44862
45088
|
var _super = _create_super$7(RunnableLambda);
|
@@ -45634,6 +45860,55 @@ function assertNonTraceableFunction(func) {
|
|
45634
45860
|
* When streaming, fallbacks will only be called on failures during the initial
|
45635
45861
|
* stream creation. Errors that occur after a stream starts will not fallback
|
45636
45862
|
* to the next Runnable.
|
45863
|
+
*
|
45864
|
+
* @example
|
45865
|
+
* ```typescript
|
45866
|
+
* import {
|
45867
|
+
* RunnableLambda,
|
45868
|
+
* RunnableWithFallbacks,
|
45869
|
+
* } from "@langchain/core/runnables";
|
45870
|
+
*
|
45871
|
+
* const primaryOperation = (input: string): string => {
|
45872
|
+
* if (input !== "safe") {
|
45873
|
+
* throw new Error("Primary operation failed due to unsafe input");
|
45874
|
+
* }
|
45875
|
+
* return `Processed: ${input}`;
|
45876
|
+
* };
|
45877
|
+
*
|
45878
|
+
* // Define a fallback operation that processes the input differently
|
45879
|
+
* const fallbackOperation = (input: string): string =>
|
45880
|
+
* `Fallback processed: ${input}`;
|
45881
|
+
*
|
45882
|
+
* const primaryRunnable = RunnableLambda.from(primaryOperation);
|
45883
|
+
* const fallbackRunnable = RunnableLambda.from(fallbackOperation);
|
45884
|
+
*
|
45885
|
+
* // Apply the fallback logic using the .withFallbacks() method
|
45886
|
+
* const runnableWithFallback = primaryRunnable.withFallbacks([fallbackRunnable]);
|
45887
|
+
*
|
45888
|
+
* // Alternatively, create a RunnableWithFallbacks instance manually
|
45889
|
+
* const manualFallbackChain = new RunnableWithFallbacks({
|
45890
|
+
* runnable: primaryRunnable,
|
45891
|
+
* fallbacks: [fallbackRunnable],
|
45892
|
+
* });
|
45893
|
+
*
|
45894
|
+
* // Example invocation using .withFallbacks()
|
45895
|
+
* const res = await runnableWithFallback
|
45896
|
+
* .invoke("unsafe input")
|
45897
|
+
* .catch((error) => {
|
45898
|
+
* console.error("Failed after all attempts:", error.message);
|
45899
|
+
* });
|
45900
|
+
*
|
45901
|
+
* // "Fallback processed: unsafe input"
|
45902
|
+
*
|
45903
|
+
* // Example invocation using manual instantiation
|
45904
|
+
* const res = await manualFallbackChain
|
45905
|
+
* .invoke("safe")
|
45906
|
+
* .catch((error) => {
|
45907
|
+
* console.error("Failed after all attempts:", error.message);
|
45908
|
+
* });
|
45909
|
+
*
|
45910
|
+
* // "Processed: safe"
|
45911
|
+
* ```
|
45637
45912
|
*/ var RunnableWithFallbacks = /*#__PURE__*/ function(Runnable) {
|
45638
45913
|
_inherits$7(RunnableWithFallbacks, Runnable);
|
45639
45914
|
var _super = _create_super$7(RunnableWithFallbacks);
|
@@ -46349,6 +46624,34 @@ function _coerceToRunnable(coerceable) {
|
|
46349
46624
|
}
|
46350
46625
|
/**
|
46351
46626
|
* A runnable that assigns key-value pairs to inputs of type `Record<string, unknown>`.
|
46627
|
+
* @example
|
46628
|
+
* ```typescript
|
46629
|
+
* import {
|
46630
|
+
* RunnableAssign,
|
46631
|
+
* RunnableLambda,
|
46632
|
+
* RunnableParallel,
|
46633
|
+
* } from "@langchain/core/runnables";
|
46634
|
+
*
|
46635
|
+
* const calculateAge = (x: { birthYear: number }): { age: number } => {
|
46636
|
+
* const currentYear = new Date().getFullYear();
|
46637
|
+
* return { age: currentYear - x.birthYear };
|
46638
|
+
* };
|
46639
|
+
*
|
46640
|
+
* const createGreeting = (x: { name: string }): { greeting: string } => {
|
46641
|
+
* return { greeting: `Hello, ${x.name}!` };
|
46642
|
+
* };
|
46643
|
+
*
|
46644
|
+
* const mapper = RunnableParallel.from({
|
46645
|
+
* age_step: RunnableLambda.from(calculateAge),
|
46646
|
+
* greeting_step: RunnableLambda.from(createGreeting),
|
46647
|
+
* });
|
46648
|
+
*
|
46649
|
+
* const runnableAssign = new RunnableAssign({ mapper });
|
46650
|
+
*
|
46651
|
+
* const res = await runnableAssign.invoke({ name: "Alice", birthYear: 1990 });
|
46652
|
+
*
|
46653
|
+
* // { name: "Alice", birthYear: 1990, age_step: { age: 34 }, greeting_step: { greeting: "Hello, Alice!" } }
|
46654
|
+
* ```
|
46352
46655
|
*/ var RunnableAssign = /*#__PURE__*/ function(Runnable) {
|
46353
46656
|
_inherits$7(RunnableAssign, Runnable);
|
46354
46657
|
var _super = _create_super$7(RunnableAssign);
|
@@ -46699,6 +47002,27 @@ function _coerceToRunnable(coerceable) {
|
|
46699
47002
|
}(Runnable);
|
46700
47003
|
/**
|
46701
47004
|
* A runnable that assigns key-value pairs to inputs of type `Record<string, unknown>`.
|
47005
|
+
* Useful for streaming, can be automatically created and chained by calling `runnable.pick();`.
|
47006
|
+
* @example
|
47007
|
+
* ```typescript
|
47008
|
+
* import { RunnablePick } from "@langchain/core/runnables";
|
47009
|
+
*
|
47010
|
+
* const inputData = {
|
47011
|
+
* name: "John",
|
47012
|
+
* age: 30,
|
47013
|
+
* city: "New York",
|
47014
|
+
* country: "USA",
|
47015
|
+
* email: "john.doe@example.com",
|
47016
|
+
* phone: "+1234567890",
|
47017
|
+
* };
|
47018
|
+
*
|
47019
|
+
* const basicInfoRunnable = new RunnablePick(["name", "city"]);
|
47020
|
+
*
|
47021
|
+
* // Example invocation
|
47022
|
+
* const res = await basicInfoRunnable.invoke(inputData);
|
47023
|
+
*
|
47024
|
+
* // { name: 'John', city: 'New York' }
|
47025
|
+
* ```
|
46702
47026
|
*/ var RunnablePick = /*#__PURE__*/ function(Runnable) {
|
46703
47027
|
_inherits$7(RunnablePick, Runnable);
|
46704
47028
|
var _super = _create_super$7(RunnablePick);
|
@@ -48402,11 +48726,23 @@ function getEncodingNameForModel(model) {
|
|
48402
48726
|
case "gpt-4-turbo-preview":
|
48403
48727
|
case "gpt-4-0125-preview":
|
48404
48728
|
case "text-embedding-ada-002":
|
48729
|
+
case "text-embedding-3-small":
|
48730
|
+
case "text-embedding-3-large":
|
48405
48731
|
{
|
48406
48732
|
return "cl100k_base";
|
48407
48733
|
}
|
48408
48734
|
case "gpt-4o":
|
48409
48735
|
case "gpt-4o-2024-05-13":
|
48736
|
+
case "gpt-4o-2024-08-06":
|
48737
|
+
case "gpt-4o-mini-2024-07-18":
|
48738
|
+
case "gpt-4o-mini":
|
48739
|
+
case "o1-mini":
|
48740
|
+
case "o1-preview":
|
48741
|
+
case "o1-preview-2024-09-12":
|
48742
|
+
case "o1-mini-2024-09-12":
|
48743
|
+
case "chatgpt-4o-latest":
|
48744
|
+
case "gpt-4o-realtime":
|
48745
|
+
case "gpt-4o-realtime-preview-2024-10-01":
|
48410
48746
|
{
|
48411
48747
|
return "o200k_base";
|
48412
48748
|
}
|
@@ -50591,9 +50927,11 @@ function _ts_generator$3(thisArg, body) {
|
|
50591
50927
|
{
|
50592
50928
|
key: "getLsParams",
|
50593
50929
|
value: function getLsParams(options) {
|
50930
|
+
var providerName = this.getName().startsWith("Chat") ? this.getName().replace("Chat", "") : this.getName();
|
50594
50931
|
return {
|
50595
50932
|
ls_model_type: "chat",
|
50596
|
-
ls_stop: options.stop
|
50933
|
+
ls_stop: options.stop,
|
50934
|
+
ls_provider: providerName
|
50597
50935
|
};
|
50598
50936
|
}
|
50599
50937
|
},
|
@@ -51341,6 +51679,9 @@ function _ts_generator$3(thisArg, body) {
|
|
51341
51679
|
if (typeof this.bindTools !== "function") {
|
51342
51680
|
throw new Error('Chat model must implement ".bindTools()" to use withStructuredOutput.');
|
51343
51681
|
}
|
51682
|
+
if (config === null || config === void 0 ? void 0 : config.strict) {
|
51683
|
+
throw new Error('"strict" mode is not supported for this model by default.');
|
51684
|
+
}
|
51344
51685
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
51345
51686
|
var schema = outputSchema;
|
51346
51687
|
var name = config === null || config === void 0 ? void 0 : config.name;
|
@@ -53813,6 +54154,9 @@ function _ts_generator(thisArg, body) {
|
|
53813
54154
|
var snakeCasedOption = mapping[key];
|
53814
54155
|
if (snakeCasedOption) {
|
53815
54156
|
snakeCasedOptions[snakeCasedOption] = value;
|
54157
|
+
} else {
|
54158
|
+
// Just pass unknown options through
|
54159
|
+
snakeCasedOptions[key] = value;
|
53816
54160
|
}
|
53817
54161
|
}
|
53818
54162
|
} catch (err) {
|