@huggingface/inference 3.11.0 → 3.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs
CHANGED
|
@@ -252,7 +252,7 @@ var HFInferenceTask = class extends TaskProviderHelper {
|
|
|
252
252
|
}
|
|
253
253
|
makeRoute(params) {
|
|
254
254
|
if (params.task && ["feature-extraction", "sentence-similarity"].includes(params.task)) {
|
|
255
|
-
return `
|
|
255
|
+
return `models/${params.model}/pipeline/${params.task}`;
|
|
256
256
|
}
|
|
257
257
|
return `models/${params.model}`;
|
|
258
258
|
}
|
|
@@ -1201,6 +1201,17 @@ var ReplicateTask = class extends TaskProviderHelper {
|
|
|
1201
1201
|
}
|
|
1202
1202
|
};
|
|
1203
1203
|
var ReplicateTextToImageTask = class extends ReplicateTask {
|
|
1204
|
+
preparePayload(params) {
|
|
1205
|
+
return {
|
|
1206
|
+
input: {
|
|
1207
|
+
...omit(params.args, ["inputs", "parameters"]),
|
|
1208
|
+
...params.args.parameters,
|
|
1209
|
+
prompt: params.args.inputs,
|
|
1210
|
+
lora_weights: params.mapping?.adapter === "lora" && params.mapping.adapterWeightsPath ? `https://huggingface.co/${params.mapping.hfModelId}` : void 0
|
|
1211
|
+
},
|
|
1212
|
+
version: params.model.includes(":") ? params.model.split(":")[1] : void 0
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1204
1215
|
async getResponse(res, url, headers, outputType) {
|
|
1205
1216
|
if (typeof res === "object" && "output" in res && Array.isArray(res.output) && res.output.length > 0 && typeof res.output[0] === "string") {
|
|
1206
1217
|
if (outputType === "url") {
|
|
@@ -1458,7 +1469,7 @@ function getProviderHelper(provider, task) {
|
|
|
1458
1469
|
|
|
1459
1470
|
// package.json
|
|
1460
1471
|
var name = "@huggingface/inference";
|
|
1461
|
-
var version = "3.
|
|
1472
|
+
var version = "3.12.1";
|
|
1462
1473
|
|
|
1463
1474
|
// src/lib/makeRequestOptions.ts
|
|
1464
1475
|
var tasks = null;
|
package/dist/index.js
CHANGED
|
@@ -194,7 +194,7 @@ var HFInferenceTask = class extends TaskProviderHelper {
|
|
|
194
194
|
}
|
|
195
195
|
makeRoute(params) {
|
|
196
196
|
if (params.task && ["feature-extraction", "sentence-similarity"].includes(params.task)) {
|
|
197
|
-
return `
|
|
197
|
+
return `models/${params.model}/pipeline/${params.task}`;
|
|
198
198
|
}
|
|
199
199
|
return `models/${params.model}`;
|
|
200
200
|
}
|
|
@@ -1143,6 +1143,17 @@ var ReplicateTask = class extends TaskProviderHelper {
|
|
|
1143
1143
|
}
|
|
1144
1144
|
};
|
|
1145
1145
|
var ReplicateTextToImageTask = class extends ReplicateTask {
|
|
1146
|
+
preparePayload(params) {
|
|
1147
|
+
return {
|
|
1148
|
+
input: {
|
|
1149
|
+
...omit(params.args, ["inputs", "parameters"]),
|
|
1150
|
+
...params.args.parameters,
|
|
1151
|
+
prompt: params.args.inputs,
|
|
1152
|
+
lora_weights: params.mapping?.adapter === "lora" && params.mapping.adapterWeightsPath ? `https://huggingface.co/${params.mapping.hfModelId}` : void 0
|
|
1153
|
+
},
|
|
1154
|
+
version: params.model.includes(":") ? params.model.split(":")[1] : void 0
|
|
1155
|
+
};
|
|
1156
|
+
}
|
|
1146
1157
|
async getResponse(res, url, headers, outputType) {
|
|
1147
1158
|
if (typeof res === "object" && "output" in res && Array.isArray(res.output) && res.output.length > 0 && typeof res.output[0] === "string") {
|
|
1148
1159
|
if (outputType === "url") {
|
|
@@ -1400,7 +1411,7 @@ function getProviderHelper(provider, task) {
|
|
|
1400
1411
|
|
|
1401
1412
|
// package.json
|
|
1402
1413
|
var name = "@huggingface/inference";
|
|
1403
|
-
var version = "3.
|
|
1414
|
+
var version = "3.12.1";
|
|
1404
1415
|
|
|
1405
1416
|
// src/lib/makeRequestOptions.ts
|
|
1406
1417
|
var tasks = null;
|
|
@@ -11,6 +11,7 @@ declare abstract class ReplicateTask extends TaskProviderHelper {
|
|
|
11
11
|
makeUrl(params: UrlParams): string;
|
|
12
12
|
}
|
|
13
13
|
export declare class ReplicateTextToImageTask extends ReplicateTask implements TextToImageTaskHelper {
|
|
14
|
+
preparePayload(params: BodyParams): Record<string, unknown>;
|
|
14
15
|
getResponse(res: ReplicateOutput | Blob, url?: string, headers?: Record<string, string>, outputType?: "url" | "blob"): Promise<string | Blob>;
|
|
15
16
|
}
|
|
16
17
|
export declare class ReplicateTextToSpeechTask extends ReplicateTask {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replicate.d.ts","sourceRoot":"","sources":["../../../src/providers/replicate.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEpE,OAAO,EAAE,kBAAkB,EAAE,KAAK,qBAAqB,EAAE,KAAK,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"replicate.d.ts","sourceRoot":"","sources":["../../../src/providers/replicate.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEpE,OAAO,EAAE,kBAAkB,EAAE,KAAK,qBAAqB,EAAE,KAAK,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC9G,MAAM,WAAW,eAAe;IAC/B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC3B;AAED,uBAAe,aAAc,SAAQ,kBAAkB;gBAC1C,GAAG,CAAC,EAAE,MAAM;IAIxB,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM;IAMpC,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAUlD,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAQ7E,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM;CAO3C;AAED,qBAAa,wBAAyB,SAAQ,aAAc,YAAW,qBAAqB;IAClF,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAerD,WAAW,CACzB,GAAG,EAAE,eAAe,GAAG,IAAI,EAC3B,GAAG,CAAC,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,UAAU,CAAC,EAAE,KAAK,GAAG,MAAM,GACzB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAmBzB;AAED,qBAAa,yBAA0B,SAAQ,aAAa;IAClD,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAarD,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAiBpE;AAED,qBAAa,wBAAyB,SAAQ,aAAc,YAAW,qBAAqB;IAC5E,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAcpE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huggingface/inference",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.12.1",
|
|
4
4
|
"packageManager": "pnpm@8.10.5",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Hugging Face and Tim Mikeladze <tim.mikeladze@gmail.com>",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
},
|
|
41
41
|
"type": "module",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@huggingface/
|
|
44
|
-
"@huggingface/
|
|
43
|
+
"@huggingface/jinja": "^0.4.1",
|
|
44
|
+
"@huggingface/tasks": "^0.19.2"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/node": "18.13.0"
|
|
@@ -106,7 +106,7 @@ export class HFInferenceTask extends TaskProviderHelper {
|
|
|
106
106
|
makeRoute(params: UrlParams): string {
|
|
107
107
|
if (params.task && ["feature-extraction", "sentence-similarity"].includes(params.task)) {
|
|
108
108
|
// when deployed on hf-inference, those two tasks are automatically compatible with one another.
|
|
109
|
-
return `
|
|
109
|
+
return `models/${params.model}/pipeline/${params.task}`;
|
|
110
110
|
}
|
|
111
111
|
return `models/${params.model}`;
|
|
112
112
|
}
|
|
@@ -19,7 +19,6 @@ import { isUrl } from "../lib/isUrl";
|
|
|
19
19
|
import type { BodyParams, HeaderParams, UrlParams } from "../types";
|
|
20
20
|
import { omit } from "../utils/omit";
|
|
21
21
|
import { TaskProviderHelper, type TextToImageTaskHelper, type TextToVideoTaskHelper } from "./providerHelper";
|
|
22
|
-
|
|
23
22
|
export interface ReplicateOutput {
|
|
24
23
|
output?: string | string[];
|
|
25
24
|
}
|
|
@@ -63,6 +62,21 @@ abstract class ReplicateTask extends TaskProviderHelper {
|
|
|
63
62
|
}
|
|
64
63
|
|
|
65
64
|
export class ReplicateTextToImageTask extends ReplicateTask implements TextToImageTaskHelper {
|
|
65
|
+
override preparePayload(params: BodyParams): Record<string, unknown> {
|
|
66
|
+
return {
|
|
67
|
+
input: {
|
|
68
|
+
...omit(params.args, ["inputs", "parameters"]),
|
|
69
|
+
...(params.args.parameters as Record<string, unknown>),
|
|
70
|
+
prompt: params.args.inputs,
|
|
71
|
+
lora_weights:
|
|
72
|
+
params.mapping?.adapter === "lora" && params.mapping.adapterWeightsPath
|
|
73
|
+
? `https://huggingface.co/${params.mapping.hfModelId}`
|
|
74
|
+
: undefined,
|
|
75
|
+
},
|
|
76
|
+
version: params.model.includes(":") ? params.model.split(":")[1] : undefined,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
66
80
|
override async getResponse(
|
|
67
81
|
res: ReplicateOutput | Blob,
|
|
68
82
|
url?: string,
|