Skip to content

Commit cba9580

Browse files
committed
lint
1 parent 3dbb6ff commit cba9580

File tree

3 files changed

+31
-23
lines changed

3 files changed

+31
-23
lines changed

packages/inference/src/lib/makeRequestOptions.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,21 @@ export async function makeRequestOptions(
6868
? "hf-token"
6969
: "provider-key"
7070
: includeCredentials === "include"
71-
? "credentials-include"
72-
: "none";
71+
? "credentials-include"
72+
: "none";
7373

7474
const url = endpointUrl
7575
? chatCompletion
7676
? endpointUrl + `/v1/chat/completions`
7777
: endpointUrl
7878
: makeUrl({
79-
authMethod,
80-
chatCompletion: chatCompletion ?? false,
81-
forceTask,
82-
model,
83-
provider: provider ?? "hf-inference",
84-
taskHint,
85-
});
79+
authMethod,
80+
chatCompletion: chatCompletion ?? false,
81+
forceTask,
82+
model,
83+
provider: provider ?? "hf-inference",
84+
taskHint,
85+
});
8686

8787
const headers: Record<string, string> = {};
8888
if (accessToken) {
@@ -131,11 +131,11 @@ export async function makeRequestOptions(
131131
body: binary
132132
? args.data
133133
: JSON.stringify({
134-
...otherArgs,
135-
...(chatCompletion || provider === "together" || provider === "nebius" || provider === "hyperbolic"
136-
? { model }
137-
: undefined),
138-
}),
134+
...otherArgs,
135+
...(chatCompletion || provider === "together" || provider === "nebius" || provider === "hyperbolic"
136+
? { model }
137+
: undefined),
138+
}),
139139
...(credentials ? { credentials } : undefined),
140140
signal: options?.signal,
141141
};

packages/inference/src/tasks/cv/textToImage.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface OutputUrlImageGeneration {
1515
output: string[];
1616
}
1717
interface HyperbolicTextToImageOutput {
18-
images: Array<{ image: string }>
18+
images: Array<{ image: string }>;
1919
}
2020

2121
function getResponseFormatArg(provider: InferenceProvider) {
@@ -42,12 +42,14 @@ export async function textToImage(args: TextToImageArgs, options?: Options): Pro
4242
!args.provider || args.provider === "hf-inference" || args.provider === "sambanova"
4343
? args
4444
: {
45-
...omit(args, ["inputs", "parameters"]),
46-
...args.parameters,
47-
...getResponseFormatArg(args.provider),
48-
prompt: args.inputs,
49-
};
50-
const res = await request<TextToImageOutput | Base64ImageGeneration | OutputUrlImageGeneration | HyperbolicTextToImageOutput>(payload, {
45+
...omit(args, ["inputs", "parameters"]),
46+
...args.parameters,
47+
...getResponseFormatArg(args.provider),
48+
prompt: args.inputs,
49+
};
50+
const res = await request<
51+
TextToImageOutput | Base64ImageGeneration | OutputUrlImageGeneration | HyperbolicTextToImageOutput
52+
>(payload, {
5153
...options,
5254
taskHint: "text-to-image",
5355
});
@@ -57,7 +59,13 @@ export async function textToImage(args: TextToImageArgs, options?: Options): Pro
5759
const image = await fetch(res.images[0].url);
5860
return await image.blob();
5961
}
60-
if (args.provider === "hyperbolic" && "images" in res && Array.isArray(res.images) && res.images[0] && typeof res.images[0].image === "string") {
62+
if (
63+
args.provider === "hyperbolic" &&
64+
"images" in res &&
65+
Array.isArray(res.images) &&
66+
res.images[0] &&
67+
typeof res.images[0].image === "string"
68+
) {
6169
const base64Response = await fetch(`data:image/jpeg;base64,${res.images[0].image}`);
6270
const blob = await base64Response.blob();
6371
return blob;

packages/inference/test/HfInference.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1248,7 +1248,7 @@ describe.concurrent("HfInference", () => {
12481248
temperature: 0,
12491249
top_p: 0.01,
12501250
max_new_tokens: 10,
1251-
}
1251+
},
12521252
});
12531253
expect(res).toMatchObject({ generated_text: "...the capital and most populous city of France," });
12541254
});

0 commit comments

Comments
 (0)