@huggingface/inference 1.7.0 → 1.7.1
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/README.md +3 -2
- package/dist/index.js +6 -0
- package/dist/index.mjs +6 -0
- package/package.json +1 -1
- package/src/HfInference.ts +7 -0
package/README.md
CHANGED
|
@@ -76,9 +76,10 @@ await hf.textGeneration({
|
|
|
76
76
|
inputs: 'The answer to the universe is'
|
|
77
77
|
})
|
|
78
78
|
|
|
79
|
-
for await const
|
|
79
|
+
for await (const output of hf.textGenerationStream({
|
|
80
80
|
model: "google/flan-t5-xxl",
|
|
81
|
-
inputs: 'repeat "one two three four"'
|
|
81
|
+
inputs: 'repeat "one two three four"',
|
|
82
|
+
parameters: { max_new_tokens: 250 }
|
|
82
83
|
})) {
|
|
83
84
|
console.log(output.token.text, output.generated_text);
|
|
84
85
|
}
|
package/dist/index.js
CHANGED
|
@@ -456,6 +456,12 @@ var HfInference = class {
|
|
|
456
456
|
});
|
|
457
457
|
}
|
|
458
458
|
if (!response.ok) {
|
|
459
|
+
if (response.headers.get("Content-Type")?.startsWith("application/json")) {
|
|
460
|
+
const output = await response.json();
|
|
461
|
+
if (output.error) {
|
|
462
|
+
throw new Error(output.error);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
459
465
|
throw new Error(`Server response contains error: ${response.status}`);
|
|
460
466
|
}
|
|
461
467
|
if (response.headers.get("content-type") !== "text/event-stream") {
|
package/dist/index.mjs
CHANGED
|
@@ -430,6 +430,12 @@ var HfInference = class {
|
|
|
430
430
|
});
|
|
431
431
|
}
|
|
432
432
|
if (!response.ok) {
|
|
433
|
+
if (response.headers.get("Content-Type")?.startsWith("application/json")) {
|
|
434
|
+
const output = await response.json();
|
|
435
|
+
if (output.error) {
|
|
436
|
+
throw new Error(output.error);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
433
439
|
throw new Error(`Server response contains error: ${response.status}`);
|
|
434
440
|
}
|
|
435
441
|
if (response.headers.get("content-type") !== "text/event-stream") {
|
package/package.json
CHANGED
package/src/HfInference.ts
CHANGED
|
@@ -1038,6 +1038,13 @@ export class HfInference {
|
|
|
1038
1038
|
});
|
|
1039
1039
|
}
|
|
1040
1040
|
if (!response.ok) {
|
|
1041
|
+
if (response.headers.get("Content-Type")?.startsWith("application/json")) {
|
|
1042
|
+
const output = await response.json();
|
|
1043
|
+
if (output.error) {
|
|
1044
|
+
throw new Error(output.error);
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1041
1048
|
throw new Error(`Server response contains error: ${response.status}`);
|
|
1042
1049
|
}
|
|
1043
1050
|
if (response.headers.get("content-type") !== "text/event-stream") {
|