@huggingface/inference 2.1.2 → 2.1.3-test

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 CHANGED
@@ -543,7 +543,7 @@ async function zeroShotClassification(args, options) {
543
543
  return res;
544
544
  }
545
545
 
546
- // ../shared/src/base64FromBytes.ts
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
- // ../shared/src/base64FromBytes.ts
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huggingface/inference",
3
- "version": "2.1.2",
3
+ "version": "2.1.3-test",
4
4
  "license": "MIT",
5
5
  "author": "Tim Mikeladze <tim.mikeladze@gmail.com>",
6
6
  "description": "Typescript wrapper for the Hugging Face Inference API",
@@ -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 "../../../../shared/src/base64FromBytes";
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 "../../../../shared/src/base64FromBytes";
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;
@@ -0,0 +1,3 @@
1
+ import { isBackend } from "./isBackend";
2
+
3
+ export const isFrontend = !isBackend;