@huggingface/inference 4.3.0 → 4.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/lib/getInferenceProviderMapping.d.ts.map +1 -1
- package/dist/commonjs/lib/getInferenceProviderMapping.js +3 -0
- package/dist/commonjs/package.d.ts +1 -1
- package/dist/commonjs/package.js +1 -1
- package/dist/commonjs/providers/nebius.d.ts +2 -0
- package/dist/commonjs/providers/nebius.d.ts.map +1 -1
- package/dist/commonjs/providers/nebius.js +8 -0
- package/dist/commonjs/providers/sambanova.d.ts +2 -0
- package/dist/commonjs/providers/sambanova.d.ts.map +1 -1
- package/dist/commonjs/providers/sambanova.js +10 -0
- package/dist/commonjs/providers/together.d.ts +2 -0
- package/dist/commonjs/providers/together.d.ts.map +1 -1
- package/dist/commonjs/providers/together.js +11 -0
- package/dist/commonjs/utils/request.d.ts.map +1 -1
- package/dist/commonjs/utils/request.js +28 -18
- package/dist/esm/lib/getInferenceProviderMapping.d.ts.map +1 -1
- package/dist/esm/lib/getInferenceProviderMapping.js +3 -0
- package/dist/esm/package.d.ts +1 -1
- package/dist/esm/package.js +1 -1
- package/dist/esm/providers/nebius.d.ts +2 -0
- package/dist/esm/providers/nebius.d.ts.map +1 -1
- package/dist/esm/providers/nebius.js +8 -0
- package/dist/esm/providers/sambanova.d.ts +2 -0
- package/dist/esm/providers/sambanova.d.ts.map +1 -1
- package/dist/esm/providers/sambanova.js +10 -0
- package/dist/esm/providers/together.d.ts +2 -0
- package/dist/esm/providers/together.d.ts.map +1 -1
- package/dist/esm/providers/together.js +11 -0
- package/dist/esm/utils/request.d.ts.map +1 -1
- package/dist/esm/utils/request.js +28 -18
- package/package.json +2 -2
- package/src/lib/getInferenceProviderMapping.ts +13 -1
- package/src/package.ts +1 -1
- package/src/providers/nebius.ts +12 -0
- package/src/providers/sambanova.ts +14 -0
- package/src/providers/together.ts +17 -0
- package/src/utils/request.ts +26 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getInferenceProviderMapping.d.ts","sourceRoot":"","sources":["../../../src/lib/getInferenceProviderMapping.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,yBAAyB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAIxH,eAAO,MAAM,6BAA6B,8CAAsD,CAAC;
|
|
1
|
+
{"version":3,"file":"getInferenceProviderMapping.d.ts","sourceRoot":"","sources":["../../../src/lib/getInferenceProviderMapping.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,yBAAyB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAIxH,eAAO,MAAM,6BAA6B,8CAAsD,CAAC;AA4CjG,wBAAsB,qCAAqC,CAC1D,OAAO,EAAE,OAAO,EAChB,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE;IACT,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;CACtE,GACC,OAAO,CAAC,6BAA6B,EAAE,CAAC,CAqD1C;AAED,wBAAsB,2BAA2B,CAChD,MAAM,EAAE;IACP,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,IAAI,EAAE,UAAU,CAAC;CACjB,EACD,OAAO,EAAE;IACR,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;CACtE,GACC,OAAO,CAAC,6BAA6B,GAAG,IAAI,CAAC,CAwB/C;AAED,wBAAsB,eAAe,CACpC,QAAQ,CAAC,EAAE,yBAAyB,EACpC,OAAO,CAAC,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,iBAAiB,CAAC,CA0B5B"}
|
|
@@ -31,6 +31,8 @@ function normalizeInferenceProviderMapping(modelId, inferenceProviderMapping) {
|
|
|
31
31
|
providerId: mapping.providerId,
|
|
32
32
|
status: mapping.status,
|
|
33
33
|
task: mapping.task,
|
|
34
|
+
adapter: mapping.adapter,
|
|
35
|
+
adapterWeightsPath: mapping.adapterWeightsPath,
|
|
34
36
|
}));
|
|
35
37
|
}
|
|
36
38
|
async function fetchInferenceProviderMappingForModel(modelId, accessToken, options) {
|
|
@@ -108,6 +110,7 @@ async function resolveProvider(provider, modelId, endpointUrl) {
|
|
|
108
110
|
}
|
|
109
111
|
const mappings = await fetchInferenceProviderMappingForModel(modelId);
|
|
110
112
|
provider = mappings[0]?.provider;
|
|
113
|
+
console.log("Auto selected provider:", provider);
|
|
111
114
|
}
|
|
112
115
|
if (!provider) {
|
|
113
116
|
throw new errors_js_1.InferenceClientInputError(`No Inference Provider available for model ${modelId}.`);
|
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.3.
|
|
5
|
+
exports.PACKAGE_VERSION = "4.3.2";
|
|
6
6
|
exports.PACKAGE_NAME = "@huggingface/inference";
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import type { FeatureExtractionOutput, TextGenerationOutput } from "@huggingface/tasks";
|
|
18
18
|
import type { BodyParams } from "../types.js";
|
|
19
19
|
import { BaseConversationalTask, BaseTextGenerationTask, TaskProviderHelper, type FeatureExtractionTaskHelper, type TextToImageTaskHelper } from "./providerHelper.js";
|
|
20
|
+
import type { ChatCompletionInput } from "../../../tasks/dist/commonjs/index.js";
|
|
20
21
|
interface NebiusBase64ImageGeneration {
|
|
21
22
|
data: Array<{
|
|
22
23
|
b64_json: string;
|
|
@@ -34,6 +35,7 @@ interface NebiusTextGenerationOutput extends Omit<TextGenerationOutput, "choices
|
|
|
34
35
|
}
|
|
35
36
|
export declare class NebiusConversationalTask extends BaseConversationalTask {
|
|
36
37
|
constructor();
|
|
38
|
+
preparePayload(params: BodyParams<ChatCompletionInput>): Record<string, unknown>;
|
|
37
39
|
}
|
|
38
40
|
export declare class NebiusTextGenerationTask extends BaseTextGenerationTask {
|
|
39
41
|
constructor();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nebius.d.ts","sourceRoot":"","sources":["../../../src/providers/nebius.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACxF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,KAAK,2BAA2B,EAChC,KAAK,qBAAqB,EAC1B,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"nebius.d.ts","sourceRoot":"","sources":["../../../src/providers/nebius.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACxF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,KAAK,2BAA2B,EAChC,KAAK,qBAAqB,EAC1B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAIjF,UAAU,2BAA2B;IACpC,IAAI,EAAE,KAAK,CAAC;QACX,QAAQ,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;CACH;AAED,UAAU,wBAAwB;IACjC,IAAI,EAAE,KAAK,CAAC;QACX,SAAS,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC,CAAC;CACH;AAED,UAAU,0BAA2B,SAAQ,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC;IACjF,OAAO,EAAE,KAAK,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;KACb,CAAC,CAAC;CACH;AAED,qBAAa,wBAAyB,SAAQ,sBAAsB;;IAK1D,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,mBAAmB,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAUzF;AAED,qBAAa,wBAAyB,SAAQ,sBAAsB;;IAK1D,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAQrD,WAAW,CAAC,QAAQ,EAAE,0BAA0B,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAc/F;AAED,qBAAa,qBAAsB,SAAQ,kBAAmB,YAAW,qBAAqB;;IAK7F,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAU3D,SAAS,IAAI,MAAM;IAIb,WAAW,CAChB,QAAQ,EAAE,2BAA2B,EACrC,GAAG,CAAC,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,WAAW,EACrB,UAAU,CAAC,EAAE,KAAK,GAAG,MAAM,GACzB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAkBzB;AAED,qBAAa,2BAA4B,SAAQ,kBAAmB,YAAW,2BAA2B;;IAKzG,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAO3D,SAAS,IAAI,MAAM;IAIb,WAAW,CAAC,QAAQ,EAAE,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,CAAC;CAGvF"}
|
|
@@ -9,6 +9,14 @@ class NebiusConversationalTask extends providerHelper_js_1.BaseConversationalTas
|
|
|
9
9
|
constructor() {
|
|
10
10
|
super("nebius", NEBIUS_API_BASE_URL);
|
|
11
11
|
}
|
|
12
|
+
preparePayload(params) {
|
|
13
|
+
const payload = super.preparePayload(params);
|
|
14
|
+
const responseFormat = params.args.response_format;
|
|
15
|
+
if (responseFormat?.type === "json_schema" && responseFormat.json_schema?.schema) {
|
|
16
|
+
payload["guided_json"] = responseFormat.json_schema.schema;
|
|
17
|
+
}
|
|
18
|
+
return payload;
|
|
19
|
+
}
|
|
12
20
|
}
|
|
13
21
|
exports.NebiusConversationalTask = NebiusConversationalTask;
|
|
14
22
|
class NebiusTextGenerationTask extends providerHelper_js_1.BaseTextGenerationTask {
|
|
@@ -18,8 +18,10 @@ import type { FeatureExtractionOutput } from "@huggingface/tasks";
|
|
|
18
18
|
import type { BodyParams } from "../types.js";
|
|
19
19
|
import type { FeatureExtractionTaskHelper } from "./providerHelper.js";
|
|
20
20
|
import { BaseConversationalTask, TaskProviderHelper } from "./providerHelper.js";
|
|
21
|
+
import type { ChatCompletionInput } from "../../../tasks/dist/commonjs/index.js";
|
|
21
22
|
export declare class SambanovaConversationalTask extends BaseConversationalTask {
|
|
22
23
|
constructor();
|
|
24
|
+
preparePayload(params: BodyParams<ChatCompletionInput>): Record<string, unknown>;
|
|
23
25
|
}
|
|
24
26
|
export declare class SambanovaFeatureExtractionTask extends TaskProviderHelper implements FeatureExtractionTaskHelper {
|
|
25
27
|
constructor();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sambanova.d.ts","sourceRoot":"","sources":["../../../src/providers/sambanova.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"sambanova.d.ts","sourceRoot":"","sources":["../../../src/providers/sambanova.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAEjF,qBAAa,2BAA4B,SAAQ,sBAAsB;;IAK7D,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,mBAAmB,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAYzF;AAED,qBAAa,8BAA+B,SAAQ,kBAAmB,YAAW,2BAA2B;;IAKnG,SAAS,IAAI,MAAM;IAIb,WAAW,CAAC,QAAQ,EAAE,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAStF,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAOpE"}
|
|
@@ -7,6 +7,16 @@ class SambanovaConversationalTask extends providerHelper_js_1.BaseConversational
|
|
|
7
7
|
constructor() {
|
|
8
8
|
super("sambanova", "https://api.sambanova.ai");
|
|
9
9
|
}
|
|
10
|
+
preparePayload(params) {
|
|
11
|
+
const responseFormat = params.args.response_format;
|
|
12
|
+
if (responseFormat?.type === "json_schema" && responseFormat.json_schema) {
|
|
13
|
+
if (responseFormat.json_schema.strict ?? true) {
|
|
14
|
+
responseFormat.json_schema.strict = false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const payload = super.preparePayload(params);
|
|
18
|
+
return payload;
|
|
19
|
+
}
|
|
10
20
|
}
|
|
11
21
|
exports.SambanovaConversationalTask = SambanovaConversationalTask;
|
|
12
22
|
class SambanovaFeatureExtractionTask extends providerHelper_js_1.TaskProviderHelper {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import type { ChatCompletionOutput, TextGenerationOutput, TextGenerationOutputFinishReason } from "@huggingface/tasks";
|
|
18
18
|
import type { BodyParams } from "../types.js";
|
|
19
19
|
import { BaseConversationalTask, BaseTextGenerationTask, TaskProviderHelper, type TextToImageTaskHelper } from "./providerHelper.js";
|
|
20
|
+
import type { ChatCompletionInput } from "../../../tasks/dist/commonjs/index.js";
|
|
20
21
|
interface TogetherTextCompletionOutput extends Omit<ChatCompletionOutput, "choices"> {
|
|
21
22
|
choices: Array<{
|
|
22
23
|
text: string;
|
|
@@ -33,6 +34,7 @@ interface TogetherBase64ImageGeneration {
|
|
|
33
34
|
}
|
|
34
35
|
export declare class TogetherConversationalTask extends BaseConversationalTask {
|
|
35
36
|
constructor();
|
|
37
|
+
preparePayload(params: BodyParams<ChatCompletionInput>): Record<string, unknown>;
|
|
36
38
|
}
|
|
37
39
|
export declare class TogetherTextGenerationTask extends BaseTextGenerationTask {
|
|
38
40
|
constructor();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"together.d.ts","sourceRoot":"","sources":["../../../src/providers/together.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AACvH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,KAAK,qBAAqB,EAC1B,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"together.d.ts","sourceRoot":"","sources":["../../../src/providers/together.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AACvH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,KAAK,qBAAqB,EAC1B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAIjF,UAAU,4BAA6B,SAAQ,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC;IACnF,OAAO,EAAE,KAAK,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,aAAa,EAAE,gCAAgC,CAAC;QAChD,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,OAAO,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;CACH;AAED,UAAU,6BAA6B;IACtC,IAAI,EAAE,KAAK,CAAC;QACX,QAAQ,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;CACH;AAED,qBAAa,0BAA2B,SAAQ,sBAAsB;;IAK5D,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,mBAAmB,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAezF;AAED,qBAAa,0BAA2B,SAAQ,sBAAsB;;IAK5D,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAQrD,WAAW,CAAC,QAAQ,EAAE,4BAA4B,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAcjG;AAED,qBAAa,uBAAwB,SAAQ,kBAAmB,YAAW,qBAAqB;;IAK/F,SAAS,IAAI,MAAM;IAInB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAUrD,WAAW,CAAC,QAAQ,EAAE,6BAA6B,EAAE,UAAU,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAkB/G"}
|
|
@@ -9,6 +9,17 @@ class TogetherConversationalTask extends providerHelper_js_1.BaseConversationalT
|
|
|
9
9
|
constructor() {
|
|
10
10
|
super("together", TOGETHER_API_BASE_URL);
|
|
11
11
|
}
|
|
12
|
+
preparePayload(params) {
|
|
13
|
+
const payload = super.preparePayload(params);
|
|
14
|
+
const response_format = payload.response_format;
|
|
15
|
+
if (response_format?.type === "json_schema" && response_format?.json_schema?.schema) {
|
|
16
|
+
payload.response_format = {
|
|
17
|
+
type: "json_schema",
|
|
18
|
+
schema: response_format.json_schema.schema,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return payload;
|
|
22
|
+
}
|
|
12
23
|
}
|
|
13
24
|
exports.TogetherConversationalTask = TogetherConversationalTask;
|
|
14
25
|
class TogetherTextGenerationTask extends providerHelper_js_1.BaseTextGenerationTask {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/utils/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAMvE,MAAM,WAAW,eAAe,CAAC,CAAC;IACjC,IAAI,EAAE,CAAC,CAAC;IACR,cAAc,EAAE;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,WAAW,CAAC;KAClB,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/utils/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAMvE,MAAM,WAAW,eAAe,CAAC,CAAC;IACjC,IAAI,EAAE,CAAC,CAAC;IACR,cAAc,EAAE;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,WAAW,CAAC;KAClB,CAAC;CACF;AAmBD;;GAEG;AACH,wBAAsB,YAAY,CAAC,CAAC,EACnC,IAAI,EAAE,WAAW,EACjB,cAAc,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,EACpD,OAAO,CAAC,EAAE,OAAO,GAAG;IACnB,oEAAoE;IACpE,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,oCAAoC;IACpC,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB,GACC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAwE7B;AAED;;GAEG;AACH,wBAAuB,qBAAqB,CAAC,CAAC,EAC7C,IAAI,EAAE,WAAW,EACjB,cAAc,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,EACpD,OAAO,CAAC,EAAE,OAAO,GAAG;IACnB,oEAAoE;IACpE,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,oCAAoC;IACpC,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB,GACC,cAAc,CAAC,CAAC,CAAC,CAuJnB"}
|
|
@@ -5,13 +5,23 @@ exports.innerStreamingRequest = innerStreamingRequest;
|
|
|
5
5
|
const makeRequestOptions_js_1 = require("../lib/makeRequestOptions.js");
|
|
6
6
|
const parse_js_1 = require("../vendor/fetch-event-source/parse.js");
|
|
7
7
|
const errors_js_1 = require("../errors.js");
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
function bodyToJson(body) {
|
|
9
|
+
let data = null;
|
|
10
|
+
if (body instanceof Blob || body instanceof ArrayBuffer) {
|
|
11
|
+
data = "[Blob or ArrayBuffer]";
|
|
12
|
+
}
|
|
13
|
+
else if (typeof body === "string") {
|
|
14
|
+
try {
|
|
15
|
+
data = JSON.parse(body);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
data = body;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (data.accessToken) {
|
|
22
|
+
data.accessToken = "[REDACTED]";
|
|
23
|
+
}
|
|
24
|
+
return data;
|
|
15
25
|
}
|
|
16
26
|
/**
|
|
17
27
|
* Primitive to make custom calls to the inference provider
|
|
@@ -32,7 +42,7 @@ async function innerRequest(args, providerHelper, options) {
|
|
|
32
42
|
url,
|
|
33
43
|
method: info.method ?? "GET",
|
|
34
44
|
headers: info.headers,
|
|
35
|
-
body:
|
|
45
|
+
body: bodyToJson(info.body),
|
|
36
46
|
}, { requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: output });
|
|
37
47
|
}
|
|
38
48
|
if (typeof output.error === "string" || typeof output.detail === "string" || typeof output.message === "string") {
|
|
@@ -40,7 +50,7 @@ async function innerRequest(args, providerHelper, options) {
|
|
|
40
50
|
url,
|
|
41
51
|
method: info.method ?? "GET",
|
|
42
52
|
headers: info.headers,
|
|
43
|
-
body:
|
|
53
|
+
body: bodyToJson(info.body),
|
|
44
54
|
}, { requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: output });
|
|
45
55
|
}
|
|
46
56
|
else {
|
|
@@ -48,7 +58,7 @@ async function innerRequest(args, providerHelper, options) {
|
|
|
48
58
|
url,
|
|
49
59
|
method: info.method ?? "GET",
|
|
50
60
|
headers: info.headers,
|
|
51
|
-
body:
|
|
61
|
+
body: bodyToJson(info.body),
|
|
52
62
|
}, { requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: output });
|
|
53
63
|
}
|
|
54
64
|
}
|
|
@@ -57,7 +67,7 @@ async function innerRequest(args, providerHelper, options) {
|
|
|
57
67
|
url,
|
|
58
68
|
method: info.method ?? "GET",
|
|
59
69
|
headers: info.headers,
|
|
60
|
-
body:
|
|
70
|
+
body: bodyToJson(info.body),
|
|
61
71
|
}, { requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: message ?? "" });
|
|
62
72
|
}
|
|
63
73
|
if (response.headers.get("Content-Type")?.startsWith("application/json")) {
|
|
@@ -84,7 +94,7 @@ async function* innerStreamingRequest(args, providerHelper, options) {
|
|
|
84
94
|
url,
|
|
85
95
|
method: info.method ?? "GET",
|
|
86
96
|
headers: info.headers,
|
|
87
|
-
body:
|
|
97
|
+
body: bodyToJson(info.body),
|
|
88
98
|
}, { requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: output });
|
|
89
99
|
}
|
|
90
100
|
if (typeof output.error === "string") {
|
|
@@ -92,7 +102,7 @@ async function* innerStreamingRequest(args, providerHelper, options) {
|
|
|
92
102
|
url,
|
|
93
103
|
method: info.method ?? "GET",
|
|
94
104
|
headers: info.headers,
|
|
95
|
-
body:
|
|
105
|
+
body: bodyToJson(info.body),
|
|
96
106
|
}, { requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: output });
|
|
97
107
|
}
|
|
98
108
|
if (output.error && "message" in output.error && typeof output.error.message === "string") {
|
|
@@ -101,7 +111,7 @@ async function* innerStreamingRequest(args, providerHelper, options) {
|
|
|
101
111
|
url,
|
|
102
112
|
method: info.method ?? "GET",
|
|
103
113
|
headers: info.headers,
|
|
104
|
-
body:
|
|
114
|
+
body: bodyToJson(info.body),
|
|
105
115
|
}, { requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: output });
|
|
106
116
|
}
|
|
107
117
|
// Sambanova errors
|
|
@@ -110,7 +120,7 @@ async function* innerStreamingRequest(args, providerHelper, options) {
|
|
|
110
120
|
url,
|
|
111
121
|
method: info.method ?? "GET",
|
|
112
122
|
headers: info.headers,
|
|
113
|
-
body:
|
|
123
|
+
body: bodyToJson(info.body),
|
|
114
124
|
}, { requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: output });
|
|
115
125
|
}
|
|
116
126
|
}
|
|
@@ -118,7 +128,7 @@ async function* innerStreamingRequest(args, providerHelper, options) {
|
|
|
118
128
|
url,
|
|
119
129
|
method: info.method ?? "GET",
|
|
120
130
|
headers: info.headers,
|
|
121
|
-
body:
|
|
131
|
+
body: bodyToJson(info.body),
|
|
122
132
|
}, { requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: "" });
|
|
123
133
|
}
|
|
124
134
|
if (!response.headers.get("content-type")?.startsWith("text/event-stream")) {
|
|
@@ -127,7 +137,7 @@ async function* innerStreamingRequest(args, providerHelper, options) {
|
|
|
127
137
|
url,
|
|
128
138
|
method: info.method ?? "GET",
|
|
129
139
|
headers: info.headers,
|
|
130
|
-
body:
|
|
140
|
+
body: bodyToJson(info.body),
|
|
131
141
|
}, { requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: "" });
|
|
132
142
|
}
|
|
133
143
|
if (!response.body) {
|
|
@@ -166,7 +176,7 @@ async function* innerStreamingRequest(args, providerHelper, options) {
|
|
|
166
176
|
url,
|
|
167
177
|
method: info.method ?? "GET",
|
|
168
178
|
headers: info.headers,
|
|
169
|
-
body:
|
|
179
|
+
body: bodyToJson(info.body),
|
|
170
180
|
}, { requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: data });
|
|
171
181
|
}
|
|
172
182
|
yield data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getInferenceProviderMapping.d.ts","sourceRoot":"","sources":["../../../src/lib/getInferenceProviderMapping.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,yBAAyB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAIxH,eAAO,MAAM,6BAA6B,8CAAsD,CAAC;
|
|
1
|
+
{"version":3,"file":"getInferenceProviderMapping.d.ts","sourceRoot":"","sources":["../../../src/lib/getInferenceProviderMapping.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,yBAAyB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAIxH,eAAO,MAAM,6BAA6B,8CAAsD,CAAC;AA4CjG,wBAAsB,qCAAqC,CAC1D,OAAO,EAAE,OAAO,EAChB,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE;IACT,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;CACtE,GACC,OAAO,CAAC,6BAA6B,EAAE,CAAC,CAqD1C;AAED,wBAAsB,2BAA2B,CAChD,MAAM,EAAE;IACP,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,IAAI,EAAE,UAAU,CAAC;CACjB,EACD,OAAO,EAAE;IACR,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;CACtE,GACC,OAAO,CAAC,6BAA6B,GAAG,IAAI,CAAC,CAwB/C;AAED,wBAAsB,eAAe,CACpC,QAAQ,CAAC,EAAE,yBAAyB,EACpC,OAAO,CAAC,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,iBAAiB,CAAC,CA0B5B"}
|
|
@@ -25,6 +25,8 @@ function normalizeInferenceProviderMapping(modelId, inferenceProviderMapping) {
|
|
|
25
25
|
providerId: mapping.providerId,
|
|
26
26
|
status: mapping.status,
|
|
27
27
|
task: mapping.task,
|
|
28
|
+
adapter: mapping.adapter,
|
|
29
|
+
adapterWeightsPath: mapping.adapterWeightsPath,
|
|
28
30
|
}));
|
|
29
31
|
}
|
|
30
32
|
export async function fetchInferenceProviderMappingForModel(modelId, accessToken, options) {
|
|
@@ -102,6 +104,7 @@ export async function resolveProvider(provider, modelId, endpointUrl) {
|
|
|
102
104
|
}
|
|
103
105
|
const mappings = await fetchInferenceProviderMappingForModel(modelId);
|
|
104
106
|
provider = mappings[0]?.provider;
|
|
107
|
+
console.log("Auto selected provider:", provider);
|
|
105
108
|
}
|
|
106
109
|
if (!provider) {
|
|
107
110
|
throw new InferenceClientInputError(`No Inference Provider available for model ${modelId}.`);
|
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.3.
|
|
2
|
+
export const PACKAGE_VERSION = "4.3.2";
|
|
3
3
|
export const PACKAGE_NAME = "@huggingface/inference";
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import type { FeatureExtractionOutput, TextGenerationOutput } from "@huggingface/tasks";
|
|
18
18
|
import type { BodyParams } from "../types.js";
|
|
19
19
|
import { BaseConversationalTask, BaseTextGenerationTask, TaskProviderHelper, type FeatureExtractionTaskHelper, type TextToImageTaskHelper } from "./providerHelper.js";
|
|
20
|
+
import type { ChatCompletionInput } from "../../../tasks/dist/commonjs/index.js";
|
|
20
21
|
interface NebiusBase64ImageGeneration {
|
|
21
22
|
data: Array<{
|
|
22
23
|
b64_json: string;
|
|
@@ -34,6 +35,7 @@ interface NebiusTextGenerationOutput extends Omit<TextGenerationOutput, "choices
|
|
|
34
35
|
}
|
|
35
36
|
export declare class NebiusConversationalTask extends BaseConversationalTask {
|
|
36
37
|
constructor();
|
|
38
|
+
preparePayload(params: BodyParams<ChatCompletionInput>): Record<string, unknown>;
|
|
37
39
|
}
|
|
38
40
|
export declare class NebiusTextGenerationTask extends BaseTextGenerationTask {
|
|
39
41
|
constructor();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nebius.d.ts","sourceRoot":"","sources":["../../../src/providers/nebius.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACxF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,KAAK,2BAA2B,EAChC,KAAK,qBAAqB,EAC1B,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"nebius.d.ts","sourceRoot":"","sources":["../../../src/providers/nebius.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACxF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,KAAK,2BAA2B,EAChC,KAAK,qBAAqB,EAC1B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAIjF,UAAU,2BAA2B;IACpC,IAAI,EAAE,KAAK,CAAC;QACX,QAAQ,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;CACH;AAED,UAAU,wBAAwB;IACjC,IAAI,EAAE,KAAK,CAAC;QACX,SAAS,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC,CAAC;CACH;AAED,UAAU,0BAA2B,SAAQ,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC;IACjF,OAAO,EAAE,KAAK,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;KACb,CAAC,CAAC;CACH;AAED,qBAAa,wBAAyB,SAAQ,sBAAsB;;IAK1D,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,mBAAmB,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAUzF;AAED,qBAAa,wBAAyB,SAAQ,sBAAsB;;IAK1D,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAQrD,WAAW,CAAC,QAAQ,EAAE,0BAA0B,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAc/F;AAED,qBAAa,qBAAsB,SAAQ,kBAAmB,YAAW,qBAAqB;;IAK7F,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAU3D,SAAS,IAAI,MAAM;IAIb,WAAW,CAChB,QAAQ,EAAE,2BAA2B,EACrC,GAAG,CAAC,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,WAAW,EACrB,UAAU,CAAC,EAAE,KAAK,GAAG,MAAM,GACzB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAkBzB;AAED,qBAAa,2BAA4B,SAAQ,kBAAmB,YAAW,2BAA2B;;IAKzG,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAO3D,SAAS,IAAI,MAAM;IAIb,WAAW,CAAC,QAAQ,EAAE,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,CAAC;CAGvF"}
|
|
@@ -6,6 +6,14 @@ export class NebiusConversationalTask extends BaseConversationalTask {
|
|
|
6
6
|
constructor() {
|
|
7
7
|
super("nebius", NEBIUS_API_BASE_URL);
|
|
8
8
|
}
|
|
9
|
+
preparePayload(params) {
|
|
10
|
+
const payload = super.preparePayload(params);
|
|
11
|
+
const responseFormat = params.args.response_format;
|
|
12
|
+
if (responseFormat?.type === "json_schema" && responseFormat.json_schema?.schema) {
|
|
13
|
+
payload["guided_json"] = responseFormat.json_schema.schema;
|
|
14
|
+
}
|
|
15
|
+
return payload;
|
|
16
|
+
}
|
|
9
17
|
}
|
|
10
18
|
export class NebiusTextGenerationTask extends BaseTextGenerationTask {
|
|
11
19
|
constructor() {
|
|
@@ -18,8 +18,10 @@ import type { FeatureExtractionOutput } from "@huggingface/tasks";
|
|
|
18
18
|
import type { BodyParams } from "../types.js";
|
|
19
19
|
import type { FeatureExtractionTaskHelper } from "./providerHelper.js";
|
|
20
20
|
import { BaseConversationalTask, TaskProviderHelper } from "./providerHelper.js";
|
|
21
|
+
import type { ChatCompletionInput } from "../../../tasks/dist/commonjs/index.js";
|
|
21
22
|
export declare class SambanovaConversationalTask extends BaseConversationalTask {
|
|
22
23
|
constructor();
|
|
24
|
+
preparePayload(params: BodyParams<ChatCompletionInput>): Record<string, unknown>;
|
|
23
25
|
}
|
|
24
26
|
export declare class SambanovaFeatureExtractionTask extends TaskProviderHelper implements FeatureExtractionTaskHelper {
|
|
25
27
|
constructor();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sambanova.d.ts","sourceRoot":"","sources":["../../../src/providers/sambanova.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"sambanova.d.ts","sourceRoot":"","sources":["../../../src/providers/sambanova.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAEjF,qBAAa,2BAA4B,SAAQ,sBAAsB;;IAK7D,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,mBAAmB,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAYzF;AAED,qBAAa,8BAA+B,SAAQ,kBAAmB,YAAW,2BAA2B;;IAKnG,SAAS,IAAI,MAAM;IAIb,WAAW,CAAC,QAAQ,EAAE,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAStF,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAOpE"}
|
|
@@ -4,6 +4,16 @@ export class SambanovaConversationalTask extends BaseConversationalTask {
|
|
|
4
4
|
constructor() {
|
|
5
5
|
super("sambanova", "https://api.sambanova.ai");
|
|
6
6
|
}
|
|
7
|
+
preparePayload(params) {
|
|
8
|
+
const responseFormat = params.args.response_format;
|
|
9
|
+
if (responseFormat?.type === "json_schema" && responseFormat.json_schema) {
|
|
10
|
+
if (responseFormat.json_schema.strict ?? true) {
|
|
11
|
+
responseFormat.json_schema.strict = false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const payload = super.preparePayload(params);
|
|
15
|
+
return payload;
|
|
16
|
+
}
|
|
7
17
|
}
|
|
8
18
|
export class SambanovaFeatureExtractionTask extends TaskProviderHelper {
|
|
9
19
|
constructor() {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import type { ChatCompletionOutput, TextGenerationOutput, TextGenerationOutputFinishReason } from "@huggingface/tasks";
|
|
18
18
|
import type { BodyParams } from "../types.js";
|
|
19
19
|
import { BaseConversationalTask, BaseTextGenerationTask, TaskProviderHelper, type TextToImageTaskHelper } from "./providerHelper.js";
|
|
20
|
+
import type { ChatCompletionInput } from "../../../tasks/dist/commonjs/index.js";
|
|
20
21
|
interface TogetherTextCompletionOutput extends Omit<ChatCompletionOutput, "choices"> {
|
|
21
22
|
choices: Array<{
|
|
22
23
|
text: string;
|
|
@@ -33,6 +34,7 @@ interface TogetherBase64ImageGeneration {
|
|
|
33
34
|
}
|
|
34
35
|
export declare class TogetherConversationalTask extends BaseConversationalTask {
|
|
35
36
|
constructor();
|
|
37
|
+
preparePayload(params: BodyParams<ChatCompletionInput>): Record<string, unknown>;
|
|
36
38
|
}
|
|
37
39
|
export declare class TogetherTextGenerationTask extends BaseTextGenerationTask {
|
|
38
40
|
constructor();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"together.d.ts","sourceRoot":"","sources":["../../../src/providers/together.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AACvH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,KAAK,qBAAqB,EAC1B,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"together.d.ts","sourceRoot":"","sources":["../../../src/providers/together.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AACvH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,KAAK,qBAAqB,EAC1B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAIjF,UAAU,4BAA6B,SAAQ,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC;IACnF,OAAO,EAAE,KAAK,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,aAAa,EAAE,gCAAgC,CAAC;QAChD,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,OAAO,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;CACH;AAED,UAAU,6BAA6B;IACtC,IAAI,EAAE,KAAK,CAAC;QACX,QAAQ,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;CACH;AAED,qBAAa,0BAA2B,SAAQ,sBAAsB;;IAK5D,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,mBAAmB,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAezF;AAED,qBAAa,0BAA2B,SAAQ,sBAAsB;;IAK5D,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAQrD,WAAW,CAAC,QAAQ,EAAE,4BAA4B,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAcjG;AAED,qBAAa,uBAAwB,SAAQ,kBAAmB,YAAW,qBAAqB;;IAK/F,SAAS,IAAI,MAAM;IAInB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAUrD,WAAW,CAAC,QAAQ,EAAE,6BAA6B,EAAE,UAAU,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAkB/G"}
|
|
@@ -6,6 +6,17 @@ export class TogetherConversationalTask extends BaseConversationalTask {
|
|
|
6
6
|
constructor() {
|
|
7
7
|
super("together", TOGETHER_API_BASE_URL);
|
|
8
8
|
}
|
|
9
|
+
preparePayload(params) {
|
|
10
|
+
const payload = super.preparePayload(params);
|
|
11
|
+
const response_format = payload.response_format;
|
|
12
|
+
if (response_format?.type === "json_schema" && response_format?.json_schema?.schema) {
|
|
13
|
+
payload.response_format = {
|
|
14
|
+
type: "json_schema",
|
|
15
|
+
schema: response_format.json_schema.schema,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return payload;
|
|
19
|
+
}
|
|
9
20
|
}
|
|
10
21
|
export class TogetherTextGenerationTask extends BaseTextGenerationTask {
|
|
11
22
|
constructor() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/utils/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAMvE,MAAM,WAAW,eAAe,CAAC,CAAC;IACjC,IAAI,EAAE,CAAC,CAAC;IACR,cAAc,EAAE;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,WAAW,CAAC;KAClB,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/utils/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAMvE,MAAM,WAAW,eAAe,CAAC,CAAC;IACjC,IAAI,EAAE,CAAC,CAAC;IACR,cAAc,EAAE;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,WAAW,CAAC;KAClB,CAAC;CACF;AAmBD;;GAEG;AACH,wBAAsB,YAAY,CAAC,CAAC,EACnC,IAAI,EAAE,WAAW,EACjB,cAAc,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,EACpD,OAAO,CAAC,EAAE,OAAO,GAAG;IACnB,oEAAoE;IACpE,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,oCAAoC;IACpC,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB,GACC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAwE7B;AAED;;GAEG;AACH,wBAAuB,qBAAqB,CAAC,CAAC,EAC7C,IAAI,EAAE,WAAW,EACjB,cAAc,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,EACpD,OAAO,CAAC,EAAE,OAAO,GAAG;IACnB,oEAAoE;IACpE,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,oCAAoC;IACpC,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB,GACC,cAAc,CAAC,CAAC,CAAC,CAuJnB"}
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import { makeRequestOptions } from "../lib/makeRequestOptions.js";
|
|
2
2
|
import { getLines, getMessages } from "../vendor/fetch-event-source/parse.js";
|
|
3
3
|
import { InferenceClientProviderApiError } from "../errors.js";
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
function bodyToJson(body) {
|
|
5
|
+
let data = null;
|
|
6
|
+
if (body instanceof Blob || body instanceof ArrayBuffer) {
|
|
7
|
+
data = "[Blob or ArrayBuffer]";
|
|
8
|
+
}
|
|
9
|
+
else if (typeof body === "string") {
|
|
10
|
+
try {
|
|
11
|
+
data = JSON.parse(body);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
data = body;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (data.accessToken) {
|
|
18
|
+
data.accessToken = "[REDACTED]";
|
|
19
|
+
}
|
|
20
|
+
return data;
|
|
11
21
|
}
|
|
12
22
|
/**
|
|
13
23
|
* Primitive to make custom calls to the inference provider
|
|
@@ -28,7 +38,7 @@ export async function innerRequest(args, providerHelper, options) {
|
|
|
28
38
|
url,
|
|
29
39
|
method: info.method ?? "GET",
|
|
30
40
|
headers: info.headers,
|
|
31
|
-
body:
|
|
41
|
+
body: bodyToJson(info.body),
|
|
32
42
|
}, { requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: output });
|
|
33
43
|
}
|
|
34
44
|
if (typeof output.error === "string" || typeof output.detail === "string" || typeof output.message === "string") {
|
|
@@ -36,7 +46,7 @@ export async function innerRequest(args, providerHelper, options) {
|
|
|
36
46
|
url,
|
|
37
47
|
method: info.method ?? "GET",
|
|
38
48
|
headers: info.headers,
|
|
39
|
-
body:
|
|
49
|
+
body: bodyToJson(info.body),
|
|
40
50
|
}, { requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: output });
|
|
41
51
|
}
|
|
42
52
|
else {
|
|
@@ -44,7 +54,7 @@ export async function innerRequest(args, providerHelper, options) {
|
|
|
44
54
|
url,
|
|
45
55
|
method: info.method ?? "GET",
|
|
46
56
|
headers: info.headers,
|
|
47
|
-
body:
|
|
57
|
+
body: bodyToJson(info.body),
|
|
48
58
|
}, { requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: output });
|
|
49
59
|
}
|
|
50
60
|
}
|
|
@@ -53,7 +63,7 @@ export async function innerRequest(args, providerHelper, options) {
|
|
|
53
63
|
url,
|
|
54
64
|
method: info.method ?? "GET",
|
|
55
65
|
headers: info.headers,
|
|
56
|
-
body:
|
|
66
|
+
body: bodyToJson(info.body),
|
|
57
67
|
}, { requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: message ?? "" });
|
|
58
68
|
}
|
|
59
69
|
if (response.headers.get("Content-Type")?.startsWith("application/json")) {
|
|
@@ -80,7 +90,7 @@ export async function* innerStreamingRequest(args, providerHelper, options) {
|
|
|
80
90
|
url,
|
|
81
91
|
method: info.method ?? "GET",
|
|
82
92
|
headers: info.headers,
|
|
83
|
-
body:
|
|
93
|
+
body: bodyToJson(info.body),
|
|
84
94
|
}, { requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: output });
|
|
85
95
|
}
|
|
86
96
|
if (typeof output.error === "string") {
|
|
@@ -88,7 +98,7 @@ export async function* innerStreamingRequest(args, providerHelper, options) {
|
|
|
88
98
|
url,
|
|
89
99
|
method: info.method ?? "GET",
|
|
90
100
|
headers: info.headers,
|
|
91
|
-
body:
|
|
101
|
+
body: bodyToJson(info.body),
|
|
92
102
|
}, { requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: output });
|
|
93
103
|
}
|
|
94
104
|
if (output.error && "message" in output.error && typeof output.error.message === "string") {
|
|
@@ -97,7 +107,7 @@ export async function* innerStreamingRequest(args, providerHelper, options) {
|
|
|
97
107
|
url,
|
|
98
108
|
method: info.method ?? "GET",
|
|
99
109
|
headers: info.headers,
|
|
100
|
-
body:
|
|
110
|
+
body: bodyToJson(info.body),
|
|
101
111
|
}, { requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: output });
|
|
102
112
|
}
|
|
103
113
|
// Sambanova errors
|
|
@@ -106,7 +116,7 @@ export async function* innerStreamingRequest(args, providerHelper, options) {
|
|
|
106
116
|
url,
|
|
107
117
|
method: info.method ?? "GET",
|
|
108
118
|
headers: info.headers,
|
|
109
|
-
body:
|
|
119
|
+
body: bodyToJson(info.body),
|
|
110
120
|
}, { requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: output });
|
|
111
121
|
}
|
|
112
122
|
}
|
|
@@ -114,7 +124,7 @@ export async function* innerStreamingRequest(args, providerHelper, options) {
|
|
|
114
124
|
url,
|
|
115
125
|
method: info.method ?? "GET",
|
|
116
126
|
headers: info.headers,
|
|
117
|
-
body:
|
|
127
|
+
body: bodyToJson(info.body),
|
|
118
128
|
}, { requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: "" });
|
|
119
129
|
}
|
|
120
130
|
if (!response.headers.get("content-type")?.startsWith("text/event-stream")) {
|
|
@@ -123,7 +133,7 @@ export async function* innerStreamingRequest(args, providerHelper, options) {
|
|
|
123
133
|
url,
|
|
124
134
|
method: info.method ?? "GET",
|
|
125
135
|
headers: info.headers,
|
|
126
|
-
body:
|
|
136
|
+
body: bodyToJson(info.body),
|
|
127
137
|
}, { requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: "" });
|
|
128
138
|
}
|
|
129
139
|
if (!response.body) {
|
|
@@ -162,7 +172,7 @@ export async function* innerStreamingRequest(args, providerHelper, options) {
|
|
|
162
172
|
url,
|
|
163
173
|
method: info.method ?? "GET",
|
|
164
174
|
headers: info.headers,
|
|
165
|
-
body:
|
|
175
|
+
body: bodyToJson(info.body),
|
|
166
176
|
}, { requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: data });
|
|
167
177
|
}
|
|
168
178
|
yield data;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huggingface/inference",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.2",
|
|
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.22",
|
|
44
44
|
"@huggingface/jinja": "^0.5.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
@@ -18,7 +18,16 @@ function normalizeInferenceProviderMapping(
|
|
|
18
18
|
modelId: ModelId,
|
|
19
19
|
inferenceProviderMapping?:
|
|
20
20
|
| InferenceProviderMappingEntry[]
|
|
21
|
-
| Record<
|
|
21
|
+
| Record<
|
|
22
|
+
string,
|
|
23
|
+
{
|
|
24
|
+
providerId: string;
|
|
25
|
+
status: "live" | "staging";
|
|
26
|
+
task: WidgetType;
|
|
27
|
+
adapter?: string;
|
|
28
|
+
adapterWeightsPath?: string;
|
|
29
|
+
}
|
|
30
|
+
>
|
|
22
31
|
): InferenceProviderMappingEntry[] {
|
|
23
32
|
if (!inferenceProviderMapping) {
|
|
24
33
|
return [];
|
|
@@ -36,6 +45,8 @@ function normalizeInferenceProviderMapping(
|
|
|
36
45
|
providerId: mapping.providerId,
|
|
37
46
|
status: mapping.status,
|
|
38
47
|
task: mapping.task,
|
|
48
|
+
adapter: mapping.adapter,
|
|
49
|
+
adapterWeightsPath: mapping.adapterWeightsPath,
|
|
39
50
|
}));
|
|
40
51
|
}
|
|
41
52
|
|
|
@@ -160,6 +171,7 @@ export async function resolveProvider(
|
|
|
160
171
|
}
|
|
161
172
|
const mappings = await fetchInferenceProviderMappingForModel(modelId);
|
|
162
173
|
provider = mappings[0]?.provider as InferenceProvider | undefined;
|
|
174
|
+
console.log("Auto selected provider:", provider);
|
|
163
175
|
}
|
|
164
176
|
if (!provider) {
|
|
165
177
|
throw new InferenceClientInputError(`No Inference Provider available for model ${modelId}.`);
|
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.3.
|
|
2
|
+
export const PACKAGE_VERSION = "4.3.2";
|
|
3
3
|
export const PACKAGE_NAME = "@huggingface/inference";
|
package/src/providers/nebius.ts
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
type TextToImageTaskHelper,
|
|
26
26
|
} from "./providerHelper.js";
|
|
27
27
|
import { InferenceClientProviderOutputError } from "../errors.js";
|
|
28
|
+
import type { ChatCompletionInput } from "../../../tasks/dist/commonjs/index.js";
|
|
28
29
|
|
|
29
30
|
const NEBIUS_API_BASE_URL = "https://api.studio.nebius.ai";
|
|
30
31
|
|
|
@@ -50,6 +51,17 @@ export class NebiusConversationalTask extends BaseConversationalTask {
|
|
|
50
51
|
constructor() {
|
|
51
52
|
super("nebius", NEBIUS_API_BASE_URL);
|
|
52
53
|
}
|
|
54
|
+
|
|
55
|
+
override preparePayload(params: BodyParams<ChatCompletionInput>): Record<string, unknown> {
|
|
56
|
+
const payload = super.preparePayload(params) as Record<string, unknown>;
|
|
57
|
+
|
|
58
|
+
const responseFormat = params.args.response_format;
|
|
59
|
+
if (responseFormat?.type === "json_schema" && responseFormat.json_schema?.schema) {
|
|
60
|
+
payload["guided_json"] = responseFormat.json_schema.schema;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return payload;
|
|
64
|
+
}
|
|
53
65
|
}
|
|
54
66
|
|
|
55
67
|
export class NebiusTextGenerationTask extends BaseTextGenerationTask {
|
|
@@ -19,11 +19,25 @@ import type { BodyParams } from "../types.js";
|
|
|
19
19
|
import type { FeatureExtractionTaskHelper } from "./providerHelper.js";
|
|
20
20
|
import { BaseConversationalTask, TaskProviderHelper } from "./providerHelper.js";
|
|
21
21
|
import { InferenceClientProviderOutputError } from "../errors.js";
|
|
22
|
+
import type { ChatCompletionInput } from "../../../tasks/dist/commonjs/index.js";
|
|
22
23
|
|
|
23
24
|
export class SambanovaConversationalTask extends BaseConversationalTask {
|
|
24
25
|
constructor() {
|
|
25
26
|
super("sambanova", "https://api.sambanova.ai");
|
|
26
27
|
}
|
|
28
|
+
|
|
29
|
+
override preparePayload(params: BodyParams<ChatCompletionInput>): Record<string, unknown> {
|
|
30
|
+
const responseFormat = params.args.response_format;
|
|
31
|
+
|
|
32
|
+
if (responseFormat?.type === "json_schema" && responseFormat.json_schema) {
|
|
33
|
+
if (responseFormat.json_schema.strict ?? true) {
|
|
34
|
+
responseFormat.json_schema.strict = false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const payload = super.preparePayload(params) as Record<string, unknown>;
|
|
38
|
+
|
|
39
|
+
return payload;
|
|
40
|
+
}
|
|
27
41
|
}
|
|
28
42
|
|
|
29
43
|
export class SambanovaFeatureExtractionTask extends TaskProviderHelper implements FeatureExtractionTaskHelper {
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
type TextToImageTaskHelper,
|
|
25
25
|
} from "./providerHelper.js";
|
|
26
26
|
import { InferenceClientProviderOutputError } from "../errors.js";
|
|
27
|
+
import type { ChatCompletionInput } from "../../../tasks/dist/commonjs/index.js";
|
|
27
28
|
|
|
28
29
|
const TOGETHER_API_BASE_URL = "https://api.together.xyz";
|
|
29
30
|
|
|
@@ -47,6 +48,22 @@ export class TogetherConversationalTask extends BaseConversationalTask {
|
|
|
47
48
|
constructor() {
|
|
48
49
|
super("together", TOGETHER_API_BASE_URL);
|
|
49
50
|
}
|
|
51
|
+
|
|
52
|
+
override preparePayload(params: BodyParams<ChatCompletionInput>): Record<string, unknown> {
|
|
53
|
+
const payload = super.preparePayload(params);
|
|
54
|
+
const response_format = payload.response_format as
|
|
55
|
+
| { type: "json_schema"; json_schema: { schema: unknown } }
|
|
56
|
+
| undefined;
|
|
57
|
+
|
|
58
|
+
if (response_format?.type === "json_schema" && response_format?.json_schema?.schema) {
|
|
59
|
+
payload.response_format = {
|
|
60
|
+
type: "json_schema",
|
|
61
|
+
schema: response_format.json_schema.schema,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return payload;
|
|
66
|
+
}
|
|
50
67
|
}
|
|
51
68
|
|
|
52
69
|
export class TogetherTextGenerationTask extends BaseTextGenerationTask {
|
package/src/utils/request.ts
CHANGED
|
@@ -14,15 +14,21 @@ export interface ResponseWrapper<T> {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
data
|
|
24
|
-
}
|
|
25
|
-
|
|
17
|
+
function bodyToJson(body?: BodyInit | null): JsonObject {
|
|
18
|
+
let data = null;
|
|
19
|
+
if (body instanceof Blob || body instanceof ArrayBuffer) {
|
|
20
|
+
data = "[Blob or ArrayBuffer]";
|
|
21
|
+
} else if (typeof body === "string") {
|
|
22
|
+
try {
|
|
23
|
+
data = JSON.parse(body);
|
|
24
|
+
} catch {
|
|
25
|
+
data = body;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (data.accessToken) {
|
|
29
|
+
data.accessToken = "[REDACTED]";
|
|
30
|
+
}
|
|
31
|
+
return data as JsonObject;
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
/**
|
|
@@ -60,7 +66,7 @@ export async function innerRequest<T>(
|
|
|
60
66
|
url,
|
|
61
67
|
method: info.method ?? "GET",
|
|
62
68
|
headers: info.headers as Record<string, string>,
|
|
63
|
-
body:
|
|
69
|
+
body: bodyToJson(info.body),
|
|
64
70
|
},
|
|
65
71
|
{ requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: output }
|
|
66
72
|
);
|
|
@@ -72,7 +78,7 @@ export async function innerRequest<T>(
|
|
|
72
78
|
url,
|
|
73
79
|
method: info.method ?? "GET",
|
|
74
80
|
headers: info.headers as Record<string, string>,
|
|
75
|
-
body:
|
|
81
|
+
body: bodyToJson(info.body),
|
|
76
82
|
},
|
|
77
83
|
{ requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: output }
|
|
78
84
|
);
|
|
@@ -83,7 +89,7 @@ export async function innerRequest<T>(
|
|
|
83
89
|
url,
|
|
84
90
|
method: info.method ?? "GET",
|
|
85
91
|
headers: info.headers as Record<string, string>,
|
|
86
|
-
body:
|
|
92
|
+
body: bodyToJson(info.body),
|
|
87
93
|
},
|
|
88
94
|
{ requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: output }
|
|
89
95
|
);
|
|
@@ -96,7 +102,7 @@ export async function innerRequest<T>(
|
|
|
96
102
|
url,
|
|
97
103
|
method: info.method ?? "GET",
|
|
98
104
|
headers: info.headers as Record<string, string>,
|
|
99
|
-
body:
|
|
105
|
+
body: bodyToJson(info.body),
|
|
100
106
|
},
|
|
101
107
|
{ requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: message ?? "" }
|
|
102
108
|
);
|
|
@@ -142,7 +148,7 @@ export async function* innerStreamingRequest<T>(
|
|
|
142
148
|
url,
|
|
143
149
|
method: info.method ?? "GET",
|
|
144
150
|
headers: info.headers as Record<string, string>,
|
|
145
|
-
body:
|
|
151
|
+
body: bodyToJson(info.body),
|
|
146
152
|
},
|
|
147
153
|
{ requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: output }
|
|
148
154
|
);
|
|
@@ -154,7 +160,7 @@ export async function* innerStreamingRequest<T>(
|
|
|
154
160
|
url,
|
|
155
161
|
method: info.method ?? "GET",
|
|
156
162
|
headers: info.headers as Record<string, string>,
|
|
157
|
-
body:
|
|
163
|
+
body: bodyToJson(info.body),
|
|
158
164
|
},
|
|
159
165
|
{ requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: output }
|
|
160
166
|
);
|
|
@@ -167,7 +173,7 @@ export async function* innerStreamingRequest<T>(
|
|
|
167
173
|
url,
|
|
168
174
|
method: info.method ?? "GET",
|
|
169
175
|
headers: info.headers as Record<string, string>,
|
|
170
|
-
body:
|
|
176
|
+
body: bodyToJson(info.body),
|
|
171
177
|
},
|
|
172
178
|
{ requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: output }
|
|
173
179
|
);
|
|
@@ -180,7 +186,7 @@ export async function* innerStreamingRequest<T>(
|
|
|
180
186
|
url,
|
|
181
187
|
method: info.method ?? "GET",
|
|
182
188
|
headers: info.headers as Record<string, string>,
|
|
183
|
-
body:
|
|
189
|
+
body: bodyToJson(info.body),
|
|
184
190
|
},
|
|
185
191
|
{ requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: output }
|
|
186
192
|
);
|
|
@@ -193,7 +199,7 @@ export async function* innerStreamingRequest<T>(
|
|
|
193
199
|
url,
|
|
194
200
|
method: info.method ?? "GET",
|
|
195
201
|
headers: info.headers as Record<string, string>,
|
|
196
|
-
body:
|
|
202
|
+
body: bodyToJson(info.body),
|
|
197
203
|
},
|
|
198
204
|
{ requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: "" }
|
|
199
205
|
);
|
|
@@ -206,7 +212,7 @@ export async function* innerStreamingRequest<T>(
|
|
|
206
212
|
url,
|
|
207
213
|
method: info.method ?? "GET",
|
|
208
214
|
headers: info.headers as Record<string, string>,
|
|
209
|
-
body:
|
|
215
|
+
body: bodyToJson(info.body),
|
|
210
216
|
},
|
|
211
217
|
{ requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: "" }
|
|
212
218
|
);
|
|
@@ -261,7 +267,7 @@ export async function* innerStreamingRequest<T>(
|
|
|
261
267
|
url,
|
|
262
268
|
method: info.method ?? "GET",
|
|
263
269
|
headers: info.headers as Record<string, string>,
|
|
264
|
-
body:
|
|
270
|
+
body: bodyToJson(info.body),
|
|
265
271
|
},
|
|
266
272
|
{ requestId: response.headers.get("x-request-id") ?? "", status: response.status, body: data }
|
|
267
273
|
);
|