Skip to content

Commit ba6e1a8

Browse files
[Inference] Fix sentence-similarity inputs (#1316)
This was broken before because one of the input parameters was incorrectly being sent as part of the `parameters` object instead of the `inputs`, this PR fixes that. ```js import { InferenceClient } from "@huggingface/inference"; const client = new InferenceClient("hf_xxxxxxxxxxxxxxxxxxxxxxxx"); const output = await client.sentenceSimilarity({ model: "sentence-transformers/all-MiniLM-L6-v2", inputs: { "source_sentence": "That is a happy person", "sentences": [ "That is a happy dog", "That is a very happy person", "Today is a sunny day" ] }, provider: "hf-inference", }); console.log(output); ```
1 parent c052632 commit ba6e1a8

File tree

4 files changed

+7162
-7146
lines changed

4 files changed

+7162
-7146
lines changed

packages/inference/src/tasks/nlp/sentenceSimilarity.ts

+1-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type { SentenceSimilarityInput, SentenceSimilarityOutput } from "@hugging
22
import { InferenceOutputError } from "../../lib/InferenceOutputError";
33
import type { BaseArgs, Options } from "../../types";
44
import { request } from "../custom/request";
5-
import { omit } from "../../utils/omit";
65

76
export type SentenceSimilarityArgs = BaseArgs & SentenceSimilarityInput;
87

@@ -13,7 +12,7 @@ export async function sentenceSimilarity(
1312
args: SentenceSimilarityArgs,
1413
options?: Options
1514
): Promise<SentenceSimilarityOutput> {
16-
const res = await request<SentenceSimilarityOutput>(prepareInput(args), {
15+
const res = await request<SentenceSimilarityOutput>(args, {
1716
...options,
1817
task: "sentence-similarity",
1918
});
@@ -24,11 +23,3 @@ export async function sentenceSimilarity(
2423
}
2524
return res;
2625
}
27-
28-
function prepareInput(args: SentenceSimilarityArgs) {
29-
return {
30-
...omit(args, ["inputs", "parameters"]),
31-
inputs: { ...omit(args.inputs, "sourceSentence") },
32-
parameters: { source_sentence: args.inputs.sourceSentence, ...args.parameters },
33-
};
34-
}

0 commit comments

Comments
 (0)