@huggingface/inference 2.1.2 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/tasks/multimodal/documentQuestionAnswering.ts +1 -1
- package/src/tasks/multimodal/visualQuestionAnswering.ts +1 -1
- package/src/utils/base64FromBytes.ts +11 -0
- package/src/utils/isBackend.ts +6 -0
- package/src/utils/isFrontend.ts +3 -0
package/dist/index.js
CHANGED
|
@@ -543,7 +543,7 @@ async function zeroShotClassification(args, options) {
|
|
|
543
543
|
return res;
|
|
544
544
|
}
|
|
545
545
|
|
|
546
|
-
//
|
|
546
|
+
// src/utils/base64FromBytes.ts
|
|
547
547
|
function base64FromBytes(arr) {
|
|
548
548
|
if (globalThis.Buffer) {
|
|
549
549
|
return globalThis.Buffer.from(arr).toString("base64");
|
package/dist/index.mjs
CHANGED
|
@@ -498,7 +498,7 @@ async function zeroShotClassification(args, options) {
|
|
|
498
498
|
return res;
|
|
499
499
|
}
|
|
500
500
|
|
|
501
|
-
//
|
|
501
|
+
// src/utils/base64FromBytes.ts
|
|
502
502
|
function base64FromBytes(arr) {
|
|
503
503
|
if (globalThis.Buffer) {
|
|
504
504
|
return globalThis.Buffer.from(arr).toString("base64");
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import { InferenceOutputError } from "../../lib/InferenceOutputError";
|
|
|
2
2
|
import type { BaseArgs, Options } from "../../types";
|
|
3
3
|
import { request } from "../custom/request";
|
|
4
4
|
import type { RequestArgs } from "../../types";
|
|
5
|
-
import { base64FromBytes } from "
|
|
5
|
+
import { base64FromBytes } from "../../utils/base64FromBytes";
|
|
6
6
|
import { toArray } from "../../utils/toArray";
|
|
7
7
|
|
|
8
8
|
export type DocumentQuestionAnsweringArgs = BaseArgs & {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InferenceOutputError } from "../../lib/InferenceOutputError";
|
|
2
2
|
import type { BaseArgs, Options, RequestArgs } from "../../types";
|
|
3
3
|
import { request } from "../custom/request";
|
|
4
|
-
import { base64FromBytes } from "
|
|
4
|
+
import { base64FromBytes } from "../../utils/base64FromBytes";
|
|
5
5
|
|
|
6
6
|
export type VisualQuestionAnsweringArgs = BaseArgs & {
|
|
7
7
|
inputs: {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function base64FromBytes(arr: Uint8Array): string {
|
|
2
|
+
if (globalThis.Buffer) {
|
|
3
|
+
return globalThis.Buffer.from(arr).toString("base64");
|
|
4
|
+
} else {
|
|
5
|
+
const bin: string[] = [];
|
|
6
|
+
arr.forEach((byte) => {
|
|
7
|
+
bin.push(String.fromCharCode(byte));
|
|
8
|
+
});
|
|
9
|
+
return globalThis.btoa(bin.join(""));
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
2
|
+
|
|
3
|
+
const isWebWorker =
|
|
4
|
+
typeof self === "object" && self.constructor && self.constructor.name === "DedicatedWorkerGlobalScope";
|
|
5
|
+
|
|
6
|
+
export const isBackend = !isBrowser && !isWebWorker;
|