@huggingface/tasks 0.16.0 → 0.16.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.
@@ -1,7 +1,4 @@
1
- import {
2
- openAIbaseUrl,
3
- type SnippetInferenceProvider,
4
- } from "../inference-providers.js";
1
+ import { openAIbaseUrl, type SnippetInferenceProvider } from "../inference-providers.js";
5
2
  import type { PipelineType, WidgetType } from "../pipelines.js";
6
3
  import type { ChatCompletionInputMessage, GenerationParameters } from "../tasks/index.js";
7
4
  import { stringifyGenerationConfig, stringifyMessages } from "./common.js";
@@ -206,9 +203,9 @@ export const snippetBasic = (
206
203
  return [
207
204
  ...(model.pipeline_tag && model.pipeline_tag in HFH_INFERENCE_CLIENT_METHODS
208
205
  ? [
209
- {
210
- client: "huggingface_hub",
211
- content: `\
206
+ {
207
+ client: "huggingface_hub",
208
+ content: `\
212
209
  ${snippetImportInferenceClient(accessToken, provider)}
213
210
 
214
211
  result = client.${HFH_INFERENCE_CLIENT_METHODS[model.pipeline_tag]}(
@@ -219,8 +216,8 @@ result = client.${HFH_INFERENCE_CLIENT_METHODS[model.pipeline_tag]}(
219
216
 
220
217
  print(result)
221
218
  `,
222
- },
223
- ]
219
+ },
220
+ ]
224
221
  : []),
225
222
  {
226
223
  client: "requests",
@@ -256,7 +253,7 @@ export const snippetTextToImage = (
256
253
  model: ModelDataMinimal,
257
254
  accessToken: string,
258
255
  provider: SnippetInferenceProvider,
259
- providerModelId?: string,
256
+ providerModelId?: string
260
257
  ): InferenceSnippet[] => {
261
258
  return [
262
259
  {
@@ -272,9 +269,9 @@ image = client.text_to_image(
272
269
  },
273
270
  ...(provider === "fal-ai"
274
271
  ? [
275
- {
276
- client: "fal-client",
277
- content: `\
272
+ {
273
+ client: "fal-client",
274
+ content: `\
278
275
  import fal_client
279
276
 
280
277
  result = fal_client.subscribe(
@@ -285,14 +282,14 @@ result = fal_client.subscribe(
285
282
  )
286
283
  print(result)
287
284
  `,
288
- },
289
- ]
285
+ },
286
+ ]
290
287
  : []),
291
288
  ...(provider === "hf-inference"
292
289
  ? [
293
- {
294
- client: "requests",
295
- content: `\
290
+ {
291
+ client: "requests",
292
+ content: `\
296
293
  def query(payload):
297
294
  response = requests.post(API_URL, headers=headers, json=payload)
298
295
  return response.content
@@ -305,8 +302,8 @@ image_bytes = query({
305
302
  import io
306
303
  from PIL import Image
307
304
  image = Image.open(io.BytesIO(image_bytes))`,
308
- },
309
- ]
305
+ },
306
+ ]
310
307
  : []),
311
308
  ];
312
309
  };