@huggingface/inference 4.8.0 → 4.10.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 +4 -0
- package/dist/commonjs/lib/getProviderHelper.d.ts.map +1 -1
- package/dist/commonjs/lib/getProviderHelper.js +8 -0
- package/dist/commonjs/package.d.ts +1 -1
- package/dist/commonjs/package.d.ts.map +1 -1
- package/dist/commonjs/package.js +1 -1
- package/dist/commonjs/providers/baseten.d.ts +21 -0
- package/dist/commonjs/providers/baseten.d.ts.map +1 -0
- package/dist/commonjs/providers/baseten.js +27 -0
- package/dist/commonjs/providers/consts.d.ts.map +1 -1
- package/dist/commonjs/providers/consts.js +2 -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 +2 -0
- package/dist/esm/lib/getProviderHelper.d.ts.map +1 -1
- package/dist/esm/lib/getProviderHelper.js +8 -0
- package/dist/esm/package.d.ts +1 -1
- package/dist/esm/package.d.ts.map +1 -1
- package/dist/esm/package.js +1 -1
- package/dist/esm/providers/baseten.d.ts +21 -0
- package/dist/esm/providers/baseten.d.ts.map +1 -0
- package/dist/esm/providers/baseten.js +23 -0
- package/dist/esm/providers/consts.d.ts.map +1 -1
- package/dist/esm/providers/consts.js +2 -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 +2 -0
- package/package.json +2 -2
- package/src/lib/getProviderHelper.ts +8 -0
- package/src/package.ts +1 -1
- package/src/providers/baseten.ts +25 -0
- package/src/providers/consts.ts +2 -0
- package/src/providers/zai-org.ts +37 -0
- package/src/types.ts +2 -0
package/README.md
CHANGED
|
@@ -61,10 +61,12 @@ Currently, we support the following providers:
|
|
|
61
61
|
- [Sambanova](https://sambanova.ai)
|
|
62
62
|
- [Scaleway](https://www.scaleway.com/en/generative-apis/)
|
|
63
63
|
- [Together](https://together.xyz)
|
|
64
|
+
- [Baseten](https://baseten.co)
|
|
64
65
|
- [Blackforestlabs](https://blackforestlabs.ai)
|
|
65
66
|
- [Cohere](https://cohere.com)
|
|
66
67
|
- [Cerebras](https://cerebras.ai/)
|
|
67
68
|
- [Groq](https://groq.com)
|
|
69
|
+
- [Z.ai](https://z.ai/)
|
|
68
70
|
|
|
69
71
|
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
72
|
|
|
@@ -96,10 +98,12 @@ Only a subset of models are supported when requesting third-party providers. You
|
|
|
96
98
|
- [Sambanova supported models](https://huggingface.co/api/partners/sambanova/models)
|
|
97
99
|
- [Scaleway supported models](https://huggingface.co/api/partners/scaleway/models)
|
|
98
100
|
- [Together supported models](https://huggingface.co/api/partners/together/models)
|
|
101
|
+
- [Baseten supported models](https://huggingface.co/api/partners/baseten/models)
|
|
99
102
|
- [Cohere supported models](https://huggingface.co/api/partners/cohere/models)
|
|
100
103
|
- [Cerebras supported models](https://huggingface.co/api/partners/cerebras/models)
|
|
101
104
|
- [Groq supported models](https://console.groq.com/docs/models)
|
|
102
105
|
- [Novita AI supported models](https://huggingface.co/api/partners/novita/models)
|
|
106
|
+
- [Z.ai supported models](https://huggingface.co/api/partners/zai-org/models)
|
|
103
107
|
|
|
104
108
|
❗**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
109
|
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":"
|
|
1
|
+
{"version":3,"file":"getProviderHelper.d.ts","sourceRoot":"","sources":["../../../src/lib/getProviderHelper.ts"],"names":[],"mappings":"AAgBA,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,CAqHnG,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,eAAe,GACnB,qBAAqB,GAAG,kBAAkB,CAAC;AAC9C,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,gBAAgB,GACpB,wBAAwB,GAAG,kBAAkB,CAAC;AACjD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,iBAA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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"}
|
|
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.PROVIDERS = void 0;
|
|
37
37
|
exports.getProviderHelper = getProviderHelper;
|
|
38
|
+
const Baseten = __importStar(require("../providers/baseten.js"));
|
|
38
39
|
const BlackForestLabs = __importStar(require("../providers/black-forest-labs.js"));
|
|
39
40
|
const Cerebras = __importStar(require("../providers/cerebras.js"));
|
|
40
41
|
const Cohere = __importStar(require("../providers/cohere.js"));
|
|
@@ -54,8 +55,12 @@ const Replicate = __importStar(require("../providers/replicate.js"));
|
|
|
54
55
|
const Sambanova = __importStar(require("../providers/sambanova.js"));
|
|
55
56
|
const Scaleway = __importStar(require("../providers/scaleway.js"));
|
|
56
57
|
const Together = __importStar(require("../providers/together.js"));
|
|
58
|
+
const Zai = __importStar(require("../providers/zai-org.js"));
|
|
57
59
|
const errors_js_1 = require("../errors.js");
|
|
58
60
|
exports.PROVIDERS = {
|
|
61
|
+
baseten: {
|
|
62
|
+
conversational: new Baseten.BasetenConversationalTask(),
|
|
63
|
+
},
|
|
59
64
|
"black-forest-labs": {
|
|
60
65
|
"text-to-image": new BlackForestLabs.BlackForestLabsTextToImageTask(),
|
|
61
66
|
},
|
|
@@ -166,6 +171,9 @@ exports.PROVIDERS = {
|
|
|
166
171
|
conversational: new Together.TogetherConversationalTask(),
|
|
167
172
|
"text-generation": new Together.TogetherTextGenerationTask(),
|
|
168
173
|
},
|
|
174
|
+
"zai-org": {
|
|
175
|
+
conversational: new Zai.ZaiConversationalTask(),
|
|
176
|
+
},
|
|
169
177
|
};
|
|
170
178
|
function getProviderHelper(provider, task) {
|
|
171
179
|
if ((provider === "hf-inference" && !task) || provider === "auto") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,eAAe,WAAW,CAAC;AACxC,eAAO,MAAM,YAAY,2BAA2B,CAAC"}
|
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.10.0";
|
|
6
6
|
exports.PACKAGE_NAME = "@huggingface/inference";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* See the registered mapping of HF model ID => Baseten model ID here:
|
|
3
|
+
*
|
|
4
|
+
* https://huggingface.co/api/partners/baseten/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 Baseten 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 Baseten, please open an issue on the present repo
|
|
13
|
+
* and we will tag Baseten team members.
|
|
14
|
+
*
|
|
15
|
+
* Thanks!
|
|
16
|
+
*/
|
|
17
|
+
import { BaseConversationalTask } from "./providerHelper.js";
|
|
18
|
+
export declare class BasetenConversationalTask extends BaseConversationalTask {
|
|
19
|
+
constructor();
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=baseten.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseten.d.ts","sourceRoot":"","sources":["../../../src/providers/baseten.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAI7D,qBAAa,yBAA0B,SAAQ,sBAAsB;;CAIpE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BasetenConversationalTask = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* See the registered mapping of HF model ID => Baseten model ID here:
|
|
6
|
+
*
|
|
7
|
+
* https://huggingface.co/api/partners/baseten/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 Baseten 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 Baseten, please open an issue on the present repo
|
|
16
|
+
* and we will tag Baseten team members.
|
|
17
|
+
*
|
|
18
|
+
* Thanks!
|
|
19
|
+
*/
|
|
20
|
+
const providerHelper_js_1 = require("./providerHelper.js");
|
|
21
|
+
const BASETEN_API_BASE_URL = "https://inference.baseten.co";
|
|
22
|
+
class BasetenConversationalTask extends providerHelper_js_1.BaseConversationalTask {
|
|
23
|
+
constructor() {
|
|
24
|
+
super("baseten", BASETEN_API_BASE_URL);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.BasetenConversationalTask = BasetenConversationalTask;
|
|
@@ -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,CA6B9C,CAAC"}
|
|
@@ -15,6 +15,7 @@ exports.HARDCODED_MODEL_INFERENCE_MAPPING = {
|
|
|
15
15
|
* Example:
|
|
16
16
|
* "Qwen/Qwen2.5-Coder-32B-Instruct": "Qwen2.5-Coder-32B-Instruct",
|
|
17
17
|
*/
|
|
18
|
+
baseten: {},
|
|
18
19
|
"black-forest-labs": {},
|
|
19
20
|
cerebras: {},
|
|
20
21
|
cohere: {},
|
|
@@ -34,4 +35,5 @@ exports.HARDCODED_MODEL_INFERENCE_MAPPING = {
|
|
|
34
35
|
sambanova: {},
|
|
35
36
|
scaleway: {},
|
|
36
37
|
together: {},
|
|
38
|
+
"zai-org": {},
|
|
37
39
|
};
|
|
@@ -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 ["baseten", "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 ["baseten", "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,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;CACnD;AAED,MAAM,WAAW,OAAO;IACvB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAEtC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,GAAG,gBAAgB,CAAC;AAE9E,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,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AW,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
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PROVIDERS_OR_POLICIES = exports.INFERENCE_PROVIDERS = void 0;
|
|
4
4
|
exports.INFERENCE_PROVIDERS = [
|
|
5
|
+
"baseten",
|
|
5
6
|
"black-forest-labs",
|
|
6
7
|
"cerebras",
|
|
7
8
|
"cohere",
|
|
@@ -21,5 +22,6 @@ exports.INFERENCE_PROVIDERS = [
|
|
|
21
22
|
"sambanova",
|
|
22
23
|
"scaleway",
|
|
23
24
|
"together",
|
|
25
|
+
"zai-org",
|
|
24
26
|
];
|
|
25
27
|
exports.PROVIDERS_OR_POLICIES = [...exports.INFERENCE_PROVIDERS, "auto"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getProviderHelper.d.ts","sourceRoot":"","sources":["../../../src/lib/getProviderHelper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getProviderHelper.d.ts","sourceRoot":"","sources":["../../../src/lib/getProviderHelper.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACX,6BAA6B,EAC7B,sBAAsB,EACtB,oCAAoC,EACpC,wBAAwB,EACxB,mCAAmC,EACnC,2BAA2B,EAC3B,kBAAkB,EAClB,6BAA6B,EAC7B,2BAA2B,EAC3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,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"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as Baseten from "../providers/baseten.js";
|
|
1
2
|
import * as BlackForestLabs from "../providers/black-forest-labs.js";
|
|
2
3
|
import * as Cerebras from "../providers/cerebras.js";
|
|
3
4
|
import * as Cohere from "../providers/cohere.js";
|
|
@@ -17,8 +18,12 @@ import * as Replicate from "../providers/replicate.js";
|
|
|
17
18
|
import * as Sambanova from "../providers/sambanova.js";
|
|
18
19
|
import * as Scaleway from "../providers/scaleway.js";
|
|
19
20
|
import * as Together from "../providers/together.js";
|
|
21
|
+
import * as Zai from "../providers/zai-org.js";
|
|
20
22
|
import { InferenceClientInputError } from "../errors.js";
|
|
21
23
|
export const PROVIDERS = {
|
|
24
|
+
baseten: {
|
|
25
|
+
conversational: new Baseten.BasetenConversationalTask(),
|
|
26
|
+
},
|
|
22
27
|
"black-forest-labs": {
|
|
23
28
|
"text-to-image": new BlackForestLabs.BlackForestLabsTextToImageTask(),
|
|
24
29
|
},
|
|
@@ -129,6 +134,9 @@ export const PROVIDERS = {
|
|
|
129
134
|
conversational: new Together.TogetherConversationalTask(),
|
|
130
135
|
"text-generation": new Together.TogetherTextGenerationTask(),
|
|
131
136
|
},
|
|
137
|
+
"zai-org": {
|
|
138
|
+
conversational: new Zai.ZaiConversationalTask(),
|
|
139
|
+
},
|
|
132
140
|
};
|
|
133
141
|
export function getProviderHelper(provider, task) {
|
|
134
142
|
if ((provider === "hf-inference" && !task) || provider === "auto") {
|
package/dist/esm/package.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,eAAe,WAAW,CAAC;AACxC,eAAO,MAAM,YAAY,2BAA2B,CAAC"}
|
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.10.0";
|
|
3
3
|
export const PACKAGE_NAME = "@huggingface/inference";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* See the registered mapping of HF model ID => Baseten model ID here:
|
|
3
|
+
*
|
|
4
|
+
* https://huggingface.co/api/partners/baseten/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 Baseten 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 Baseten, please open an issue on the present repo
|
|
13
|
+
* and we will tag Baseten team members.
|
|
14
|
+
*
|
|
15
|
+
* Thanks!
|
|
16
|
+
*/
|
|
17
|
+
import { BaseConversationalTask } from "./providerHelper.js";
|
|
18
|
+
export declare class BasetenConversationalTask extends BaseConversationalTask {
|
|
19
|
+
constructor();
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=baseten.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseten.d.ts","sourceRoot":"","sources":["../../../src/providers/baseten.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAI7D,qBAAa,yBAA0B,SAAQ,sBAAsB;;CAIpE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* See the registered mapping of HF model ID => Baseten model ID here:
|
|
3
|
+
*
|
|
4
|
+
* https://huggingface.co/api/partners/baseten/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 Baseten 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 Baseten, please open an issue on the present repo
|
|
13
|
+
* and we will tag Baseten team members.
|
|
14
|
+
*
|
|
15
|
+
* Thanks!
|
|
16
|
+
*/
|
|
17
|
+
import { BaseConversationalTask } from "./providerHelper.js";
|
|
18
|
+
const BASETEN_API_BASE_URL = "https://inference.baseten.co";
|
|
19
|
+
export class BasetenConversationalTask extends BaseConversationalTask {
|
|
20
|
+
constructor() {
|
|
21
|
+
super("baseten", BASETEN_API_BASE_URL);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -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,CA6B9C,CAAC"}
|
|
@@ -12,6 +12,7 @@ export const HARDCODED_MODEL_INFERENCE_MAPPING = {
|
|
|
12
12
|
* Example:
|
|
13
13
|
* "Qwen/Qwen2.5-Coder-32B-Instruct": "Qwen2.5-Coder-32B-Instruct",
|
|
14
14
|
*/
|
|
15
|
+
baseten: {},
|
|
15
16
|
"black-forest-labs": {},
|
|
16
17
|
cerebras: {},
|
|
17
18
|
cohere: {},
|
|
@@ -31,4 +32,5 @@ export const HARDCODED_MODEL_INFERENCE_MAPPING = {
|
|
|
31
32
|
sambanova: {},
|
|
32
33
|
scaleway: {},
|
|
33
34
|
together: {},
|
|
35
|
+
"zai-org": {},
|
|
34
36
|
};
|
|
@@ -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 ["baseten", "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 ["baseten", "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,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,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;CACnD;AAED,MAAM,WAAW,OAAO;IACvB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,KAAK,C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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/esm/types.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export const INFERENCE_PROVIDERS = [
|
|
2
|
+
"baseten",
|
|
2
3
|
"black-forest-labs",
|
|
3
4
|
"cerebras",
|
|
4
5
|
"cohere",
|
|
@@ -18,5 +19,6 @@ export const INFERENCE_PROVIDERS = [
|
|
|
18
19
|
"sambanova",
|
|
19
20
|
"scaleway",
|
|
20
21
|
"together",
|
|
22
|
+
"zai-org",
|
|
21
23
|
];
|
|
22
24
|
export const PROVIDERS_OR_POLICIES = [...INFERENCE_PROVIDERS, "auto"];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huggingface/inference",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.0",
|
|
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",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"type": "module",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@huggingface/tasks": "^0.19.
|
|
43
|
+
"@huggingface/tasks": "^0.19.49",
|
|
44
44
|
"@huggingface/jinja": "^0.5.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as Baseten from "../providers/baseten.js";
|
|
1
2
|
import * as BlackForestLabs from "../providers/black-forest-labs.js";
|
|
2
3
|
import * as Cerebras from "../providers/cerebras.js";
|
|
3
4
|
import * as Cohere from "../providers/cohere.js";
|
|
@@ -50,10 +51,14 @@ import * as Replicate from "../providers/replicate.js";
|
|
|
50
51
|
import * as Sambanova from "../providers/sambanova.js";
|
|
51
52
|
import * as Scaleway from "../providers/scaleway.js";
|
|
52
53
|
import * as Together from "../providers/together.js";
|
|
54
|
+
import * as Zai from "../providers/zai-org.js";
|
|
53
55
|
import type { InferenceProvider, InferenceProviderOrPolicy, InferenceTask } from "../types.js";
|
|
54
56
|
import { InferenceClientInputError } from "../errors.js";
|
|
55
57
|
|
|
56
58
|
export const PROVIDERS: Record<InferenceProvider, Partial<Record<InferenceTask, TaskProviderHelper>>> = {
|
|
59
|
+
baseten: {
|
|
60
|
+
conversational: new Baseten.BasetenConversationalTask(),
|
|
61
|
+
},
|
|
57
62
|
"black-forest-labs": {
|
|
58
63
|
"text-to-image": new BlackForestLabs.BlackForestLabsTextToImageTask(),
|
|
59
64
|
},
|
|
@@ -164,6 +169,9 @@ export const PROVIDERS: Record<InferenceProvider, Partial<Record<InferenceTask,
|
|
|
164
169
|
conversational: new Together.TogetherConversationalTask(),
|
|
165
170
|
"text-generation": new Together.TogetherTextGenerationTask(),
|
|
166
171
|
},
|
|
172
|
+
"zai-org": {
|
|
173
|
+
conversational: new Zai.ZaiConversationalTask(),
|
|
174
|
+
},
|
|
167
175
|
};
|
|
168
176
|
|
|
169
177
|
/**
|
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.10.0";
|
|
3
3
|
export const PACKAGE_NAME = "@huggingface/inference";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* See the registered mapping of HF model ID => Baseten model ID here:
|
|
3
|
+
*
|
|
4
|
+
* https://huggingface.co/api/partners/baseten/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 Baseten 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 Baseten, please open an issue on the present repo
|
|
13
|
+
* and we will tag Baseten team members.
|
|
14
|
+
*
|
|
15
|
+
* Thanks!
|
|
16
|
+
*/
|
|
17
|
+
import { BaseConversationalTask } from "./providerHelper.js";
|
|
18
|
+
|
|
19
|
+
const BASETEN_API_BASE_URL = "https://inference.baseten.co";
|
|
20
|
+
|
|
21
|
+
export class BasetenConversationalTask extends BaseConversationalTask {
|
|
22
|
+
constructor() {
|
|
23
|
+
super("baseten", BASETEN_API_BASE_URL);
|
|
24
|
+
}
|
|
25
|
+
}
|
package/src/providers/consts.ts
CHANGED
|
@@ -18,6 +18,7 @@ export const HARDCODED_MODEL_INFERENCE_MAPPING: Record<
|
|
|
18
18
|
* Example:
|
|
19
19
|
* "Qwen/Qwen2.5-Coder-32B-Instruct": "Qwen2.5-Coder-32B-Instruct",
|
|
20
20
|
*/
|
|
21
|
+
baseten: {},
|
|
21
22
|
"black-forest-labs": {},
|
|
22
23
|
cerebras: {},
|
|
23
24
|
cohere: {},
|
|
@@ -37,4 +38,5 @@ export const HARDCODED_MODEL_INFERENCE_MAPPING: Record<
|
|
|
37
38
|
sambanova: {},
|
|
38
39
|
scaleway: {},
|
|
39
40
|
together: {},
|
|
41
|
+
"zai-org": {},
|
|
40
42
|
};
|
|
@@ -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
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -45,6 +45,7 @@ export interface Options {
|
|
|
45
45
|
export type InferenceTask = Exclude<PipelineType, "other"> | "conversational";
|
|
46
46
|
|
|
47
47
|
export const INFERENCE_PROVIDERS = [
|
|
48
|
+
"baseten",
|
|
48
49
|
"black-forest-labs",
|
|
49
50
|
"cerebras",
|
|
50
51
|
"cohere",
|
|
@@ -64,6 +65,7 @@ export const INFERENCE_PROVIDERS = [
|
|
|
64
65
|
"sambanova",
|
|
65
66
|
"scaleway",
|
|
66
67
|
"together",
|
|
68
|
+
"zai-org",
|
|
67
69
|
] as const;
|
|
68
70
|
|
|
69
71
|
export const PROVIDERS_OR_POLICIES = [...INFERENCE_PROVIDERS, "auto"] as const;
|