@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.
- package/dist/commonjs/default-widget-inputs.js +3 -3
- package/dist/commonjs/hardware.d.ts +69 -1
- package/dist/commonjs/hardware.d.ts.map +1 -1
- package/dist/commonjs/hardware.js +69 -1
- package/dist/commonjs/local-apps.d.ts.map +1 -1
- package/dist/commonjs/local-apps.js +7 -6
- package/dist/commonjs/model-libraries-snippets.d.ts.map +1 -1
- package/dist/commonjs/model-libraries-snippets.js +4 -11
- package/dist/commonjs/model-libraries.d.ts +7 -1
- package/dist/commonjs/model-libraries.d.ts.map +1 -1
- package/dist/commonjs/model-libraries.js +7 -1
- package/dist/commonjs/snippets/python.d.ts.map +1 -1
- package/dist/esm/default-widget-inputs.js +3 -3
- package/dist/esm/hardware.d.ts +69 -1
- package/dist/esm/hardware.d.ts.map +1 -1
- package/dist/esm/hardware.js +69 -1
- package/dist/esm/local-apps.d.ts.map +1 -1
- package/dist/esm/local-apps.js +7 -6
- package/dist/esm/model-libraries-snippets.d.ts.map +1 -1
- package/dist/esm/model-libraries-snippets.js +4 -11
- package/dist/esm/model-libraries.d.ts +7 -1
- package/dist/esm/model-libraries.d.ts.map +1 -1
- package/dist/esm/model-libraries.js +7 -1
- package/dist/esm/snippets/python.d.ts.map +1 -1
- package/dist/esm/snippets/python.js +1 -1
- package/package.json +1 -1
- package/src/default-widget-inputs.ts +3 -3
- package/src/hardware.ts +69 -1
- package/src/local-apps.ts +9 -6
- package/src/model-libraries-snippets.ts +4 -11
- package/src/model-libraries.ts +7 -1
- package/src/snippets/js.ts +12 -12
- package/src/snippets/python.ts +17 -20
package/src/snippets/python.ts
CHANGED
|
@@ -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
|
-
|
|
211
|
-
|
|
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
|
-
|
|
277
|
-
|
|
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
|
-
|
|
295
|
-
|
|
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
|
};
|