@huggingface/inference 4.13.11 → 4.13.13
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 +9 -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 +2 -0
- package/dist/commonjs/providers/deepinfra.d.ts +42 -0
- package/dist/commonjs/providers/deepinfra.d.ts.map +1 -0
- package/dist/commonjs/providers/deepinfra.js +75 -0
- package/dist/commonjs/providers/nvidia.d.ts +21 -0
- package/dist/commonjs/providers/nvidia.d.ts.map +1 -0
- package/dist/commonjs/providers/nvidia.js +26 -0
- package/dist/commonjs/types.d.ts +2 -2
- package/dist/commonjs/types.d.ts.map +1 -1
- package/dist/commonjs/types.js +4 -0
- package/dist/esm/lib/getProviderHelper.d.ts.map +1 -1
- package/dist/esm/lib/getProviderHelper.js +9 -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 +2 -0
- package/dist/esm/providers/deepinfra.d.ts +42 -0
- package/dist/esm/providers/deepinfra.d.ts.map +1 -0
- package/dist/esm/providers/deepinfra.js +70 -0
- package/dist/esm/providers/nvidia.d.ts +21 -0
- package/dist/esm/providers/nvidia.d.ts.map +1 -0
- package/dist/esm/providers/nvidia.js +22 -0
- package/dist/esm/types.d.ts +2 -2
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js +4 -0
- package/package.json +3 -3
- package/src/lib/getProviderHelper.ts +9 -0
- package/src/package.ts +1 -1
- package/src/providers/consts.ts +2 -0
- package/src/providers/deepinfra.ts +94 -0
- package/src/providers/nvidia.ts +23 -0
- package/src/types.ts +4 -0
package/README.md
CHANGED
|
@@ -55,6 +55,7 @@ Currently, we support the following providers:
|
|
|
55
55
|
- [Nebius](https://studio.nebius.ai)
|
|
56
56
|
- [Novita](https://novita.ai)
|
|
57
57
|
- [Nscale](https://nscale.com)
|
|
58
|
+
- [NVIDIA](https://build.nvidia.com/)
|
|
58
59
|
- [OVHcloud](https://endpoints.ai.cloud.ovh.net/)
|
|
59
60
|
- [Public AI](https://publicai.co)
|
|
60
61
|
- [Replicate](https://replicate.com)
|
|
@@ -66,6 +67,7 @@ Currently, we support the following providers:
|
|
|
66
67
|
- [Blackforestlabs](https://blackforestlabs.ai)
|
|
67
68
|
- [Cohere](https://cohere.com)
|
|
68
69
|
- [Cerebras](https://cerebras.ai/)
|
|
70
|
+
- [DeepInfra](https://deepinfra.com)
|
|
69
71
|
- [Groq](https://groq.com)
|
|
70
72
|
- [Wavespeed.ai](https://wavespeed.ai/)
|
|
71
73
|
- [Z.ai](https://z.ai/)
|
|
@@ -95,6 +97,7 @@ Only a subset of models are supported when requesting third-party providers. You
|
|
|
95
97
|
- [Hyperbolic supported models](https://huggingface.co/api/partners/hyperbolic/models)
|
|
96
98
|
- [Nebius supported models](https://huggingface.co/api/partners/nebius/models)
|
|
97
99
|
- [Nscale supported models](https://huggingface.co/api/partners/nscale/models)
|
|
100
|
+
- [NVIDIA supported models](https://huggingface.co/api/partners/nvidia/models)
|
|
98
101
|
- [OVHcloud supported models](https://huggingface.co/api/partners/ovhcloud/models)
|
|
99
102
|
- [Replicate supported models](https://huggingface.co/api/partners/replicate/models)
|
|
100
103
|
- [Sambanova supported models](https://huggingface.co/api/partners/sambanova/models)
|
|
@@ -104,6 +107,7 @@ Only a subset of models are supported when requesting third-party providers. You
|
|
|
104
107
|
- [Clarifai supported models](https://huggingface.co/api/partners/clarifai/models)
|
|
105
108
|
- [Cohere supported models](https://huggingface.co/api/partners/cohere/models)
|
|
106
109
|
- [Cerebras supported models](https://huggingface.co/api/partners/cerebras/models)
|
|
110
|
+
- [DeepInfra supported models](https://huggingface.co/api/partners/deepinfra/models)
|
|
107
111
|
- [Groq supported models](https://console.groq.com/docs/models)
|
|
108
112
|
- [Novita AI supported models](https://huggingface.co/api/partners/novita/models)
|
|
109
113
|
- [Wavespeed.ai supported models](https://huggingface.co/api/partners/wavespeed/models)
|
|
@@ -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":"AAmBA,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,0BAA0B,EAC1B,0BAA0B,EAC1B,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;AAOxC,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,CA0InG,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,eAAe,GACnB,qBAAqB,GAAG,kBAAkB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AAkB,CAAC;AACnD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,qBAAqB,GACzB,0BAA0B,GAAG,kBAAkB,CAAC;AACnD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,qBAAqB,GACzB,4BAA4B,GAAG,kBAAkB,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"}
|
|
@@ -40,6 +40,7 @@ const Clarifai = __importStar(require("../providers/clarifai.js"));
|
|
|
40
40
|
const BlackForestLabs = __importStar(require("../providers/black-forest-labs.js"));
|
|
41
41
|
const Cerebras = __importStar(require("../providers/cerebras.js"));
|
|
42
42
|
const Cohere = __importStar(require("../providers/cohere.js"));
|
|
43
|
+
const DeepInfra = __importStar(require("../providers/deepinfra.js"));
|
|
43
44
|
const FalAI = __importStar(require("../providers/fal-ai.js"));
|
|
44
45
|
const FeatherlessAI = __importStar(require("../providers/featherless-ai.js"));
|
|
45
46
|
const Fireworks = __importStar(require("../providers/fireworks-ai.js"));
|
|
@@ -49,6 +50,7 @@ const Hyperbolic = __importStar(require("../providers/hyperbolic.js"));
|
|
|
49
50
|
const Nebius = __importStar(require("../providers/nebius.js"));
|
|
50
51
|
const Novita = __importStar(require("../providers/novita.js"));
|
|
51
52
|
const Nscale = __importStar(require("../providers/nscale.js"));
|
|
53
|
+
const Nvidia = __importStar(require("../providers/nvidia.js"));
|
|
52
54
|
const OpenAI = __importStar(require("../providers/openai.js"));
|
|
53
55
|
const OvhCloud = __importStar(require("../providers/ovhcloud.js"));
|
|
54
56
|
const PublicAI = __importStar(require("../providers/publicai.js"));
|
|
@@ -75,6 +77,10 @@ exports.PROVIDERS = {
|
|
|
75
77
|
cohere: {
|
|
76
78
|
conversational: new Cohere.CohereConversationalTask(),
|
|
77
79
|
},
|
|
80
|
+
deepinfra: {
|
|
81
|
+
conversational: new DeepInfra.DeepInfraConversationalTask(),
|
|
82
|
+
"text-generation": new DeepInfra.DeepInfraTextGenerationTask(),
|
|
83
|
+
},
|
|
78
84
|
"fal-ai": {
|
|
79
85
|
"automatic-speech-recognition": new FalAI.FalAIAutomaticSpeechRecognitionTask(),
|
|
80
86
|
"image-text-to-image": new FalAI.FalAIImageTextToImageTask(),
|
|
@@ -147,6 +153,9 @@ exports.PROVIDERS = {
|
|
|
147
153
|
"text-to-image": new Nscale.NscaleTextToImageTask(),
|
|
148
154
|
conversational: new Nscale.NscaleConversationalTask(),
|
|
149
155
|
},
|
|
156
|
+
nvidia: {
|
|
157
|
+
conversational: new Nvidia.NvidiaConversationalTask(),
|
|
158
|
+
},
|
|
150
159
|
openai: {
|
|
151
160
|
conversational: new OpenAI.OpenAIConversationalTask(),
|
|
152
161
|
},
|
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.13";
|
|
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,CAiC9C,CAAC"}
|
|
@@ -20,6 +20,7 @@ exports.HARDCODED_MODEL_INFERENCE_MAPPING = {
|
|
|
20
20
|
cerebras: {},
|
|
21
21
|
clarifai: {},
|
|
22
22
|
cohere: {},
|
|
23
|
+
deepinfra: {},
|
|
23
24
|
"fal-ai": {},
|
|
24
25
|
"featherless-ai": {},
|
|
25
26
|
"fireworks-ai": {},
|
|
@@ -29,6 +30,7 @@ exports.HARDCODED_MODEL_INFERENCE_MAPPING = {
|
|
|
29
30
|
nebius: {},
|
|
30
31
|
novita: {},
|
|
31
32
|
nscale: {},
|
|
33
|
+
nvidia: {},
|
|
32
34
|
openai: {},
|
|
33
35
|
publicai: {},
|
|
34
36
|
ovhcloud: {},
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* See the registered mapping of HF model ID => DeepInfra model ID here:
|
|
3
|
+
*
|
|
4
|
+
* https://huggingface.co/api/partners/deepinfra/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
|
|
9
|
+
it's registered on huggingface.co,
|
|
10
|
+
* you can add it to the dictionary "HARDCODED_MODEL_ID_MAPPING" in
|
|
11
|
+
consts.ts, for dev purposes.
|
|
12
|
+
*
|
|
13
|
+
* - If you work at DeepInfra and want to update this mapping, please
|
|
14
|
+
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
|
|
16
|
+
model to DeepInfra, please open an issue on the present repo
|
|
17
|
+
* and we will tag DeepInfra team members.
|
|
18
|
+
*
|
|
19
|
+
* Thanks!
|
|
20
|
+
*/
|
|
21
|
+
import type { TextGenerationOutput } from "@huggingface/tasks";
|
|
22
|
+
import type { BodyParams } from "../types.js";
|
|
23
|
+
import { BaseConversationalTask, BaseTextGenerationTask } from "./providerHelper.js";
|
|
24
|
+
interface DeepInfraCompletionChoice {
|
|
25
|
+
text?: string;
|
|
26
|
+
}
|
|
27
|
+
interface DeepInfraCompletionResponse {
|
|
28
|
+
choices: DeepInfraCompletionChoice[];
|
|
29
|
+
model: string;
|
|
30
|
+
}
|
|
31
|
+
export declare class DeepInfraConversationalTask extends BaseConversationalTask {
|
|
32
|
+
constructor();
|
|
33
|
+
makeRoute(): string;
|
|
34
|
+
}
|
|
35
|
+
export declare class DeepInfraTextGenerationTask extends BaseTextGenerationTask {
|
|
36
|
+
constructor();
|
|
37
|
+
makeRoute(): string;
|
|
38
|
+
preparePayload(params: BodyParams): Record<string, unknown>;
|
|
39
|
+
getResponse(response: DeepInfraCompletionResponse): Promise<TextGenerationOutput>;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=deepinfra.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepinfra.d.ts","sourceRoot":"","sources":["../../../src/providers/deepinfra.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;EAmBE;AAEF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAOrF,UAAU,yBAAyB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,UAAU,2BAA2B;IACpC,OAAO,EAAE,yBAAyB,EAAE,CAAC;IACrC,KAAK,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,2BAA4B,SAAQ,sBAAsB;;IAK7D,SAAS,IAAI,MAAM;CAG5B;AAED,qBAAa,2BAA4B,SAAQ,sBAAsB;;IAK7D,SAAS,IAAI,MAAM;IAInB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAgBrD,WAAW,CAAC,QAAQ,EAAE,2BAA2B,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAiBhG"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* See the registered mapping of HF model ID => DeepInfra model ID here:
|
|
4
|
+
*
|
|
5
|
+
* https://huggingface.co/api/partners/deepinfra/models
|
|
6
|
+
*
|
|
7
|
+
* This is a publicly available mapping.
|
|
8
|
+
*
|
|
9
|
+
* If you want to try to run inference for a new model locally before
|
|
10
|
+
it's registered on huggingface.co,
|
|
11
|
+
* you can add it to the dictionary "HARDCODED_MODEL_ID_MAPPING" in
|
|
12
|
+
consts.ts, for dev purposes.
|
|
13
|
+
*
|
|
14
|
+
* - If you work at DeepInfra and want to update this mapping, please
|
|
15
|
+
use the model mapping API we provide on huggingface.co
|
|
16
|
+
* - If you're a community member and want to add a new supported HF
|
|
17
|
+
model to DeepInfra, please open an issue on the present repo
|
|
18
|
+
* and we will tag DeepInfra team members.
|
|
19
|
+
*
|
|
20
|
+
* Thanks!
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.DeepInfraTextGenerationTask = exports.DeepInfraConversationalTask = void 0;
|
|
24
|
+
const errors_js_1 = require("../errors.js");
|
|
25
|
+
const omit_js_1 = require("../utils/omit.js");
|
|
26
|
+
const providerHelper_js_1 = require("./providerHelper.js");
|
|
27
|
+
/**
|
|
28
|
+
* DeepInfra exposes OpenAI-compatible endpoints under the /v1/openai namespace.
|
|
29
|
+
*/
|
|
30
|
+
const DEEPINFRA_API_BASE_URL = "https://api.deepinfra.com";
|
|
31
|
+
class DeepInfraConversationalTask extends providerHelper_js_1.BaseConversationalTask {
|
|
32
|
+
constructor() {
|
|
33
|
+
super("deepinfra", DEEPINFRA_API_BASE_URL);
|
|
34
|
+
}
|
|
35
|
+
makeRoute() {
|
|
36
|
+
return "v1/openai/chat/completions";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.DeepInfraConversationalTask = DeepInfraConversationalTask;
|
|
40
|
+
class DeepInfraTextGenerationTask extends providerHelper_js_1.BaseTextGenerationTask {
|
|
41
|
+
constructor() {
|
|
42
|
+
super("deepinfra", DEEPINFRA_API_BASE_URL);
|
|
43
|
+
}
|
|
44
|
+
makeRoute() {
|
|
45
|
+
return "v1/openai/completions";
|
|
46
|
+
}
|
|
47
|
+
preparePayload(params) {
|
|
48
|
+
const parameters = params.args.parameters;
|
|
49
|
+
const res = {
|
|
50
|
+
model: params.model,
|
|
51
|
+
prompt: params.args.inputs,
|
|
52
|
+
...(0, omit_js_1.omit)(params.args, ["inputs", "parameters"]),
|
|
53
|
+
...(parameters
|
|
54
|
+
? {
|
|
55
|
+
max_tokens: parameters.max_new_tokens,
|
|
56
|
+
...(0, omit_js_1.omit)(parameters, ["max_new_tokens"]),
|
|
57
|
+
}
|
|
58
|
+
: undefined),
|
|
59
|
+
};
|
|
60
|
+
return res;
|
|
61
|
+
}
|
|
62
|
+
async getResponse(response) {
|
|
63
|
+
if (typeof response === "object" &&
|
|
64
|
+
response !== null &&
|
|
65
|
+
Array.isArray(response.choices) &&
|
|
66
|
+
response.choices.length > 0) {
|
|
67
|
+
const completion = response.choices[0].text;
|
|
68
|
+
if (typeof completion === "string") {
|
|
69
|
+
return { generated_text: completion };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
throw new errors_js_1.InferenceClientProviderOutputError("Received malformed response from DeepInfra text-generation API: expected OpenAI completion payload");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.DeepInfraTextGenerationTask = DeepInfraTextGenerationTask;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* See the registered mapping of HF model ID => NVIDIA model ID here:
|
|
3
|
+
*
|
|
4
|
+
* https://huggingface.co/api/partners/nvidia/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 NVIDIA 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 NVIDIA, please open an issue on the present repo
|
|
13
|
+
* and we will tag NVIDIA team members.
|
|
14
|
+
*
|
|
15
|
+
* Thanks!
|
|
16
|
+
*/
|
|
17
|
+
import { BaseConversationalTask } from "./providerHelper.js";
|
|
18
|
+
export declare class NvidiaConversationalTask extends BaseConversationalTask {
|
|
19
|
+
constructor();
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=nvidia.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nvidia.d.ts","sourceRoot":"","sources":["../../../src/providers/nvidia.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,qBAAa,wBAAyB,SAAQ,sBAAsB;;CAInE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NvidiaConversationalTask = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* See the registered mapping of HF model ID => NVIDIA model ID here:
|
|
6
|
+
*
|
|
7
|
+
* https://huggingface.co/api/partners/nvidia/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 NVIDIA 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 NVIDIA, please open an issue on the present repo
|
|
16
|
+
* and we will tag NVIDIA team members.
|
|
17
|
+
*
|
|
18
|
+
* Thanks!
|
|
19
|
+
*/
|
|
20
|
+
const providerHelper_js_1 = require("./providerHelper.js");
|
|
21
|
+
class NvidiaConversationalTask extends providerHelper_js_1.BaseConversationalTask {
|
|
22
|
+
constructor() {
|
|
23
|
+
super("nvidia", "https://integrate.api.nvidia.com");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.NvidiaConversationalTask = NvidiaConversationalTask;
|
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 ["baseten", "black-forest-labs", "cerebras", "clarifai", "cohere", "fal-ai", "featherless-ai", "fireworks-ai", "groq", "hf-inference", "hyperbolic", "nebius", "novita", "nscale", "openai", "ovhcloud", "publicai", "replicate", "sambanova", "scaleway", "together", "wavespeed", "zai-org"];
|
|
40
|
-
export declare const PROVIDERS_OR_POLICIES: readonly ["baseten", "black-forest-labs", "cerebras", "clarifai", "cohere", "fal-ai", "featherless-ai", "fireworks-ai", "groq", "hf-inference", "hyperbolic", "nebius", "novita", "nscale", "openai", "ovhcloud", "publicai", "replicate", "sambanova", "scaleway", "together", "wavespeed", "zai-org", "auto"];
|
|
39
|
+
export declare const INFERENCE_PROVIDERS: readonly ["baseten", "black-forest-labs", "cerebras", "clarifai", "cohere", "deepinfra", "fal-ai", "featherless-ai", "fireworks-ai", "groq", "hf-inference", "hyperbolic", "nebius", "novita", "nscale", "nvidia", "openai", "ovhcloud", "publicai", "replicate", "sambanova", "scaleway", "together", "wavespeed", "zai-org"];
|
|
40
|
+
export declare const PROVIDERS_OR_POLICIES: readonly ["baseten", "black-forest-labs", "cerebras", "clarifai", "cohere", "deepinfra", "fal-ai", "featherless-ai", "fireworks-ai", "groq", "hf-inference", "hyperbolic", "nebius", "novita", "nscale", "nvidia", "openai", "ovhcloud", "publicai", "replicate", "sambanova", "scaleway", "together", "wavespeed", "zai-org", "auto"];
|
|
41
41
|
export type InferenceProvider = (typeof INFERENCE_PROVIDERS)[number];
|
|
42
42
|
export type InferenceProviderOrPolicy = (typeof PROVIDERS_OR_POLICIES)[number];
|
|
43
43
|
/**
|
|
@@ -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,
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AAM,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;IACrB,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;CACvC;AAED,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7D,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;IACrB,UAAU,CAAC,EAAE,UAAU,CAAC;CACxB"}
|
package/dist/commonjs/types.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.INFERENCE_PROVIDERS = [
|
|
|
7
7
|
"cerebras",
|
|
8
8
|
"clarifai",
|
|
9
9
|
"cohere",
|
|
10
|
+
"deepinfra",
|
|
10
11
|
"fal-ai",
|
|
11
12
|
"featherless-ai",
|
|
12
13
|
"fireworks-ai",
|
|
@@ -16,6 +17,7 @@ exports.INFERENCE_PROVIDERS = [
|
|
|
16
17
|
"nebius",
|
|
17
18
|
"novita",
|
|
18
19
|
"nscale",
|
|
20
|
+
"nvidia",
|
|
19
21
|
"openai",
|
|
20
22
|
"ovhcloud",
|
|
21
23
|
"publicai",
|
|
@@ -38,6 +40,7 @@ exports.PROVIDERS_HUB_ORGS = {
|
|
|
38
40
|
cerebras: "cerebras",
|
|
39
41
|
clarifai: "clarifai",
|
|
40
42
|
cohere: "CohereLabs",
|
|
43
|
+
deepinfra: "DeepInfra",
|
|
41
44
|
"fal-ai": "fal",
|
|
42
45
|
"featherless-ai": "featherless-ai",
|
|
43
46
|
"fireworks-ai": "fireworks-ai",
|
|
@@ -47,6 +50,7 @@ exports.PROVIDERS_HUB_ORGS = {
|
|
|
47
50
|
nebius: "nebius",
|
|
48
51
|
novita: "novita",
|
|
49
52
|
nscale: "nscale",
|
|
53
|
+
nvidia: "nvidia",
|
|
50
54
|
openai: "openai",
|
|
51
55
|
ovhcloud: "ovhcloud",
|
|
52
56
|
publicai: "publicai",
|
|
@@ -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":"AAmBA,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,0BAA0B,EAC1B,0BAA0B,EAC1B,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;AAOxC,OAAO,KAAK,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,aAAa,CA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C/B,iCAAiC,GAAG,kBAAkB,CAAC;AAC1D,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,aAAa,GAAG,SAAS,GAC7B,kBAAkB,CAAC"}
|
|
@@ -3,6 +3,7 @@ import * as Clarifai from "../providers/clarifai.js";
|
|
|
3
3
|
import * as BlackForestLabs from "../providers/black-forest-labs.js";
|
|
4
4
|
import * as Cerebras from "../providers/cerebras.js";
|
|
5
5
|
import * as Cohere from "../providers/cohere.js";
|
|
6
|
+
import * as DeepInfra from "../providers/deepinfra.js";
|
|
6
7
|
import * as FalAI from "../providers/fal-ai.js";
|
|
7
8
|
import * as FeatherlessAI from "../providers/featherless-ai.js";
|
|
8
9
|
import * as Fireworks from "../providers/fireworks-ai.js";
|
|
@@ -12,6 +13,7 @@ import * as Hyperbolic from "../providers/hyperbolic.js";
|
|
|
12
13
|
import * as Nebius from "../providers/nebius.js";
|
|
13
14
|
import * as Novita from "../providers/novita.js";
|
|
14
15
|
import * as Nscale from "../providers/nscale.js";
|
|
16
|
+
import * as Nvidia from "../providers/nvidia.js";
|
|
15
17
|
import * as OpenAI from "../providers/openai.js";
|
|
16
18
|
import * as OvhCloud from "../providers/ovhcloud.js";
|
|
17
19
|
import * as PublicAI from "../providers/publicai.js";
|
|
@@ -38,6 +40,10 @@ export const PROVIDERS = {
|
|
|
38
40
|
cohere: {
|
|
39
41
|
conversational: new Cohere.CohereConversationalTask(),
|
|
40
42
|
},
|
|
43
|
+
deepinfra: {
|
|
44
|
+
conversational: new DeepInfra.DeepInfraConversationalTask(),
|
|
45
|
+
"text-generation": new DeepInfra.DeepInfraTextGenerationTask(),
|
|
46
|
+
},
|
|
41
47
|
"fal-ai": {
|
|
42
48
|
"automatic-speech-recognition": new FalAI.FalAIAutomaticSpeechRecognitionTask(),
|
|
43
49
|
"image-text-to-image": new FalAI.FalAIImageTextToImageTask(),
|
|
@@ -110,6 +116,9 @@ export const PROVIDERS = {
|
|
|
110
116
|
"text-to-image": new Nscale.NscaleTextToImageTask(),
|
|
111
117
|
conversational: new Nscale.NscaleConversationalTask(),
|
|
112
118
|
},
|
|
119
|
+
nvidia: {
|
|
120
|
+
conversational: new Nvidia.NvidiaConversationalTask(),
|
|
121
|
+
},
|
|
113
122
|
openai: {
|
|
114
123
|
conversational: new OpenAI.OpenAIConversationalTask(),
|
|
115
124
|
},
|
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.13";
|
|
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,CAiC9C,CAAC"}
|
|
@@ -17,6 +17,7 @@ export const HARDCODED_MODEL_INFERENCE_MAPPING = {
|
|
|
17
17
|
cerebras: {},
|
|
18
18
|
clarifai: {},
|
|
19
19
|
cohere: {},
|
|
20
|
+
deepinfra: {},
|
|
20
21
|
"fal-ai": {},
|
|
21
22
|
"featherless-ai": {},
|
|
22
23
|
"fireworks-ai": {},
|
|
@@ -26,6 +27,7 @@ export const HARDCODED_MODEL_INFERENCE_MAPPING = {
|
|
|
26
27
|
nebius: {},
|
|
27
28
|
novita: {},
|
|
28
29
|
nscale: {},
|
|
30
|
+
nvidia: {},
|
|
29
31
|
openai: {},
|
|
30
32
|
publicai: {},
|
|
31
33
|
ovhcloud: {},
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* See the registered mapping of HF model ID => DeepInfra model ID here:
|
|
3
|
+
*
|
|
4
|
+
* https://huggingface.co/api/partners/deepinfra/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
|
|
9
|
+
it's registered on huggingface.co,
|
|
10
|
+
* you can add it to the dictionary "HARDCODED_MODEL_ID_MAPPING" in
|
|
11
|
+
consts.ts, for dev purposes.
|
|
12
|
+
*
|
|
13
|
+
* - If you work at DeepInfra and want to update this mapping, please
|
|
14
|
+
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
|
|
16
|
+
model to DeepInfra, please open an issue on the present repo
|
|
17
|
+
* and we will tag DeepInfra team members.
|
|
18
|
+
*
|
|
19
|
+
* Thanks!
|
|
20
|
+
*/
|
|
21
|
+
import type { TextGenerationOutput } from "@huggingface/tasks";
|
|
22
|
+
import type { BodyParams } from "../types.js";
|
|
23
|
+
import { BaseConversationalTask, BaseTextGenerationTask } from "./providerHelper.js";
|
|
24
|
+
interface DeepInfraCompletionChoice {
|
|
25
|
+
text?: string;
|
|
26
|
+
}
|
|
27
|
+
interface DeepInfraCompletionResponse {
|
|
28
|
+
choices: DeepInfraCompletionChoice[];
|
|
29
|
+
model: string;
|
|
30
|
+
}
|
|
31
|
+
export declare class DeepInfraConversationalTask extends BaseConversationalTask {
|
|
32
|
+
constructor();
|
|
33
|
+
makeRoute(): string;
|
|
34
|
+
}
|
|
35
|
+
export declare class DeepInfraTextGenerationTask extends BaseTextGenerationTask {
|
|
36
|
+
constructor();
|
|
37
|
+
makeRoute(): string;
|
|
38
|
+
preparePayload(params: BodyParams): Record<string, unknown>;
|
|
39
|
+
getResponse(response: DeepInfraCompletionResponse): Promise<TextGenerationOutput>;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=deepinfra.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepinfra.d.ts","sourceRoot":"","sources":["../../../src/providers/deepinfra.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;EAmBE;AAEF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAOrF,UAAU,yBAAyB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,UAAU,2BAA2B;IACpC,OAAO,EAAE,yBAAyB,EAAE,CAAC;IACrC,KAAK,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,2BAA4B,SAAQ,sBAAsB;;IAK7D,SAAS,IAAI,MAAM;CAG5B;AAED,qBAAa,2BAA4B,SAAQ,sBAAsB;;IAK7D,SAAS,IAAI,MAAM;IAInB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAgBrD,WAAW,CAAC,QAAQ,EAAE,2BAA2B,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAiBhG"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* See the registered mapping of HF model ID => DeepInfra model ID here:
|
|
3
|
+
*
|
|
4
|
+
* https://huggingface.co/api/partners/deepinfra/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
|
|
9
|
+
it's registered on huggingface.co,
|
|
10
|
+
* you can add it to the dictionary "HARDCODED_MODEL_ID_MAPPING" in
|
|
11
|
+
consts.ts, for dev purposes.
|
|
12
|
+
*
|
|
13
|
+
* - If you work at DeepInfra and want to update this mapping, please
|
|
14
|
+
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
|
|
16
|
+
model to DeepInfra, please open an issue on the present repo
|
|
17
|
+
* and we will tag DeepInfra team members.
|
|
18
|
+
*
|
|
19
|
+
* Thanks!
|
|
20
|
+
*/
|
|
21
|
+
import { InferenceClientProviderOutputError } from "../errors.js";
|
|
22
|
+
import { omit } from "../utils/omit.js";
|
|
23
|
+
import { BaseConversationalTask, BaseTextGenerationTask } from "./providerHelper.js";
|
|
24
|
+
/**
|
|
25
|
+
* DeepInfra exposes OpenAI-compatible endpoints under the /v1/openai namespace.
|
|
26
|
+
*/
|
|
27
|
+
const DEEPINFRA_API_BASE_URL = "https://api.deepinfra.com";
|
|
28
|
+
export class DeepInfraConversationalTask extends BaseConversationalTask {
|
|
29
|
+
constructor() {
|
|
30
|
+
super("deepinfra", DEEPINFRA_API_BASE_URL);
|
|
31
|
+
}
|
|
32
|
+
makeRoute() {
|
|
33
|
+
return "v1/openai/chat/completions";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export class DeepInfraTextGenerationTask extends BaseTextGenerationTask {
|
|
37
|
+
constructor() {
|
|
38
|
+
super("deepinfra", DEEPINFRA_API_BASE_URL);
|
|
39
|
+
}
|
|
40
|
+
makeRoute() {
|
|
41
|
+
return "v1/openai/completions";
|
|
42
|
+
}
|
|
43
|
+
preparePayload(params) {
|
|
44
|
+
const parameters = params.args.parameters;
|
|
45
|
+
const res = {
|
|
46
|
+
model: params.model,
|
|
47
|
+
prompt: params.args.inputs,
|
|
48
|
+
...omit(params.args, ["inputs", "parameters"]),
|
|
49
|
+
...(parameters
|
|
50
|
+
? {
|
|
51
|
+
max_tokens: parameters.max_new_tokens,
|
|
52
|
+
...omit(parameters, ["max_new_tokens"]),
|
|
53
|
+
}
|
|
54
|
+
: undefined),
|
|
55
|
+
};
|
|
56
|
+
return res;
|
|
57
|
+
}
|
|
58
|
+
async getResponse(response) {
|
|
59
|
+
if (typeof response === "object" &&
|
|
60
|
+
response !== null &&
|
|
61
|
+
Array.isArray(response.choices) &&
|
|
62
|
+
response.choices.length > 0) {
|
|
63
|
+
const completion = response.choices[0].text;
|
|
64
|
+
if (typeof completion === "string") {
|
|
65
|
+
return { generated_text: completion };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
throw new InferenceClientProviderOutputError("Received malformed response from DeepInfra text-generation API: expected OpenAI completion payload");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* See the registered mapping of HF model ID => NVIDIA model ID here:
|
|
3
|
+
*
|
|
4
|
+
* https://huggingface.co/api/partners/nvidia/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 NVIDIA 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 NVIDIA, please open an issue on the present repo
|
|
13
|
+
* and we will tag NVIDIA team members.
|
|
14
|
+
*
|
|
15
|
+
* Thanks!
|
|
16
|
+
*/
|
|
17
|
+
import { BaseConversationalTask } from "./providerHelper.js";
|
|
18
|
+
export declare class NvidiaConversationalTask extends BaseConversationalTask {
|
|
19
|
+
constructor();
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=nvidia.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nvidia.d.ts","sourceRoot":"","sources":["../../../src/providers/nvidia.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,qBAAa,wBAAyB,SAAQ,sBAAsB;;CAInE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* See the registered mapping of HF model ID => NVIDIA model ID here:
|
|
3
|
+
*
|
|
4
|
+
* https://huggingface.co/api/partners/nvidia/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 NVIDIA 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 NVIDIA, please open an issue on the present repo
|
|
13
|
+
* and we will tag NVIDIA team members.
|
|
14
|
+
*
|
|
15
|
+
* Thanks!
|
|
16
|
+
*/
|
|
17
|
+
import { BaseConversationalTask } from "./providerHelper.js";
|
|
18
|
+
export class NvidiaConversationalTask extends BaseConversationalTask {
|
|
19
|
+
constructor() {
|
|
20
|
+
super("nvidia", "https://integrate.api.nvidia.com");
|
|
21
|
+
}
|
|
22
|
+
}
|
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 ["baseten", "black-forest-labs", "cerebras", "clarifai", "cohere", "fal-ai", "featherless-ai", "fireworks-ai", "groq", "hf-inference", "hyperbolic", "nebius", "novita", "nscale", "openai", "ovhcloud", "publicai", "replicate", "sambanova", "scaleway", "together", "wavespeed", "zai-org"];
|
|
40
|
-
export declare const PROVIDERS_OR_POLICIES: readonly ["baseten", "black-forest-labs", "cerebras", "clarifai", "cohere", "fal-ai", "featherless-ai", "fireworks-ai", "groq", "hf-inference", "hyperbolic", "nebius", "novita", "nscale", "openai", "ovhcloud", "publicai", "replicate", "sambanova", "scaleway", "together", "wavespeed", "zai-org", "auto"];
|
|
39
|
+
export declare const INFERENCE_PROVIDERS: readonly ["baseten", "black-forest-labs", "cerebras", "clarifai", "cohere", "deepinfra", "fal-ai", "featherless-ai", "fireworks-ai", "groq", "hf-inference", "hyperbolic", "nebius", "novita", "nscale", "nvidia", "openai", "ovhcloud", "publicai", "replicate", "sambanova", "scaleway", "together", "wavespeed", "zai-org"];
|
|
40
|
+
export declare const PROVIDERS_OR_POLICIES: readonly ["baseten", "black-forest-labs", "cerebras", "clarifai", "cohere", "deepinfra", "fal-ai", "featherless-ai", "fireworks-ai", "groq", "hf-inference", "hyperbolic", "nebius", "novita", "nscale", "nvidia", "openai", "ovhcloud", "publicai", "replicate", "sambanova", "scaleway", "together", "wavespeed", "zai-org", "auto"];
|
|
41
41
|
export type InferenceProvider = (typeof INFERENCE_PROVIDERS)[number];
|
|
42
42
|
export type InferenceProviderOrPolicy = (typeof PROVIDERS_OR_POLICIES)[number];
|
|
43
43
|
/**
|
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,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AG,EAAE,MAAM,KAAK,MAAM,CAAC;CACvC;AAED,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7D,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;IACrB,UAAU,CAAC,EAAE,UAAU,CAAC;CACxB"}
|
package/dist/esm/types.js
CHANGED
|
@@ -4,6 +4,7 @@ export const INFERENCE_PROVIDERS = [
|
|
|
4
4
|
"cerebras",
|
|
5
5
|
"clarifai",
|
|
6
6
|
"cohere",
|
|
7
|
+
"deepinfra",
|
|
7
8
|
"fal-ai",
|
|
8
9
|
"featherless-ai",
|
|
9
10
|
"fireworks-ai",
|
|
@@ -13,6 +14,7 @@ export const INFERENCE_PROVIDERS = [
|
|
|
13
14
|
"nebius",
|
|
14
15
|
"novita",
|
|
15
16
|
"nscale",
|
|
17
|
+
"nvidia",
|
|
16
18
|
"openai",
|
|
17
19
|
"ovhcloud",
|
|
18
20
|
"publicai",
|
|
@@ -35,6 +37,7 @@ export const PROVIDERS_HUB_ORGS = {
|
|
|
35
37
|
cerebras: "cerebras",
|
|
36
38
|
clarifai: "clarifai",
|
|
37
39
|
cohere: "CohereLabs",
|
|
40
|
+
deepinfra: "DeepInfra",
|
|
38
41
|
"fal-ai": "fal",
|
|
39
42
|
"featherless-ai": "featherless-ai",
|
|
40
43
|
"fireworks-ai": "fireworks-ai",
|
|
@@ -44,6 +47,7 @@ export const PROVIDERS_HUB_ORGS = {
|
|
|
44
47
|
nebius: "nebius",
|
|
45
48
|
novita: "novita",
|
|
46
49
|
nscale: "nscale",
|
|
50
|
+
nvidia: "nvidia",
|
|
47
51
|
openai: "openai",
|
|
48
52
|
ovhcloud: "ovhcloud",
|
|
49
53
|
publicai: "publicai",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huggingface/inference",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.13",
|
|
4
4
|
"description": "Typescript client for the Hugging Face Inference Providers and Inference Endpoints",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@huggingface/jinja": "^0.5.
|
|
48
|
-
"@huggingface/tasks": "^0.19.
|
|
47
|
+
"@huggingface/jinja": "^0.5.5",
|
|
48
|
+
"@huggingface/tasks": "^0.19.85"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "18.13.0"
|
|
@@ -3,6 +3,7 @@ import * as Clarifai from "../providers/clarifai.js";
|
|
|
3
3
|
import * as BlackForestLabs from "../providers/black-forest-labs.js";
|
|
4
4
|
import * as Cerebras from "../providers/cerebras.js";
|
|
5
5
|
import * as Cohere from "../providers/cohere.js";
|
|
6
|
+
import * as DeepInfra from "../providers/deepinfra.js";
|
|
6
7
|
import * as FalAI from "../providers/fal-ai.js";
|
|
7
8
|
import * as FeatherlessAI from "../providers/featherless-ai.js";
|
|
8
9
|
import * as Fireworks from "../providers/fireworks-ai.js";
|
|
@@ -12,6 +13,7 @@ import * as Hyperbolic from "../providers/hyperbolic.js";
|
|
|
12
13
|
import * as Nebius from "../providers/nebius.js";
|
|
13
14
|
import * as Novita from "../providers/novita.js";
|
|
14
15
|
import * as Nscale from "../providers/nscale.js";
|
|
16
|
+
import * as Nvidia from "../providers/nvidia.js";
|
|
15
17
|
import * as OpenAI from "../providers/openai.js";
|
|
16
18
|
import * as OvhCloud from "../providers/ovhcloud.js";
|
|
17
19
|
import * as PublicAI from "../providers/publicai.js";
|
|
@@ -75,6 +77,10 @@ export const PROVIDERS: Record<InferenceProvider, Partial<Record<InferenceTask,
|
|
|
75
77
|
cohere: {
|
|
76
78
|
conversational: new Cohere.CohereConversationalTask(),
|
|
77
79
|
},
|
|
80
|
+
deepinfra: {
|
|
81
|
+
conversational: new DeepInfra.DeepInfraConversationalTask(),
|
|
82
|
+
"text-generation": new DeepInfra.DeepInfraTextGenerationTask(),
|
|
83
|
+
},
|
|
78
84
|
"fal-ai": {
|
|
79
85
|
"automatic-speech-recognition": new FalAI.FalAIAutomaticSpeechRecognitionTask(),
|
|
80
86
|
"image-text-to-image": new FalAI.FalAIImageTextToImageTask(),
|
|
@@ -147,6 +153,9 @@ export const PROVIDERS: Record<InferenceProvider, Partial<Record<InferenceTask,
|
|
|
147
153
|
"text-to-image": new Nscale.NscaleTextToImageTask(),
|
|
148
154
|
conversational: new Nscale.NscaleConversationalTask(),
|
|
149
155
|
},
|
|
156
|
+
nvidia: {
|
|
157
|
+
conversational: new Nvidia.NvidiaConversationalTask(),
|
|
158
|
+
},
|
|
150
159
|
openai: {
|
|
151
160
|
conversational: new OpenAI.OpenAIConversationalTask(),
|
|
152
161
|
},
|
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.13";
|
|
3
3
|
export const PACKAGE_NAME = "@huggingface/inference";
|
package/src/providers/consts.ts
CHANGED
|
@@ -23,6 +23,7 @@ export const HARDCODED_MODEL_INFERENCE_MAPPING: Record<
|
|
|
23
23
|
cerebras: {},
|
|
24
24
|
clarifai: {},
|
|
25
25
|
cohere: {},
|
|
26
|
+
deepinfra: {},
|
|
26
27
|
"fal-ai": {},
|
|
27
28
|
"featherless-ai": {},
|
|
28
29
|
"fireworks-ai": {},
|
|
@@ -32,6 +33,7 @@ export const HARDCODED_MODEL_INFERENCE_MAPPING: Record<
|
|
|
32
33
|
nebius: {},
|
|
33
34
|
novita: {},
|
|
34
35
|
nscale: {},
|
|
36
|
+
nvidia: {},
|
|
35
37
|
openai: {},
|
|
36
38
|
publicai: {},
|
|
37
39
|
ovhcloud: {},
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* See the registered mapping of HF model ID => DeepInfra model ID here:
|
|
3
|
+
*
|
|
4
|
+
* https://huggingface.co/api/partners/deepinfra/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
|
|
9
|
+
it's registered on huggingface.co,
|
|
10
|
+
* you can add it to the dictionary "HARDCODED_MODEL_ID_MAPPING" in
|
|
11
|
+
consts.ts, for dev purposes.
|
|
12
|
+
*
|
|
13
|
+
* - If you work at DeepInfra and want to update this mapping, please
|
|
14
|
+
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
|
|
16
|
+
model to DeepInfra, please open an issue on the present repo
|
|
17
|
+
* and we will tag DeepInfra team members.
|
|
18
|
+
*
|
|
19
|
+
* Thanks!
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import type { TextGenerationOutput } from "@huggingface/tasks";
|
|
23
|
+
import { InferenceClientProviderOutputError } from "../errors.js";
|
|
24
|
+
import type { BodyParams } from "../types.js";
|
|
25
|
+
import { omit } from "../utils/omit.js";
|
|
26
|
+
import { BaseConversationalTask, BaseTextGenerationTask } from "./providerHelper.js";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* DeepInfra exposes OpenAI-compatible endpoints under the /v1/openai namespace.
|
|
30
|
+
*/
|
|
31
|
+
const DEEPINFRA_API_BASE_URL = "https://api.deepinfra.com";
|
|
32
|
+
|
|
33
|
+
interface DeepInfraCompletionChoice {
|
|
34
|
+
text?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface DeepInfraCompletionResponse {
|
|
38
|
+
choices: DeepInfraCompletionChoice[];
|
|
39
|
+
model: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export class DeepInfraConversationalTask extends BaseConversationalTask {
|
|
43
|
+
constructor() {
|
|
44
|
+
super("deepinfra", DEEPINFRA_API_BASE_URL);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
override makeRoute(): string {
|
|
48
|
+
return "v1/openai/chat/completions";
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export class DeepInfraTextGenerationTask extends BaseTextGenerationTask {
|
|
53
|
+
constructor() {
|
|
54
|
+
super("deepinfra", DEEPINFRA_API_BASE_URL);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
override makeRoute(): string {
|
|
58
|
+
return "v1/openai/completions";
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
override preparePayload(params: BodyParams): Record<string, unknown> {
|
|
62
|
+
const parameters = params.args.parameters as Record<string, unknown> | undefined;
|
|
63
|
+
const res = {
|
|
64
|
+
model: params.model,
|
|
65
|
+
prompt: params.args.inputs,
|
|
66
|
+
...omit(params.args, ["inputs", "parameters"]),
|
|
67
|
+
...(parameters
|
|
68
|
+
? {
|
|
69
|
+
max_tokens: parameters.max_new_tokens,
|
|
70
|
+
...omit(parameters, ["max_new_tokens"]),
|
|
71
|
+
}
|
|
72
|
+
: undefined),
|
|
73
|
+
};
|
|
74
|
+
return res;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
override async getResponse(response: DeepInfraCompletionResponse): Promise<TextGenerationOutput> {
|
|
78
|
+
if (
|
|
79
|
+
typeof response === "object" &&
|
|
80
|
+
response !== null &&
|
|
81
|
+
Array.isArray(response.choices) &&
|
|
82
|
+
response.choices.length > 0
|
|
83
|
+
) {
|
|
84
|
+
const completion = response.choices[0].text;
|
|
85
|
+
if (typeof completion === "string") {
|
|
86
|
+
return { generated_text: completion };
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
throw new InferenceClientProviderOutputError(
|
|
91
|
+
"Received malformed response from DeepInfra text-generation API: expected OpenAI completion payload",
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* See the registered mapping of HF model ID => NVIDIA model ID here:
|
|
3
|
+
*
|
|
4
|
+
* https://huggingface.co/api/partners/nvidia/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 NVIDIA 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 NVIDIA, please open an issue on the present repo
|
|
13
|
+
* and we will tag NVIDIA team members.
|
|
14
|
+
*
|
|
15
|
+
* Thanks!
|
|
16
|
+
*/
|
|
17
|
+
import { BaseConversationalTask } from "./providerHelper.js";
|
|
18
|
+
|
|
19
|
+
export class NvidiaConversationalTask extends BaseConversationalTask {
|
|
20
|
+
constructor() {
|
|
21
|
+
super("nvidia", "https://integrate.api.nvidia.com");
|
|
22
|
+
}
|
|
23
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -50,6 +50,7 @@ export const INFERENCE_PROVIDERS = [
|
|
|
50
50
|
"cerebras",
|
|
51
51
|
"clarifai",
|
|
52
52
|
"cohere",
|
|
53
|
+
"deepinfra",
|
|
53
54
|
"fal-ai",
|
|
54
55
|
"featherless-ai",
|
|
55
56
|
"fireworks-ai",
|
|
@@ -59,6 +60,7 @@ export const INFERENCE_PROVIDERS = [
|
|
|
59
60
|
"nebius",
|
|
60
61
|
"novita",
|
|
61
62
|
"nscale",
|
|
63
|
+
"nvidia",
|
|
62
64
|
"openai",
|
|
63
65
|
"ovhcloud",
|
|
64
66
|
"publicai",
|
|
@@ -87,6 +89,7 @@ export const PROVIDERS_HUB_ORGS: Record<InferenceProvider, string> = {
|
|
|
87
89
|
cerebras: "cerebras",
|
|
88
90
|
clarifai: "clarifai",
|
|
89
91
|
cohere: "CohereLabs",
|
|
92
|
+
deepinfra: "DeepInfra",
|
|
90
93
|
"fal-ai": "fal",
|
|
91
94
|
"featherless-ai": "featherless-ai",
|
|
92
95
|
"fireworks-ai": "fireworks-ai",
|
|
@@ -96,6 +99,7 @@ export const PROVIDERS_HUB_ORGS: Record<InferenceProvider, string> = {
|
|
|
96
99
|
nebius: "nebius",
|
|
97
100
|
novita: "novita",
|
|
98
101
|
nscale: "nscale",
|
|
102
|
+
nvidia: "nvidia",
|
|
99
103
|
openai: "openai",
|
|
100
104
|
ovhcloud: "ovhcloud",
|
|
101
105
|
publicai: "publicai",
|