@huggingface/inference
Advanced tools
Comparing version 2.7.0 to 2.7.1
@@ -690,8 +690,18 @@ var __defProp = Object.defineProperty; | ||
// src/utils/toArray.ts | ||
function toArray(obj) { | ||
if (Array.isArray(obj)) { | ||
return obj; | ||
} | ||
return [obj]; | ||
} | ||
// src/tasks/nlp/textGeneration.ts | ||
async function textGeneration(args, options) { | ||
const res = await request(args, { | ||
...options, | ||
taskHint: "text-generation" | ||
}); | ||
const res = toArray( | ||
await request(args, { | ||
...options, | ||
taskHint: "text-generation" | ||
}) | ||
); | ||
const isValidOutput = Array.isArray(res) && res.every((x) => typeof x?.generated_text === "string"); | ||
@@ -712,10 +722,2 @@ if (!isValidOutput) { | ||
// src/utils/toArray.ts | ||
function toArray(obj) { | ||
if (Array.isArray(obj)) { | ||
return obj; | ||
} | ||
return [obj]; | ||
} | ||
// src/tasks/nlp/tokenClassification.ts | ||
@@ -722,0 +724,0 @@ async function tokenClassification(args, options) { |
{ | ||
"name": "@huggingface/inference", | ||
"version": "2.7.0", | ||
"version": "2.7.1", | ||
"packageManager": "pnpm@8.10.5", | ||
@@ -42,3 +42,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"@huggingface/tasks": "^0.10.0" | ||
"@huggingface/tasks": "^0.11.2" | ||
}, | ||
@@ -45,0 +45,0 @@ "devDependencies": { |
import type { TextGenerationInput, TextGenerationOutput } from "@huggingface/tasks"; | ||
import { InferenceOutputError } from "../../lib/InferenceOutputError"; | ||
import type { BaseArgs, Options } from "../../types"; | ||
import { toArray } from "../../utils/toArray"; | ||
import { request } from "../custom/request"; | ||
@@ -15,6 +16,8 @@ | ||
): Promise<TextGenerationOutput> { | ||
const res = await request<TextGenerationOutput[]>(args, { | ||
...options, | ||
taskHint: "text-generation", | ||
}); | ||
const res = toArray( | ||
await request<TextGenerationOutput | TextGenerationOutput[]>(args, { | ||
...options, | ||
taskHint: "text-generation", | ||
}) | ||
); | ||
const isValidOutput = Array.isArray(res) && res.every((x) => typeof x?.generated_text === "string"); | ||
@@ -21,0 +24,0 @@ if (!isValidOutput) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
235107
5290
+ Added@huggingface/tasks@0.11.13(transitive)
- Removed@huggingface/tasks@0.10.22(transitive)
Updated@huggingface/tasks@^0.11.2