@huggingface/inference 2.1.2 → 2.1.3-test2

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
@@ -556,6 +556,10 @@ function base64FromBytes(arr) {
556
556
  }
557
557
  }
558
558
 
559
+ // ../shared/src/isBackend.ts
560
+ var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
561
+ var isWebWorker = typeof self === "object" && self.constructor && self.constructor.name === "DedicatedWorkerGlobalScope";
562
+
559
563
  // src/tasks/multimodal/documentQuestionAnswering.ts
560
564
  async function documentQuestionAnswering(args, options) {
561
565
  const reqArgs = {
package/dist/index.mjs CHANGED
@@ -511,6 +511,10 @@ function base64FromBytes(arr) {
511
511
  }
512
512
  }
513
513
 
514
+ // ../shared/src/isBackend.ts
515
+ var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
516
+ var isWebWorker = typeof self === "object" && self.constructor && self.constructor.name === "DedicatedWorkerGlobalScope";
517
+
514
518
  // src/tasks/multimodal/documentQuestionAnswering.ts
515
519
  async function documentQuestionAnswering(args, options) {
516
520
  const reqArgs = {
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "@huggingface/shared",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "main": "src/index.ts",
6
+ "source": "src/index.ts",
7
+ "types": "./src/index.ts"
8
+ }
@@ -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,3 @@
1
+ export * from './base64FromBytes';
2
+ export * from './isBackend';
3
+ export * from './isFrontend';
@@ -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;
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "esModuleInterop": true,
4
+ "noEmit": false,
5
+ "module": "ESNext",
6
+ "target": "ESNext",
7
+ "moduleResolution": "Node",
8
+ "noImplicitAny": true,
9
+ "strict": true,
10
+ "strictNullChecks": true,
11
+ "skipLibCheck": true,
12
+ "composite": true
13
+ }
14
+ }
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-test2",
4
4
  "license": "MIT",
5
5
  "author": "Tim Mikeladze <tim.mikeladze@gmail.com>",
6
6
  "description": "Typescript wrapper for the Hugging Face Inference API",
@@ -40,8 +40,12 @@
40
40
  "@types/node": "18.13.0",
41
41
  "typescript": "^5.0.4",
42
42
  "vite": "^4.1.4",
43
- "vitest": "^0.29.8"
43
+ "vitest": "^0.29.8",
44
+ "@huggingface/shared": "1.0.0"
44
45
  },
46
+ "bundledDependencies": [
47
+ "@huggingface/shared"
48
+ ],
45
49
  "resolutions": {},
46
50
  "scripts": {
47
51
  "build": "tsup src/index.ts --format cjs,esm --clean",
@@ -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 "@huggingface/shared";
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 "@huggingface/shared";
5
5
 
6
6
  export type VisualQuestionAnsweringArgs = BaseArgs & {
7
7
  inputs: {