@huggingface/inference 4.13.6 → 4.13.7
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/commonjs/package.d.ts +1 -1
- package/dist/commonjs/package.js +1 -1
- package/dist/commonjs/providers/zai-org.d.ts.map +1 -1
- package/dist/commonjs/providers/zai-org.js +6 -2
- package/dist/esm/package.d.ts +1 -1
- package/dist/esm/package.js +1 -1
- package/dist/esm/providers/zai-org.d.ts.map +1 -1
- package/dist/esm/providers/zai-org.js +7 -3
- package/package.json +1 -1
- package/src/package.ts +1 -1
- package/src/providers/zai-org.ts +13 -3
package/dist/commonjs/package.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PACKAGE_NAME = exports.PACKAGE_VERSION = void 0;
|
|
4
4
|
// Generated file from package.json. Issues importing JSON directly when publishing on commonjs/ESM - see https://github.com/microsoft/TypeScript/issues/51783
|
|
5
|
-
exports.PACKAGE_VERSION = "4.13.
|
|
5
|
+
exports.PACKAGE_VERSION = "4.13.7";
|
|
6
6
|
exports.PACKAGE_NAME = "@huggingface/inference";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zai-org.d.ts","sourceRoot":"","sources":["../../../src/providers/zai-org.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zai-org.d.ts","sourceRoot":"","sources":["../../../src/providers/zai-org.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG5D,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAI7G,qBAAa,qBAAsB,SAAQ,sBAAsB;;IAKvD,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAO7E,SAAS,IAAI,MAAM;CAG5B;AAED,UAAU,sBAAsB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,YAAY,GAAG,SAAS,GAAG,MAAM,CAAC;CAC/C;AAaD,qBAAa,kBAAmB,SAAQ,kBAAmB,YAAW,qBAAqB;;IAKjF,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAYtF,SAAS,IAAI,MAAM;IAInB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IASrD,WAAW,CAChB,QAAQ,EAAE,sBAAsB,EAChC,GAAG,CAAC,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,UAAU,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,GAClC,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CA4FnD"}
|
|
@@ -67,7 +67,9 @@ class ZaiTextToImageTask extends providerHelper_js_1.TaskProviderHelper {
|
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
async getResponse(response, url, headers, outputType) {
|
|
70
|
-
|
|
70
|
+
if (!url || !headers) {
|
|
71
|
+
throw new errors_js_1.InferenceClientInputError(`URL and headers are required for 'text-to-image' task`);
|
|
72
|
+
}
|
|
71
73
|
if (typeof response !== "object" ||
|
|
72
74
|
!response ||
|
|
73
75
|
!("task_status" in response) ||
|
|
@@ -79,7 +81,9 @@ class ZaiTextToImageTask extends providerHelper_js_1.TaskProviderHelper {
|
|
|
79
81
|
throw new errors_js_1.InferenceClientProviderOutputError("ZAI API returned task status: FAIL");
|
|
80
82
|
}
|
|
81
83
|
const taskId = response.id;
|
|
82
|
-
const
|
|
84
|
+
const parsedUrl = new URL(url);
|
|
85
|
+
const baseUrl = `${parsedUrl.protocol}//${parsedUrl.host}${parsedUrl.host === "router.huggingface.co" ? "/zai-org" : ""}`;
|
|
86
|
+
const pollUrl = `${baseUrl}/api/paas/v4/async-result/${taskId}`;
|
|
83
87
|
const pollHeaders = {
|
|
84
88
|
"x-source-channel": "hugging_face",
|
|
85
89
|
"accept-language": "en-US,en",
|
package/dist/esm/package.d.ts
CHANGED
package/dist/esm/package.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Generated file from package.json. Issues importing JSON directly when publishing on commonjs/ESM - see https://github.com/microsoft/TypeScript/issues/51783
|
|
2
|
-
export const PACKAGE_VERSION = "4.13.
|
|
2
|
+
export const PACKAGE_VERSION = "4.13.7";
|
|
3
3
|
export const PACKAGE_NAME = "@huggingface/inference";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zai-org.d.ts","sourceRoot":"","sources":["../../../src/providers/zai-org.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zai-org.d.ts","sourceRoot":"","sources":["../../../src/providers/zai-org.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG5D,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAI7G,qBAAa,qBAAsB,SAAQ,sBAAsB;;IAKvD,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAO7E,SAAS,IAAI,MAAM;CAG5B;AAED,UAAU,sBAAsB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,YAAY,GAAG,SAAS,GAAG,MAAM,CAAC;CAC/C;AAaD,qBAAa,kBAAmB,SAAQ,kBAAmB,YAAW,qBAAqB;;IAKjF,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAYtF,SAAS,IAAI,MAAM;IAInB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IASrD,WAAW,CAChB,QAAQ,EAAE,sBAAsB,EAChC,GAAG,CAAC,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,UAAU,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,GAClC,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CA4FnD"}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* Thanks!
|
|
16
16
|
*/
|
|
17
|
-
import { InferenceClientProviderApiError, InferenceClientProviderOutputError } from "../errors.js";
|
|
17
|
+
import { InferenceClientInputError, InferenceClientProviderApiError, InferenceClientProviderOutputError, } from "../errors.js";
|
|
18
18
|
import { isUrl } from "../lib/isUrl.js";
|
|
19
19
|
import { delay } from "../utils/delay.js";
|
|
20
20
|
import { omit } from "../utils/omit.js";
|
|
@@ -63,7 +63,9 @@ export class ZaiTextToImageTask extends TaskProviderHelper {
|
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
async getResponse(response, url, headers, outputType) {
|
|
66
|
-
|
|
66
|
+
if (!url || !headers) {
|
|
67
|
+
throw new InferenceClientInputError(`URL and headers are required for 'text-to-image' task`);
|
|
68
|
+
}
|
|
67
69
|
if (typeof response !== "object" ||
|
|
68
70
|
!response ||
|
|
69
71
|
!("task_status" in response) ||
|
|
@@ -75,7 +77,9 @@ export class ZaiTextToImageTask extends TaskProviderHelper {
|
|
|
75
77
|
throw new InferenceClientProviderOutputError("ZAI API returned task status: FAIL");
|
|
76
78
|
}
|
|
77
79
|
const taskId = response.id;
|
|
78
|
-
const
|
|
80
|
+
const parsedUrl = new URL(url);
|
|
81
|
+
const baseUrl = `${parsedUrl.protocol}//${parsedUrl.host}${parsedUrl.host === "router.huggingface.co" ? "/zai-org" : ""}`;
|
|
82
|
+
const pollUrl = `${baseUrl}/api/paas/v4/async-result/${taskId}`;
|
|
79
83
|
const pollHeaders = {
|
|
80
84
|
"x-source-channel": "hugging_face",
|
|
81
85
|
"accept-language": "en-US,en",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huggingface/inference",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Hugging Face and Tim Mikeladze <tim.mikeladze@gmail.com>",
|
|
6
6
|
"description": "Typescript client for the Hugging Face Inference Providers and Inference Endpoints",
|
package/src/package.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Generated file from package.json. Issues importing JSON directly when publishing on commonjs/ESM - see https://github.com/microsoft/TypeScript/issues/51783
|
|
2
|
-
export const PACKAGE_VERSION = "4.13.
|
|
2
|
+
export const PACKAGE_VERSION = "4.13.7";
|
|
3
3
|
export const PACKAGE_NAME = "@huggingface/inference";
|
package/src/providers/zai-org.ts
CHANGED
|
@@ -14,7 +14,11 @@
|
|
|
14
14
|
*
|
|
15
15
|
* Thanks!
|
|
16
16
|
*/
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
InferenceClientInputError,
|
|
19
|
+
InferenceClientProviderApiError,
|
|
20
|
+
InferenceClientProviderOutputError,
|
|
21
|
+
} from "../errors.js";
|
|
18
22
|
import { isUrl } from "../lib/isUrl.js";
|
|
19
23
|
import type { BodyParams, HeaderParams } from "../types.js";
|
|
20
24
|
import { delay } from "../utils/delay.js";
|
|
@@ -94,7 +98,9 @@ export class ZaiTextToImageTask extends TaskProviderHelper implements TextToImag
|
|
|
94
98
|
headers?: Record<string, string>,
|
|
95
99
|
outputType?: "url" | "blob" | "json"
|
|
96
100
|
): Promise<string | Blob | Record<string, unknown>> {
|
|
97
|
-
|
|
101
|
+
if (!url || !headers) {
|
|
102
|
+
throw new InferenceClientInputError(`URL and headers are required for 'text-to-image' task`);
|
|
103
|
+
}
|
|
98
104
|
if (
|
|
99
105
|
typeof response !== "object" ||
|
|
100
106
|
!response ||
|
|
@@ -114,7 +120,11 @@ export class ZaiTextToImageTask extends TaskProviderHelper implements TextToImag
|
|
|
114
120
|
}
|
|
115
121
|
|
|
116
122
|
const taskId = response.id;
|
|
117
|
-
const
|
|
123
|
+
const parsedUrl = new URL(url);
|
|
124
|
+
const baseUrl = `${parsedUrl.protocol}//${parsedUrl.host}${
|
|
125
|
+
parsedUrl.host === "router.huggingface.co" ? "/zai-org" : ""
|
|
126
|
+
}`;
|
|
127
|
+
const pollUrl = `${baseUrl}/api/paas/v4/async-result/${taskId}`;
|
|
118
128
|
|
|
119
129
|
const pollHeaders: Record<string, string> = {
|
|
120
130
|
"x-source-channel": "hugging_face",
|