@huggingface/transformers 3.3.2 → 3.3.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/README.md +2 -2
- package/dist/ort-wasm-simd-threaded.jsep.mjs +26 -26
- package/dist/ort-wasm-simd-threaded.jsep.wasm +0 -0
- package/dist/transformers.cjs +64 -9
- package/dist/transformers.cjs.map +1 -1
- package/dist/transformers.js +417 -344
- package/dist/transformers.js.map +1 -1
- package/dist/transformers.min.cjs +1 -1
- package/dist/transformers.min.cjs.map +1 -1
- package/dist/transformers.min.js +1 -1
- package/dist/transformers.min.js.map +1 -1
- package/dist/transformers.min.mjs +1 -1
- package/dist/transformers.min.mjs.map +1 -1
- package/dist/transformers.mjs +64 -9
- package/dist/transformers.mjs.map +1 -1
- package/package.json +3 -3
- package/src/env.js +1 -1
package/dist/transformers.mjs
CHANGED
|
@@ -750,18 +750,19 @@ function parse(tokens) {
|
|
|
750
750
|
return left;
|
|
751
751
|
}
|
|
752
752
|
function parseCallMemberExpression() {
|
|
753
|
-
const member = parseMemberExpression();
|
|
753
|
+
const member = parseMemberExpression(parsePrimaryExpression());
|
|
754
754
|
if (is(TOKEN_TYPES.OpenParen)) {
|
|
755
755
|
return parseCallExpression(member);
|
|
756
756
|
}
|
|
757
757
|
return member;
|
|
758
758
|
}
|
|
759
759
|
function parseCallExpression(callee) {
|
|
760
|
-
let
|
|
760
|
+
let expression = new CallExpression(callee, parseArgs());
|
|
761
|
+
expression = parseMemberExpression(expression);
|
|
761
762
|
if (is(TOKEN_TYPES.OpenParen)) {
|
|
762
|
-
|
|
763
|
+
expression = parseCallExpression(expression);
|
|
763
764
|
}
|
|
764
|
-
return
|
|
765
|
+
return expression;
|
|
765
766
|
}
|
|
766
767
|
function parseArgs() {
|
|
767
768
|
expect(TOKEN_TYPES.OpenParen, "Expected opening parenthesis for arguments list");
|
|
@@ -815,8 +816,7 @@ function parse(tokens) {
|
|
|
815
816
|
}
|
|
816
817
|
return slices[0];
|
|
817
818
|
}
|
|
818
|
-
function parseMemberExpression() {
|
|
819
|
-
let object = parsePrimaryExpression();
|
|
819
|
+
function parseMemberExpression(object) {
|
|
820
820
|
while (is(TOKEN_TYPES.Dot) || is(TOKEN_TYPES.OpenSquareBracket)) {
|
|
821
821
|
const operator = tokens[current];
|
|
822
822
|
++current;
|
|
@@ -1041,6 +1041,41 @@ var StringValue = class extends RuntimeValue {
|
|
|
1041
1041
|
new FunctionValue(() => {
|
|
1042
1042
|
return new StringValue(this.value.trimStart());
|
|
1043
1043
|
})
|
|
1044
|
+
],
|
|
1045
|
+
[
|
|
1046
|
+
"split",
|
|
1047
|
+
// follows Python's `str.split(sep=None, maxsplit=-1)` function behavior
|
|
1048
|
+
// https://docs.python.org/3.13/library/stdtypes.html#str.split
|
|
1049
|
+
new FunctionValue((args) => {
|
|
1050
|
+
const sep = args[0] ?? new NullValue();
|
|
1051
|
+
if (!(sep instanceof StringValue || sep instanceof NullValue)) {
|
|
1052
|
+
throw new Error("sep argument must be a string or null");
|
|
1053
|
+
}
|
|
1054
|
+
const maxsplit = args[1] ?? new NumericValue(-1);
|
|
1055
|
+
if (!(maxsplit instanceof NumericValue)) {
|
|
1056
|
+
throw new Error("maxsplit argument must be a number");
|
|
1057
|
+
}
|
|
1058
|
+
let result = [];
|
|
1059
|
+
if (sep instanceof NullValue) {
|
|
1060
|
+
const text = this.value.trimStart();
|
|
1061
|
+
for (const { 0: match, index } of text.matchAll(/\S+/g)) {
|
|
1062
|
+
if (maxsplit.value !== -1 && result.length >= maxsplit.value && index !== void 0) {
|
|
1063
|
+
result.push(match + text.slice(index + match.length));
|
|
1064
|
+
break;
|
|
1065
|
+
}
|
|
1066
|
+
result.push(match);
|
|
1067
|
+
}
|
|
1068
|
+
} else {
|
|
1069
|
+
if (sep.value === "") {
|
|
1070
|
+
throw new Error("empty separator");
|
|
1071
|
+
}
|
|
1072
|
+
result = this.value.split(sep.value);
|
|
1073
|
+
if (maxsplit.value !== -1 && result.length > maxsplit.value) {
|
|
1074
|
+
result.push(result.splice(maxsplit.value).join(sep.value));
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
return new ArrayValue(result.map((part) => new StringValue(part)));
|
|
1078
|
+
})
|
|
1044
1079
|
]
|
|
1045
1080
|
]);
|
|
1046
1081
|
};
|
|
@@ -1377,6 +1412,8 @@ var Interpreter = class {
|
|
|
1377
1412
|
}
|
|
1378
1413
|
})
|
|
1379
1414
|
);
|
|
1415
|
+
case "join":
|
|
1416
|
+
return new StringValue(operand.value.map((x) => x.value).join(""));
|
|
1380
1417
|
default:
|
|
1381
1418
|
throw new Error(`Unknown ArrayValue filter: ${filter.value}`);
|
|
1382
1419
|
}
|
|
@@ -1403,6 +1440,7 @@ var Interpreter = class {
|
|
|
1403
1440
|
)
|
|
1404
1441
|
).join("\n")
|
|
1405
1442
|
);
|
|
1443
|
+
case "join":
|
|
1406
1444
|
case "string":
|
|
1407
1445
|
return operand;
|
|
1408
1446
|
default:
|
|
@@ -1441,6 +1479,21 @@ var Interpreter = class {
|
|
|
1441
1479
|
throw new Error("If set, indent must be a number");
|
|
1442
1480
|
}
|
|
1443
1481
|
return new StringValue(toJSON(operand, indent.value));
|
|
1482
|
+
} else if (filterName === "join") {
|
|
1483
|
+
let value;
|
|
1484
|
+
if (operand instanceof StringValue) {
|
|
1485
|
+
value = Array.from(operand.value);
|
|
1486
|
+
} else if (operand instanceof ArrayValue) {
|
|
1487
|
+
value = operand.value.map((x) => x.value);
|
|
1488
|
+
} else {
|
|
1489
|
+
throw new Error(`Cannot apply filter "${filterName}" to type: ${operand.type}`);
|
|
1490
|
+
}
|
|
1491
|
+
const [args, kwargs] = this.evaluateArguments(filter.args, environment);
|
|
1492
|
+
const separator = args.at(0) ?? kwargs.get("separator") ?? new StringValue("");
|
|
1493
|
+
if (!(separator instanceof StringValue)) {
|
|
1494
|
+
throw new Error("separator must be a string");
|
|
1495
|
+
}
|
|
1496
|
+
return new StringValue(value.join(separator.value));
|
|
1444
1497
|
}
|
|
1445
1498
|
if (operand instanceof ArrayValue) {
|
|
1446
1499
|
switch (filterName) {
|
|
@@ -1902,8 +1955,10 @@ var Template = class {
|
|
|
1902
1955
|
throw new Error(args);
|
|
1903
1956
|
});
|
|
1904
1957
|
env.set("range", range);
|
|
1905
|
-
|
|
1906
|
-
|
|
1958
|
+
if (items) {
|
|
1959
|
+
for (const [key, value] of Object.entries(items)) {
|
|
1960
|
+
env.set(key, value);
|
|
1961
|
+
}
|
|
1907
1962
|
}
|
|
1908
1963
|
const interpreter = new Interpreter(env);
|
|
1909
1964
|
const result = interpreter.run(this.parsed);
|
|
@@ -5947,7 +6002,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
5947
6002
|
|
|
5948
6003
|
|
|
5949
6004
|
|
|
5950
|
-
const VERSION = '3.3.
|
|
6005
|
+
const VERSION = '3.3.3';
|
|
5951
6006
|
|
|
5952
6007
|
// Check if various APIs are available (depends on environment)
|
|
5953
6008
|
const IS_BROWSER_ENV = typeof window !== "undefined" && typeof window.document !== "undefined";
|