@huggingface/inference 4.8.0 → 4.9.0
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 -0
- package/dist/commonjs/lib/getProviderHelper.d.ts.map +1 -1
- package/dist/commonjs/lib/getProviderHelper.js +4 -0
- package/dist/commonjs/package.d.ts +1 -1
- package/dist/commonjs/package.js +1 -1
- package/dist/commonjs/providers/consts.d.ts.map +1 -1
- package/dist/commonjs/providers/consts.js +1 -0
- package/dist/commonjs/providers/zai-org.d.ts +24 -0
- package/dist/commonjs/providers/zai-org.d.ts.map +1 -0
- package/dist/commonjs/providers/zai-org.js +36 -0
- package/dist/commonjs/types.d.ts +2 -2
- package/dist/commonjs/types.d.ts.map +1 -1
- package/dist/commonjs/types.js +1 -0
- package/dist/esm/lib/getProviderHelper.d.ts.map +1 -1
- package/dist/esm/lib/getProviderHelper.js +4 -0
- package/dist/esm/package.d.ts +1 -1
- package/dist/esm/package.js +1 -1
- package/dist/esm/providers/consts.d.ts.map +1 -1
- package/dist/esm/providers/consts.js +1 -0
- package/dist/esm/providers/zai-org.d.ts +24 -0
- package/dist/esm/providers/zai-org.d.ts.map +1 -0
- package/dist/esm/providers/zai-org.js +32 -0
- package/dist/esm/types.d.ts +2 -2
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js +1 -0
- package/package.json +2 -2
- package/src/lib/getProviderHelper.ts +4 -0
- package/src/package.ts +1 -1
- package/src/providers/consts.ts +1 -0
- package/src/providers/zai-org.ts +37 -0
- package/src/types.ts +1 -0
package/README.md
CHANGED
|
@@ -65,6 +65,7 @@ Currently, we support the following providers:
|
|
|
65
65
|
- [Cohere](https://cohere.com)
|
|
66
66
|
- [Cerebras](https://cerebras.ai/)
|
|
67
67
|
- [Groq](https://groq.com)
|
|
68
|
+
- [Z.ai](https://z.ai/)
|
|
68
69
|
|
|
69
70
|
To send requests to a third-party provider, you have to pass the `provider` parameter to the inference function. The default value of the `provider` parameter is "auto", which will select the first of the providers available for the model, sorted by your preferred order in https://hf.co/settings/inference-providers.
|
|
70
71
|
|
|
@@ -100,6 +101,7 @@ Only a subset of models are supported when requesting third-party providers. You
|
|
|
100
101
|
- [Cerebras supported models](https://huggingface.co/api/partners/cerebras/models)
|
|
101
102
|
- [Groq supported models](https://console.groq.com/docs/models)
|
|
102
103
|
- [Novita AI supported models](https://huggingface.co/api/partners/novita/models)
|
|
104
|
+
- [Z.ai supported models](https://huggingface.co/api/partners/zai-org/models)
|
|
103
105
|
|
|
104
106
|
❗**Important note:** To be compatible, the third-party API must adhere to the "standard" shape API we expect on HF model pages for each pipeline task type.
|
|
105
107
|
This is not an issue for LLMs as everyone converged on the OpenAI API anyways, but can be more tricky for other tasks like "text-to-image" or "automatic-speech-recognition" where there exists no standard API. Let us know if any help is needed or if we can make things easier for you!
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getProviderHelper.d.ts","sourceRoot":"","sources":["../../../src/lib/getProviderHelper.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACX,6BAA6B,EAC7B,sBAAsB,EACtB,oCAAoC,EACpC,wBAAwB,EACxB,mCAAmC,EACnC,2BAA2B,EAC3B,kBAAkB,EAClB,6BAA6B,EAC7B,2BAA2B,EAC3B,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,EACzB,2BAA2B,EAC3B,4BAA4B,EAC5B,uBAAuB,EACvB,gCAAgC,EAChC,+BAA+B,EAC/B,2BAA2B,EAC3B,kBAAkB,EAClB,4BAA4B,EAC5B,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,6BAA6B,EAC7B,qBAAqB,EACrB,iCAAiC,EACjC,gCAAgC,EAChC,qCAAqC,EACrC,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"getProviderHelper.d.ts","sourceRoot":"","sources":["../../../src/lib/getProviderHelper.ts"],"names":[],"m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yB,EACnC,IAAI,EAAE,sBAAsB,GAC1B,6BAA6B,GAAG,kBAAkB,CAAC;AACtD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,aAAa,GACjB,qBAAqB,GAAG,kBAAkB,CAAC;AAC9C,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,eAAe,GACnB,uBAAuB,GAAG,kBAAkB,CAAC;AAChD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,2BAA2B,GAC/B,iCAAiC,GAAG,kBAAkB,CAAC;AAC1D,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,aAAa,GAAG,SAAS,GAC7B,kBAAkB,CAAC"}
|
|
@@ -54,6 +54,7 @@ const Replicate = __importStar(require("../providers/replicate.js"));
|
|
|
54
54
|
const Sambanova = __importStar(require("../providers/sambanova.js"));
|
|
55
55
|
const Scaleway = __importStar(require("../providers/scaleway.js"));
|
|
56
56
|
const Together = __importStar(require("../providers/together.js"));
|
|
57
|
+
const Zai = __importStar(require("../providers/zai-org.js"));
|
|
57
58
|
const errors_js_1 = require("../errors.js");
|
|
58
59
|
exports.PROVIDERS = {
|
|
59
60
|
"black-forest-labs": {
|
|
@@ -166,6 +167,9 @@ exports.PROVIDERS = {
|
|
|
166
167
|
conversational: new Together.TogetherConversationalTask(),
|
|
167
168
|
"text-generation": new Together.TogetherTextGenerationTask(),
|
|
168
169
|
},
|
|
170
|
+
"zai-org": {
|
|
171
|
+
conversational: new Zai.ZaiConversationalTask(),
|
|
172
|
+
},
|
|
169
173
|
};
|
|
170
174
|
function getProviderHelper(provider, task) {
|
|
171
175
|
if ((provider === "hf-inference" && !task) || provider === "auto") {
|
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.
|
|
5
|
+
exports.PACKAGE_VERSION = "4.9.0";
|
|
6
6
|
exports.PACKAGE_NAME = "@huggingface/inference";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../src/providers/consts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,EAAE,MAAM,CACrD,iBAAiB,EACjB,MAAM,CAAC,OAAO,EAAE,6BAA6B,CAAC,
|
|
1
|
+
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../src/providers/consts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,EAAE,MAAM,CACrD,iBAAiB,EACjB,MAAM,CAAC,OAAO,EAAE,6BAA6B,CAAC,CA4B9C,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* See the registered mapping of HF model ID => ZAI model ID here:
|
|
3
|
+
*
|
|
4
|
+
* https://huggingface.co/api/partners/zai-org/models
|
|
5
|
+
*
|
|
6
|
+
* This is a publicly available mapping.
|
|
7
|
+
*
|
|
8
|
+
* If you want to try to run inference for a new model locally before it's registered on huggingface.co,
|
|
9
|
+
* you can add it to the dictionary "HARDCODED_MODEL_ID_MAPPING" in consts.ts, for dev purposes.
|
|
10
|
+
*
|
|
11
|
+
* - If you work at zai and want to update this mapping, please use the model mapping API we provide on huggingface.co
|
|
12
|
+
* - If you're a community member and want to add a new supported HF model to zai, please open an issue on the present repo
|
|
13
|
+
* and we will tag zai team members.
|
|
14
|
+
*
|
|
15
|
+
* Thanks!
|
|
16
|
+
*/
|
|
17
|
+
import { BaseConversationalTask } from "./providerHelper.js";
|
|
18
|
+
import type { HeaderParams } from "../types.js";
|
|
19
|
+
export declare class ZaiConversationalTask extends BaseConversationalTask {
|
|
20
|
+
constructor();
|
|
21
|
+
prepareHeaders(params: HeaderParams, binary: boolean): Record<string, string>;
|
|
22
|
+
makeRoute(): string;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=zai-org.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zai-org.d.ts","sourceRoot":"","sources":["../../../src/providers/zai-org.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD,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"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZaiConversationalTask = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* See the registered mapping of HF model ID => ZAI model ID here:
|
|
6
|
+
*
|
|
7
|
+
* https://huggingface.co/api/partners/zai-org/models
|
|
8
|
+
*
|
|
9
|
+
* This is a publicly available mapping.
|
|
10
|
+
*
|
|
11
|
+
* If you want to try to run inference for a new model locally before it's registered on huggingface.co,
|
|
12
|
+
* you can add it to the dictionary "HARDCODED_MODEL_ID_MAPPING" in consts.ts, for dev purposes.
|
|
13
|
+
*
|
|
14
|
+
* - If you work at zai and want to update this mapping, please use the model mapping API we provide on huggingface.co
|
|
15
|
+
* - If you're a community member and want to add a new supported HF model to zai, please open an issue on the present repo
|
|
16
|
+
* and we will tag zai team members.
|
|
17
|
+
*
|
|
18
|
+
* Thanks!
|
|
19
|
+
*/
|
|
20
|
+
const providerHelper_js_1 = require("./providerHelper.js");
|
|
21
|
+
const ZAI_API_BASE_URL = "https://api.z.ai";
|
|
22
|
+
class ZaiConversationalTask extends providerHelper_js_1.BaseConversationalTask {
|
|
23
|
+
constructor() {
|
|
24
|
+
super("zai-org", ZAI_API_BASE_URL);
|
|
25
|
+
}
|
|
26
|
+
prepareHeaders(params, binary) {
|
|
27
|
+
const headers = super.prepareHeaders(params, binary);
|
|
28
|
+
headers["x-source-channel"] = "hugging_face";
|
|
29
|
+
headers["accept-language"] = "en-US,en";
|
|
30
|
+
return headers;
|
|
31
|
+
}
|
|
32
|
+
makeRoute() {
|
|
33
|
+
return "/api/paas/v4/chat/completions";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.ZaiConversationalTask = ZaiConversationalTask;
|
package/dist/commonjs/types.d.ts
CHANGED
|
@@ -36,8 +36,8 @@ export interface Options {
|
|
|
36
36
|
billTo?: string;
|
|
37
37
|
}
|
|
38
38
|
export type InferenceTask = Exclude<PipelineType, "other"> | "conversational";
|
|
39
|
-
export declare const INFERENCE_PROVIDERS: readonly ["black-forest-labs", "cerebras", "cohere", "fal-ai", "featherless-ai", "fireworks-ai", "groq", "hf-inference", "hyperbolic", "nebius", "novita", "nscale", "openai", "ovhcloud", "publicai", "replicate", "sambanova", "scaleway", "together"];
|
|
40
|
-
export declare const PROVIDERS_OR_POLICIES: readonly ["black-forest-labs", "cerebras", "cohere", "fal-ai", "featherless-ai", "fireworks-ai", "groq", "hf-inference", "hyperbolic", "nebius", "novita", "nscale", "openai", "ovhcloud", "publicai", "replicate", "sambanova", "scaleway", "together", "auto"];
|
|
39
|
+
export declare const INFERENCE_PROVIDERS: readonly ["black-forest-labs", "cerebras", "cohere", "fal-ai", "featherless-ai", "fireworks-ai", "groq", "hf-inference", "hyperbolic", "nebius", "novita", "nscale", "openai", "ovhcloud", "publicai", "replicate", "sambanova", "scaleway", "together", "zai-org"];
|
|
40
|
+
export declare const PROVIDERS_OR_POLICIES: readonly ["black-forest-labs", "cerebras", "cohere", "fal-ai", "featherless-ai", "fireworks-ai", "groq", "hf-inference", "hyperbolic", "nebius", "novita", "nscale", "openai", "ovhcloud", "publicai", "replicate", "sambanova", "scaleway", "together", "zai-org", "auto"];
|
|
41
41
|
export type InferenceProvider = (typeof INFERENCE_PROVIDERS)[number];
|
|
42
42
|
export type InferenceProviderOrPolicy = (typeof PROVIDERS_OR_POLICIES)[number];
|
|
43
43
|
export interface InferenceProviderMappingEntry {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAExF;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAE7B,MAAM,WAAW,MAAM;IACtB,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACrD,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACpD,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACpD,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACrD,GAAG,EA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ACG;IAAE,IAAI,EAAE,IAAI,GAAG,WAAW,CAAA;CAAE,GAC5B;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,GACnB;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GACrB,mBAAmB,CACrB,GAAG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,qBAAqB,GAAG,cAAc,CAAC;AAEtF,MAAM,WAAW,YAAY;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,UAAU,CAAC;CACvB;AAED,MAAM,WAAW,SAAS;IACzB,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACtF,IAAI,EAAE,CAAC,CAAC;IACR,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,6BAA6B,GAAG,SAAS,CAAC;IACpD,IAAI,CAAC,EAAE,aAAa,CAAC;CACrB"}
|
package/dist/commonjs/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getProviderHelper.d.ts","sourceRoot":"","sources":["../../../src/lib/getProviderHelper.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACX,6BAA6B,EAC7B,sBAAsB,EACtB,oCAAoC,EACpC,wBAAwB,EACxB,mCAAmC,EACnC,2BAA2B,EAC3B,kBAAkB,EAClB,6BAA6B,EAC7B,2BAA2B,EAC3B,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,EACzB,2BAA2B,EAC3B,4BAA4B,EAC5B,uBAAuB,EACvB,gCAAgC,EAChC,+BAA+B,EAC/B,2BAA2B,EAC3B,kBAAkB,EAClB,4BAA4B,EAC5B,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,6BAA6B,EAC7B,qBAAqB,EACrB,iCAAiC,EACjC,gCAAgC,EAChC,qCAAqC,EACrC,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"getProviderHelper.d.ts","sourceRoot":"","sources":["../../../src/lib/getProviderHelper.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACX,6BAA6B,EAC7B,sBAAsB,EACtB,oCAAoC,EACpC,wBAAwB,EACxB,mCAAmC,EACnC,2BAA2B,EAC3B,kBAAkB,EAClB,6BAA6B,EAC7B,2BAA2B,EAC3B,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,EACzB,2BAA2B,EAC3B,4BAA4B,EAC5B,uBAAuB,EACvB,gCAAgC,EAChC,+BAA+B,EAC/B,2BAA2B,EAC3B,kBAAkB,EAClB,4BAA4B,EAC5B,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,6BAA6B,EAC7B,qBAAqB,EACrB,iCAAiC,EACjC,gCAAgC,EAChC,qCAAqC,EACrC,MAAM,gCAAgC,CAAC;AAMxC,OAAO,KAAK,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG/F,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,iBAAiB,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC,CAkHnG,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,eAAe,GACnB,qBAAqB,GAAG,kBAAk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BAAkB,CAAC;AACrD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,0BAA0B,GAC9B,gCAAgC,GAAG,kBAAkB,CAAC;AACzD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,wBAAwB,GAC5B,+BAA+B,GAAG,kBAAkB,CAAC;AACxD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,oBAAoB,GACxB,2BAA2B,GAAG,kBAAkB,CAAC;AACpD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,sBAAsB,GAC1B,6BAA6B,GAAG,kBAAkB,CAAC;AACtD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,aAAa,GACjB,qBAAqB,GAAG,kBAAkB,CAAC;AAC9C,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,eAAe,GACnB,uBAAuB,GAAG,kBAAkB,CAAC;AAChD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,2BAA2B,GAC/B,iCAAiC,GAAG,kBAAkB,CAAC;AAC1D,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,aAAa,GAAG,SAAS,GAC7B,kBAAkB,CAAC"}
|
|
@@ -17,6 +17,7 @@ import * as Replicate from "../providers/replicate.js";
|
|
|
17
17
|
import * as Sambanova from "../providers/sambanova.js";
|
|
18
18
|
import * as Scaleway from "../providers/scaleway.js";
|
|
19
19
|
import * as Together from "../providers/together.js";
|
|
20
|
+
import * as Zai from "../providers/zai-org.js";
|
|
20
21
|
import { InferenceClientInputError } from "../errors.js";
|
|
21
22
|
export const PROVIDERS = {
|
|
22
23
|
"black-forest-labs": {
|
|
@@ -129,6 +130,9 @@ export const PROVIDERS = {
|
|
|
129
130
|
conversational: new Together.TogetherConversationalTask(),
|
|
130
131
|
"text-generation": new Together.TogetherTextGenerationTask(),
|
|
131
132
|
},
|
|
133
|
+
"zai-org": {
|
|
134
|
+
conversational: new Zai.ZaiConversationalTask(),
|
|
135
|
+
},
|
|
132
136
|
};
|
|
133
137
|
export function getProviderHelper(provider, task) {
|
|
134
138
|
if ((provider === "hf-inference" && !task) || provider === "auto") {
|
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.
|
|
2
|
+
export const PACKAGE_VERSION = "4.9.0";
|
|
3
3
|
export const PACKAGE_NAME = "@huggingface/inference";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../src/providers/consts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,EAAE,MAAM,CACrD,iBAAiB,EACjB,MAAM,CAAC,OAAO,EAAE,6BAA6B,CAAC,
|
|
1
|
+
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../src/providers/consts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,EAAE,MAAM,CACrD,iBAAiB,EACjB,MAAM,CAAC,OAAO,EAAE,6BAA6B,CAAC,CA4B9C,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* See the registered mapping of HF model ID => ZAI model ID here:
|
|
3
|
+
*
|
|
4
|
+
* https://huggingface.co/api/partners/zai-org/models
|
|
5
|
+
*
|
|
6
|
+
* This is a publicly available mapping.
|
|
7
|
+
*
|
|
8
|
+
* If you want to try to run inference for a new model locally before it's registered on huggingface.co,
|
|
9
|
+
* you can add it to the dictionary "HARDCODED_MODEL_ID_MAPPING" in consts.ts, for dev purposes.
|
|
10
|
+
*
|
|
11
|
+
* - If you work at zai and want to update this mapping, please use the model mapping API we provide on huggingface.co
|
|
12
|
+
* - If you're a community member and want to add a new supported HF model to zai, please open an issue on the present repo
|
|
13
|
+
* and we will tag zai team members.
|
|
14
|
+
*
|
|
15
|
+
* Thanks!
|
|
16
|
+
*/
|
|
17
|
+
import { BaseConversationalTask } from "./providerHelper.js";
|
|
18
|
+
import type { HeaderParams } from "../types.js";
|
|
19
|
+
export declare class ZaiConversationalTask extends BaseConversationalTask {
|
|
20
|
+
constructor();
|
|
21
|
+
prepareHeaders(params: HeaderParams, binary: boolean): Record<string, string>;
|
|
22
|
+
makeRoute(): string;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=zai-org.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zai-org.d.ts","sourceRoot":"","sources":["../../../src/providers/zai-org.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD,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"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* See the registered mapping of HF model ID => ZAI model ID here:
|
|
3
|
+
*
|
|
4
|
+
* https://huggingface.co/api/partners/zai-org/models
|
|
5
|
+
*
|
|
6
|
+
* This is a publicly available mapping.
|
|
7
|
+
*
|
|
8
|
+
* If you want to try to run inference for a new model locally before it's registered on huggingface.co,
|
|
9
|
+
* you can add it to the dictionary "HARDCODED_MODEL_ID_MAPPING" in consts.ts, for dev purposes.
|
|
10
|
+
*
|
|
11
|
+
* - If you work at zai and want to update this mapping, please use the model mapping API we provide on huggingface.co
|
|
12
|
+
* - If you're a community member and want to add a new supported HF model to zai, please open an issue on the present repo
|
|
13
|
+
* and we will tag zai team members.
|
|
14
|
+
*
|
|
15
|
+
* Thanks!
|
|
16
|
+
*/
|
|
17
|
+
import { BaseConversationalTask } from "./providerHelper.js";
|
|
18
|
+
const ZAI_API_BASE_URL = "https://api.z.ai";
|
|
19
|
+
export class ZaiConversationalTask extends BaseConversationalTask {
|
|
20
|
+
constructor() {
|
|
21
|
+
super("zai-org", ZAI_API_BASE_URL);
|
|
22
|
+
}
|
|
23
|
+
prepareHeaders(params, binary) {
|
|
24
|
+
const headers = super.prepareHeaders(params, binary);
|
|
25
|
+
headers["x-source-channel"] = "hugging_face";
|
|
26
|
+
headers["accept-language"] = "en-US,en";
|
|
27
|
+
return headers;
|
|
28
|
+
}
|
|
29
|
+
makeRoute() {
|
|
30
|
+
return "/api/paas/v4/chat/completions";
|
|
31
|
+
}
|
|
32
|
+
}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -36,8 +36,8 @@ export interface Options {
|
|
|
36
36
|
billTo?: string;
|
|
37
37
|
}
|
|
38
38
|
export type InferenceTask = Exclude<PipelineType, "other"> | "conversational";
|
|
39
|
-
export declare const INFERENCE_PROVIDERS: readonly ["black-forest-labs", "cerebras", "cohere", "fal-ai", "featherless-ai", "fireworks-ai", "groq", "hf-inference", "hyperbolic", "nebius", "novita", "nscale", "openai", "ovhcloud", "publicai", "replicate", "sambanova", "scaleway", "together"];
|
|
40
|
-
export declare const PROVIDERS_OR_POLICIES: readonly ["black-forest-labs", "cerebras", "cohere", "fal-ai", "featherless-ai", "fireworks-ai", "groq", "hf-inference", "hyperbolic", "nebius", "novita", "nscale", "openai", "ovhcloud", "publicai", "replicate", "sambanova", "scaleway", "together", "auto"];
|
|
39
|
+
export declare const INFERENCE_PROVIDERS: readonly ["black-forest-labs", "cerebras", "cohere", "fal-ai", "featherless-ai", "fireworks-ai", "groq", "hf-inference", "hyperbolic", "nebius", "novita", "nscale", "openai", "ovhcloud", "publicai", "replicate", "sambanova", "scaleway", "together", "zai-org"];
|
|
40
|
+
export declare const PROVIDERS_OR_POLICIES: readonly ["black-forest-labs", "cerebras", "cohere", "fal-ai", "featherless-ai", "fireworks-ai", "groq", "hf-inference", "hyperbolic", "nebius", "novita", "nscale", "openai", "ovhcloud", "publicai", "replicate", "sambanova", "scaleway", "together", "zai-org", "auto"];
|
|
41
41
|
export type InferenceProvider = (typeof INFERENCE_PROVIDERS)[number];
|
|
42
42
|
export type InferenceProviderOrPolicy = (typeof PROVIDERS_OR_POLICIES)[number];
|
|
43
43
|
export interface InferenceProviderMappingEntry {
|
package/dist/esm/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAExF;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAE7B,MAAM,WAAW,MAAM;IACtB,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACrD,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACpD,IAAI,EAAE,CAAC,OAAO,EAAE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
|
"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",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"type": "module",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@huggingface/tasks": "^0.19.
|
|
43
|
+
"@huggingface/tasks": "^0.19.48",
|
|
44
44
|
"@huggingface/jinja": "^0.5.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
@@ -50,6 +50,7 @@ import * as Replicate from "../providers/replicate.js";
|
|
|
50
50
|
import * as Sambanova from "../providers/sambanova.js";
|
|
51
51
|
import * as Scaleway from "../providers/scaleway.js";
|
|
52
52
|
import * as Together from "../providers/together.js";
|
|
53
|
+
import * as Zai from "../providers/zai-org.js";
|
|
53
54
|
import type { InferenceProvider, InferenceProviderOrPolicy, InferenceTask } from "../types.js";
|
|
54
55
|
import { InferenceClientInputError } from "../errors.js";
|
|
55
56
|
|
|
@@ -164,6 +165,9 @@ export const PROVIDERS: Record<InferenceProvider, Partial<Record<InferenceTask,
|
|
|
164
165
|
conversational: new Together.TogetherConversationalTask(),
|
|
165
166
|
"text-generation": new Together.TogetherTextGenerationTask(),
|
|
166
167
|
},
|
|
168
|
+
"zai-org": {
|
|
169
|
+
conversational: new Zai.ZaiConversationalTask(),
|
|
170
|
+
},
|
|
167
171
|
};
|
|
168
172
|
|
|
169
173
|
/**
|
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.
|
|
2
|
+
export const PACKAGE_VERSION = "4.9.0";
|
|
3
3
|
export const PACKAGE_NAME = "@huggingface/inference";
|
package/src/providers/consts.ts
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* See the registered mapping of HF model ID => ZAI model ID here:
|
|
3
|
+
*
|
|
4
|
+
* https://huggingface.co/api/partners/zai-org/models
|
|
5
|
+
*
|
|
6
|
+
* This is a publicly available mapping.
|
|
7
|
+
*
|
|
8
|
+
* If you want to try to run inference for a new model locally before it's registered on huggingface.co,
|
|
9
|
+
* you can add it to the dictionary "HARDCODED_MODEL_ID_MAPPING" in consts.ts, for dev purposes.
|
|
10
|
+
*
|
|
11
|
+
* - If you work at zai and want to update this mapping, please use the model mapping API we provide on huggingface.co
|
|
12
|
+
* - If you're a community member and want to add a new supported HF model to zai, please open an issue on the present repo
|
|
13
|
+
* and we will tag zai team members.
|
|
14
|
+
*
|
|
15
|
+
* Thanks!
|
|
16
|
+
*/
|
|
17
|
+
import { BaseConversationalTask } from "./providerHelper.js";
|
|
18
|
+
import type { HeaderParams } from "../types.js";
|
|
19
|
+
|
|
20
|
+
const ZAI_API_BASE_URL = "https://api.z.ai";
|
|
21
|
+
|
|
22
|
+
export class ZaiConversationalTask extends BaseConversationalTask {
|
|
23
|
+
constructor() {
|
|
24
|
+
super("zai-org", ZAI_API_BASE_URL);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
override prepareHeaders(params: HeaderParams, binary: boolean): Record<string, string> {
|
|
28
|
+
const headers = super.prepareHeaders(params, binary);
|
|
29
|
+
headers["x-source-channel"] = "hugging_face";
|
|
30
|
+
headers["accept-language"] = "en-US,en";
|
|
31
|
+
return headers;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
override makeRoute(): string {
|
|
35
|
+
return "/api/paas/v4/chat/completions";
|
|
36
|
+
}
|
|
37
|
+
}
|