@huggingface/inference 3.8.0 → 3.8.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/index.cjs CHANGED
@@ -458,7 +458,7 @@ var FalAITextToSpeechTask = class extends FalAITask {
458
458
  return {
459
459
  ...omit(params.args, ["inputs", "parameters"]),
460
460
  ...params.args.parameters,
461
- lyrics: params.args.inputs
461
+ text: params.args.inputs
462
462
  };
463
463
  }
464
464
  async getResponse(response) {
@@ -1042,6 +1042,29 @@ var SambanovaConversationalTask = class extends BaseConversationalTask {
1042
1042
  super("sambanova", "https://api.sambanova.ai");
1043
1043
  }
1044
1044
  };
1045
+ var SambanovaFeatureExtractionTask = class extends TaskProviderHelper {
1046
+ constructor() {
1047
+ super("sambanova", "https://api.sambanova.ai");
1048
+ }
1049
+ makeRoute() {
1050
+ return `/v1/embeddings`;
1051
+ }
1052
+ async getResponse(response) {
1053
+ if (typeof response === "object" && "data" in response && Array.isArray(response.data)) {
1054
+ return response.data.map((item) => item.embedding);
1055
+ }
1056
+ throw new InferenceOutputError(
1057
+ "Expected Sambanova feature-extraction (embeddings) response format to be {'data' : list of {'embedding' : number[]}}"
1058
+ );
1059
+ }
1060
+ preparePayload(params) {
1061
+ return {
1062
+ model: params.model,
1063
+ input: params.args.inputs,
1064
+ ...params.args
1065
+ };
1066
+ }
1067
+ };
1045
1068
 
1046
1069
  // src/providers/together.ts
1047
1070
  var TOGETHER_API_BASE_URL = "https://api.together.xyz";
@@ -1172,7 +1195,8 @@ var PROVIDERS = {
1172
1195
  "text-to-video": new ReplicateTextToVideoTask()
1173
1196
  },
1174
1197
  sambanova: {
1175
- conversational: new SambanovaConversationalTask()
1198
+ conversational: new SambanovaConversationalTask(),
1199
+ "feature-extraction": new SambanovaFeatureExtractionTask()
1176
1200
  },
1177
1201
  together: {
1178
1202
  "text-to-image": new TogetherTextToImageTask(),
@@ -1203,7 +1227,7 @@ function getProviderHelper(provider, task) {
1203
1227
 
1204
1228
  // package.json
1205
1229
  var name = "@huggingface/inference";
1206
- var version = "3.8.0";
1230
+ var version = "3.8.2";
1207
1231
 
1208
1232
  // src/providers/consts.ts
1209
1233
  var HARDCODED_MODEL_INFERENCE_MAPPING = {
@@ -2346,7 +2370,7 @@ var HF_JS_METHODS = {
2346
2370
  translation: "translation"
2347
2371
  };
2348
2372
  var snippetGenerator = (templateName, inputPreparationFn) => {
2349
- return (model, accessToken, provider, inferenceProviderMapping, billTo, opts) => {
2373
+ return (model, accessToken, provider, inferenceProviderMapping, opts) => {
2350
2374
  const providerModelId = inferenceProviderMapping?.providerId ?? model.id;
2351
2375
  let task = model.pipeline_tag;
2352
2376
  if (model.pipeline_tag && ["text-generation", "image-text-to-text"].includes(model.pipeline_tag) && model.tags.includes("conversational")) {
@@ -2373,7 +2397,7 @@ var snippetGenerator = (templateName, inputPreparationFn) => {
2373
2397
  inferenceProviderMapping,
2374
2398
  {
2375
2399
  task,
2376
- billTo
2400
+ billTo: opts?.billTo
2377
2401
  }
2378
2402
  );
2379
2403
  let providerInputs = inputs;
@@ -2407,7 +2431,7 @@ var snippetGenerator = (templateName, inputPreparationFn) => {
2407
2431
  model,
2408
2432
  provider,
2409
2433
  providerModelId: providerModelId ?? model.id,
2410
- billTo
2434
+ billTo: opts?.billTo
2411
2435
  };
2412
2436
  return import_tasks.inferenceSnippetLanguages.map((language) => {
2413
2437
  return CLIENTS[language].map((client) => {
@@ -2497,8 +2521,8 @@ var snippets = {
2497
2521
  "zero-shot-classification": snippetGenerator("zeroShotClassification"),
2498
2522
  "zero-shot-image-classification": snippetGenerator("zeroShotImageClassification")
2499
2523
  };
2500
- function getInferenceSnippets(model, accessToken, provider, inferenceProviderMapping, billTo, opts) {
2501
- return model.pipeline_tag && model.pipeline_tag in snippets ? snippets[model.pipeline_tag]?.(model, accessToken, provider, inferenceProviderMapping, billTo, opts) ?? [] : [];
2524
+ function getInferenceSnippets(model, accessToken, provider, inferenceProviderMapping, opts) {
2525
+ return model.pipeline_tag && model.pipeline_tag in snippets ? snippets[model.pipeline_tag]?.(model, accessToken, provider, inferenceProviderMapping, opts) ?? [] : [];
2502
2526
  }
2503
2527
  function formatBody(obj, format) {
2504
2528
  switch (format) {
package/dist/index.js CHANGED
@@ -401,7 +401,7 @@ var FalAITextToSpeechTask = class extends FalAITask {
401
401
  return {
402
402
  ...omit(params.args, ["inputs", "parameters"]),
403
403
  ...params.args.parameters,
404
- lyrics: params.args.inputs
404
+ text: params.args.inputs
405
405
  };
406
406
  }
407
407
  async getResponse(response) {
@@ -985,6 +985,29 @@ var SambanovaConversationalTask = class extends BaseConversationalTask {
985
985
  super("sambanova", "https://api.sambanova.ai");
986
986
  }
987
987
  };
988
+ var SambanovaFeatureExtractionTask = class extends TaskProviderHelper {
989
+ constructor() {
990
+ super("sambanova", "https://api.sambanova.ai");
991
+ }
992
+ makeRoute() {
993
+ return `/v1/embeddings`;
994
+ }
995
+ async getResponse(response) {
996
+ if (typeof response === "object" && "data" in response && Array.isArray(response.data)) {
997
+ return response.data.map((item) => item.embedding);
998
+ }
999
+ throw new InferenceOutputError(
1000
+ "Expected Sambanova feature-extraction (embeddings) response format to be {'data' : list of {'embedding' : number[]}}"
1001
+ );
1002
+ }
1003
+ preparePayload(params) {
1004
+ return {
1005
+ model: params.model,
1006
+ input: params.args.inputs,
1007
+ ...params.args
1008
+ };
1009
+ }
1010
+ };
988
1011
 
989
1012
  // src/providers/together.ts
990
1013
  var TOGETHER_API_BASE_URL = "https://api.together.xyz";
@@ -1115,7 +1138,8 @@ var PROVIDERS = {
1115
1138
  "text-to-video": new ReplicateTextToVideoTask()
1116
1139
  },
1117
1140
  sambanova: {
1118
- conversational: new SambanovaConversationalTask()
1141
+ conversational: new SambanovaConversationalTask(),
1142
+ "feature-extraction": new SambanovaFeatureExtractionTask()
1119
1143
  },
1120
1144
  together: {
1121
1145
  "text-to-image": new TogetherTextToImageTask(),
@@ -1146,7 +1170,7 @@ function getProviderHelper(provider, task) {
1146
1170
 
1147
1171
  // package.json
1148
1172
  var name = "@huggingface/inference";
1149
- var version = "3.8.0";
1173
+ var version = "3.8.2";
1150
1174
 
1151
1175
  // src/providers/consts.ts
1152
1176
  var HARDCODED_MODEL_INFERENCE_MAPPING = {
@@ -2292,7 +2316,7 @@ var HF_JS_METHODS = {
2292
2316
  translation: "translation"
2293
2317
  };
2294
2318
  var snippetGenerator = (templateName, inputPreparationFn) => {
2295
- return (model, accessToken, provider, inferenceProviderMapping, billTo, opts) => {
2319
+ return (model, accessToken, provider, inferenceProviderMapping, opts) => {
2296
2320
  const providerModelId = inferenceProviderMapping?.providerId ?? model.id;
2297
2321
  let task = model.pipeline_tag;
2298
2322
  if (model.pipeline_tag && ["text-generation", "image-text-to-text"].includes(model.pipeline_tag) && model.tags.includes("conversational")) {
@@ -2319,7 +2343,7 @@ var snippetGenerator = (templateName, inputPreparationFn) => {
2319
2343
  inferenceProviderMapping,
2320
2344
  {
2321
2345
  task,
2322
- billTo
2346
+ billTo: opts?.billTo
2323
2347
  }
2324
2348
  );
2325
2349
  let providerInputs = inputs;
@@ -2353,7 +2377,7 @@ var snippetGenerator = (templateName, inputPreparationFn) => {
2353
2377
  model,
2354
2378
  provider,
2355
2379
  providerModelId: providerModelId ?? model.id,
2356
- billTo
2380
+ billTo: opts?.billTo
2357
2381
  };
2358
2382
  return inferenceSnippetLanguages.map((language) => {
2359
2383
  return CLIENTS[language].map((client) => {
@@ -2443,8 +2467,8 @@ var snippets = {
2443
2467
  "zero-shot-classification": snippetGenerator("zeroShotClassification"),
2444
2468
  "zero-shot-image-classification": snippetGenerator("zeroShotImageClassification")
2445
2469
  };
2446
- function getInferenceSnippets(model, accessToken, provider, inferenceProviderMapping, billTo, opts) {
2447
- return model.pipeline_tag && model.pipeline_tag in snippets ? snippets[model.pipeline_tag]?.(model, accessToken, provider, inferenceProviderMapping, billTo, opts) ?? [] : [];
2470
+ function getInferenceSnippets(model, accessToken, provider, inferenceProviderMapping, opts) {
2471
+ return model.pipeline_tag && model.pipeline_tag in snippets ? snippets[model.pipeline_tag]?.(model, accessToken, provider, inferenceProviderMapping, opts) ?? [] : [];
2448
2472
  }
2449
2473
  function formatBody(obj, format) {
2450
2474
  switch (format) {
@@ -1 +1 @@
1
- {"version":3,"file":"getProviderHelper.d.ts","sourceRoot":"","sources":["../../../src/lib/getProviderHelper.ts"],"names":[],"mappings":"AAWA,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,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,6BAA6B,CAAC;AAIrC,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEjE,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,iBAAiB,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC,CA+EnG,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,eAAe,GACnB,qBAAqB,GAAG,kBAAkB,CAAC;AAC9C,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,gBAAgB,GACpB,wBAAwB,GAAG,kBAAkB,CAAC;AACjD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,iBA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iBAAiB,CAChC,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,gBAAgB,GACpB,sBAAsB,GAAG,kBAAkB,CAAC;AAC/C,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,qBAAqB,GACzB,4BAA4B,GAAG,kBAAkB,CAAC;AACrD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,0BAA0B,GAC9B,gCAAgC,GAAG,kBAAkB,CAAC;AACzD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,wBAAwB,GAC5B,+BAA+B,GAAG,kBAAkB,CAAC;AACxD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,oBAAoB,GACxB,2BAA2B,GAAG,kBAAkB,CAAC;AACpD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,sBAAsB,GAC1B,6BAA6B,GAAG,kBAAkB,CAAC;AACtD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,aAAa,GACjB,qBAAqB,GAAG,kBAAkB,CAAC;AAC9C,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,eAAe,GACnB,uBAAuB,GAAG,kBAAkB,CAAC;AAChD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,2BAA2B,GAC/B,iCAAiC,GAAG,kBAAkB,CAAC;AAC1D,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,EAAE,aAAa,GAAG,SAAS,GAAG,kBAAkB,CAAC"}
@@ -1,21 +1,14 @@
1
- /**
2
- * See the registered mapping of HF model ID => Sambanova model ID here:
3
- *
4
- * https://huggingface.co/api/partners/sambanova/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 Sambanova 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 Sambanova, please open an issue on the present repo
13
- * and we will tag Sambanova team members.
14
- *
15
- * Thanks!
16
- */
17
- import { BaseConversationalTask } from "./providerHelper";
1
+ import type { FeatureExtractionOutput } from "@huggingface/tasks";
2
+ import type { BodyParams } from "../types";
3
+ import type { FeatureExtractionTaskHelper } from "./providerHelper";
4
+ import { BaseConversationalTask, TaskProviderHelper } from "./providerHelper";
18
5
  export declare class SambanovaConversationalTask extends BaseConversationalTask {
19
6
  constructor();
20
7
  }
8
+ export declare class SambanovaFeatureExtractionTask extends TaskProviderHelper implements FeatureExtractionTaskHelper {
9
+ constructor();
10
+ makeRoute(): string;
11
+ getResponse(response: FeatureExtractionOutput): Promise<FeatureExtractionOutput>;
12
+ preparePayload(params: BodyParams): Record<string, unknown>;
13
+ }
21
14
  //# sourceMappingURL=sambanova.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sambanova.d.ts","sourceRoot":"","sources":["../../../src/providers/sambanova.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,qBAAa,2BAA4B,SAAQ,sBAAsB;;CAItE"}
1
+ {"version":3,"file":"sambanova.d.ts","sourceRoot":"","sources":["../../../src/providers/sambanova.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE9E,qBAAa,2BAA4B,SAAQ,sBAAsB;;CAItE;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"}
@@ -1,5 +1,9 @@
1
1
  import { type InferenceSnippet, type ModelDataMinimal } from "@huggingface/tasks";
2
2
  import type { InferenceProvider } from "../types";
3
3
  import type { InferenceProviderModelMapping } from "../lib/getInferenceProviderMapping";
4
- export declare function getInferenceSnippets(model: ModelDataMinimal, accessToken: string, provider: InferenceProvider, inferenceProviderMapping?: InferenceProviderModelMapping, billTo?: string, opts?: Record<string, unknown>): InferenceSnippet[];
4
+ export type InferenceSnippetOptions = {
5
+ streaming?: boolean;
6
+ billTo?: string;
7
+ } & Record<string, unknown>;
8
+ export declare function getInferenceSnippets(model: ModelDataMinimal, accessToken: string, provider: InferenceProvider, inferenceProviderMapping?: InferenceProviderModelMapping, opts?: Record<string, unknown>): InferenceSnippet[];
5
9
  //# sourceMappingURL=getInferenceSnippets.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getInferenceSnippets.d.ts","sourceRoot":"","sources":["../../../src/snippets/getInferenceSnippets.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EAGrB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,KAAK,EAAE,iBAAiB,EAA8B,MAAM,UAAU,CAAC;AAE9E,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAoTxF,wBAAgB,oBAAoB,CACnC,KAAK,EAAE,gBAAgB,EACvB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,iBAAiB,EAC3B,wBAAwB,CAAC,EAAE,6BAA6B,EACxD,MAAM,CAAC,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,gBAAgB,EAAE,CAIpB"}
1
+ {"version":3,"file":"getInferenceSnippets.d.ts","sourceRoot":"","sources":["../../../src/snippets/getInferenceSnippets.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EAGrB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,KAAK,EAAE,iBAAiB,EAA8B,MAAM,UAAU,CAAC;AAE9E,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAGxF,MAAM,MAAM,uBAAuB,GAAG;IAAE,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAiTzG,wBAAgB,oBAAoB,CACnC,KAAK,EAAE,gBAAgB,EACvB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,iBAAiB,EAC3B,wBAAwB,CAAC,EAAE,6BAA6B,EACxD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,gBAAgB,EAAE,CAIpB"}
@@ -1,2 +1,2 @@
1
- export { getInferenceSnippets } from "./getInferenceSnippets.js";
1
+ export { getInferenceSnippets, type InferenceSnippetOptions } from "./getInferenceSnippets.js";
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/snippets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/snippets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,KAAK,uBAAuB,EAAE,MAAM,2BAA2B,CAAC"}
@@ -1,6 +1,10 @@
1
1
  import type { FeatureExtractionInput } from "@huggingface/tasks";
2
2
  import type { BaseArgs, Options } from "../../types";
3
- export type FeatureExtractionArgs = BaseArgs & FeatureExtractionInput;
3
+ interface FeatureExtractionOAICompatInput {
4
+ encoding_format?: "float" | "base64";
5
+ dimensions?: number | null;
6
+ }
7
+ export type FeatureExtractionArgs = BaseArgs & FeatureExtractionInput & FeatureExtractionOAICompatInput;
4
8
  /**
5
9
  * Returned values are a multidimensional array of floats (dimension depending on if you sent a string or a list of string, and if the automatic reduction, usually mean_pooling for instance was applied for you or not. This should be explained on the model's README).
6
10
  */
@@ -9,4 +13,5 @@ export type FeatureExtractionOutput = (number | number[] | number[][])[];
9
13
  * This task reads some text and outputs raw float values, that are usually consumed as part of a semantic database/semantic search.
10
14
  */
11
15
  export declare function featureExtraction(args: FeatureExtractionArgs, options?: Options): Promise<FeatureExtractionOutput>;
16
+ export {};
12
17
  //# sourceMappingURL=featureExtraction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"featureExtraction.d.ts","sourceRoot":"","sources":["../../../../src/tasks/nlp/featureExtraction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGrD,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,sBAAsB,CAAC;AAEtE;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;AAEzE;;GAEG;AACH,wBAAsB,iBAAiB,CACtC,IAAI,EAAE,qBAAqB,EAC3B,OAAO,CAAC,EAAE,OAAO,GACf,OAAO,CAAC,uBAAuB,CAAC,CAOlC"}
1
+ {"version":3,"file":"featureExtraction.d.ts","sourceRoot":"","sources":["../../../../src/tasks/nlp/featureExtraction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGrD,UAAU,+BAA+B;IACxC,eAAe,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IACrC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,sBAAsB,GAAG,+BAA+B,CAAC;AAExG;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;AAEzE;;GAEG;AACH,wBAAsB,iBAAiB,CACtC,IAAI,EAAE,qBAAqB,EAC3B,OAAO,CAAC,EAAE,OAAO,GACf,OAAO,CAAC,uBAAuB,CAAC,CAOlC"}
@@ -1 +1 @@
1
- {"version":3,"file":"InferenceClient.spec.d.ts","sourceRoot":"","sources":["../../test/InferenceClient.spec.ts"],"names":[],"mappings":"AAcA,OAAO,OAAO,CAAC"}
1
+ {"version":3,"file":"InferenceClient.spec.d.ts","sourceRoot":"","sources":["../../test/InferenceClient.spec.ts"],"names":[],"mappings":"AAgBA,OAAO,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huggingface/inference",
3
- "version": "3.8.0",
3
+ "version": "3.8.2",
4
4
  "packageManager": "pnpm@8.10.5",
5
5
  "license": "MIT",
6
6
  "author": "Hugging Face and Tim Mikeladze <tim.mikeladze@gmail.com>",
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "type": "module",
42
42
  "dependencies": {
43
- "@huggingface/tasks": "^0.18.7",
43
+ "@huggingface/tasks": "^0.18.10",
44
44
  "@huggingface/jinja": "^0.3.4"
45
45
  },
46
46
  "devDependencies": {
@@ -119,6 +119,7 @@ export const PROVIDERS: Record<InferenceProvider, Partial<Record<InferenceTask,
119
119
  },
120
120
  sambanova: {
121
121
  conversational: new Sambanova.SambanovaConversationalTask(),
122
+ "feature-extraction": new Sambanova.SambanovaFeatureExtractionTask(),
122
123
  },
123
124
  together: {
124
125
  "text-to-image": new Together.TogetherTextToImageTask(),
@@ -241,7 +241,7 @@ export class FalAITextToSpeechTask extends FalAITask {
241
241
  return {
242
242
  ...omit(params.args, ["inputs", "parameters"]),
243
243
  ...(params.args.parameters as Record<string, unknown>),
244
- lyrics: params.args.inputs,
244
+ text: params.args.inputs,
245
245
  };
246
246
  }
247
247
 
@@ -14,10 +14,42 @@
14
14
  *
15
15
  * Thanks!
16
16
  */
17
- import { BaseConversationalTask } from "./providerHelper";
17
+ import { InferenceOutputError } from "../lib/InferenceOutputError";
18
+
19
+ import type { FeatureExtractionOutput } from "@huggingface/tasks";
20
+ import type { BodyParams } from "../types";
21
+ import type { FeatureExtractionTaskHelper } from "./providerHelper";
22
+ import { BaseConversationalTask, TaskProviderHelper } from "./providerHelper";
18
23
 
19
24
  export class SambanovaConversationalTask extends BaseConversationalTask {
20
25
  constructor() {
21
26
  super("sambanova", "https://api.sambanova.ai");
22
27
  }
23
28
  }
29
+
30
+ export class SambanovaFeatureExtractionTask extends TaskProviderHelper implements FeatureExtractionTaskHelper {
31
+ constructor() {
32
+ super("sambanova", "https://api.sambanova.ai");
33
+ }
34
+
35
+ override makeRoute(): string {
36
+ return `/v1/embeddings`;
37
+ }
38
+
39
+ override async getResponse(response: FeatureExtractionOutput): Promise<FeatureExtractionOutput> {
40
+ if (typeof response === "object" && "data" in response && Array.isArray(response.data)) {
41
+ return response.data.map((item) => item.embedding);
42
+ }
43
+ throw new InferenceOutputError(
44
+ "Expected Sambanova feature-extraction (embeddings) response format to be {'data' : list of {'embedding' : number[]}}"
45
+ );
46
+ }
47
+
48
+ override preparePayload(params: BodyParams): Record<string, unknown> {
49
+ return {
50
+ model: params.model,
51
+ input: params.args.inputs,
52
+ ...params.args,
53
+ };
54
+ }
55
+ }
@@ -14,6 +14,8 @@ import { templates } from "./templates.exported";
14
14
  import type { InferenceProviderModelMapping } from "../lib/getInferenceProviderMapping";
15
15
  import { getProviderHelper } from "../lib/getProviderHelper";
16
16
 
17
+ export type InferenceSnippetOptions = { streaming?: boolean; billTo?: string } & Record<string, unknown>;
18
+
17
19
  const PYTHON_CLIENTS = ["huggingface_hub", "fal_client", "requests", "openai"] as const;
18
20
  const JS_CLIENTS = ["fetch", "huggingface.js", "openai"] as const;
19
21
  const SH_CLIENTS = ["curl"] as const;
@@ -120,8 +122,7 @@ const snippetGenerator = (templateName: string, inputPreparationFn?: InputPrepar
120
122
  accessToken: string,
121
123
  provider: InferenceProvider,
122
124
  inferenceProviderMapping?: InferenceProviderModelMapping,
123
- billTo?: string,
124
- opts?: Record<string, unknown>
125
+ opts?: InferenceSnippetOptions
125
126
  ): InferenceSnippet[] => {
126
127
  const providerModelId = inferenceProviderMapping?.providerId ?? model.id;
127
128
  /// Hacky: hard-code conversational templates here
@@ -155,7 +156,7 @@ const snippetGenerator = (templateName: string, inputPreparationFn?: InputPrepar
155
156
  inferenceProviderMapping,
156
157
  {
157
158
  task,
158
- billTo,
159
+ billTo: opts?.billTo,
159
160
  }
160
161
  );
161
162
 
@@ -194,7 +195,7 @@ const snippetGenerator = (templateName: string, inputPreparationFn?: InputPrepar
194
195
  model,
195
196
  provider,
196
197
  providerModelId: providerModelId ?? model.id,
197
- billTo,
198
+ billTo: opts?.billTo,
198
199
  };
199
200
 
200
201
  /// Iterate over clients => check if a snippet exists => generate
@@ -283,8 +284,7 @@ const snippets: Partial<
283
284
  accessToken: string,
284
285
  provider: InferenceProvider,
285
286
  inferenceProviderMapping?: InferenceProviderModelMapping,
286
- billTo?: string,
287
- opts?: Record<string, unknown>
287
+ opts?: InferenceSnippetOptions
288
288
  ) => InferenceSnippet[]
289
289
  >
290
290
  > = {
@@ -324,11 +324,10 @@ export function getInferenceSnippets(
324
324
  accessToken: string,
325
325
  provider: InferenceProvider,
326
326
  inferenceProviderMapping?: InferenceProviderModelMapping,
327
- billTo?: string,
328
327
  opts?: Record<string, unknown>
329
328
  ): InferenceSnippet[] {
330
329
  return model.pipeline_tag && model.pipeline_tag in snippets
331
- ? snippets[model.pipeline_tag]?.(model, accessToken, provider, inferenceProviderMapping, billTo, opts) ?? []
330
+ ? snippets[model.pipeline_tag]?.(model, accessToken, provider, inferenceProviderMapping, opts) ?? []
332
331
  : [];
333
332
  }
334
333
 
@@ -1 +1 @@
1
- export { getInferenceSnippets } from "./getInferenceSnippets.js";
1
+ export { getInferenceSnippets, type InferenceSnippetOptions } from "./getInferenceSnippets.js";
@@ -3,7 +3,12 @@ import { getProviderHelper } from "../../lib/getProviderHelper";
3
3
  import type { BaseArgs, Options } from "../../types";
4
4
  import { innerRequest } from "../../utils/request";
5
5
 
6
- export type FeatureExtractionArgs = BaseArgs & FeatureExtractionInput;
6
+ interface FeatureExtractionOAICompatInput {
7
+ encoding_format?: "float" | "base64";
8
+ dimensions?: number | null;
9
+ }
10
+
11
+ export type FeatureExtractionArgs = BaseArgs & FeatureExtractionInput & FeatureExtractionOAICompatInput;
7
12
 
8
13
  /**
9
14
  * Returned values are a multidimensional array of floats (dimension depending on if you sent a string or a list of string, and if the automatic reduction, usually mean_pooling for instance was applied for you or not. This should be explained on the model's README).