You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there, found a bug on HFInference.chatCompletionStream implementation specified below:
Environment
Library: @huggingface/inference
version: "^2.8.0"
Function: chatCompletionStream in streamingRequest
Problem
In the HFInference.chatCompletionStream implementation, the streamingRequest function throws errors incorrectly when the data.error field is an object. Specifically, the following code causes the error message to display [object Object] instead of the actual error content:
for (const event of events) {
if (event.data.length > 0) {
if (event.data === "[DONE]") {
return;
}
const data = JSON.parse(event.data);
if (typeof data === "object" && data !== null && "error" in data) {
throw new Error(data.error); // This causes [object Object] to be thrown
}
yield data as T;
}
}
The error should contain the message field or be stringified to provide readable error information, such as:
Error: Input validation error: inputs tokens + max_new_tokens must be <= 4096. Given: 48 inputs tokens and 4096 max_new_tokens
Suggested Fix
change throw new Error(data.error);
to explicitly stringify the error message: throw new Error(data.error.message || JSON.stringify(data.error));
Thanks!
The text was updated successfully, but these errors were encountered:
Hi there, found a bug on
HFInference.chatCompletionStream
implementation specified below:Environment
Library: @huggingface/inference
version: "^2.8.0"
Function: chatCompletionStream in streamingRequest
Problem
In the
HFInference.chatCompletionStream
implementation, the streamingRequest function throws errors incorrectly when the data.error field is an object. Specifically, the following code causes the error message to display [object Object] instead of the actual error content:The error should contain the message field or be stringified to provide readable error information, such as:
Suggested Fix
change
throw new Error(data.error);
to explicitly stringify the error message:
throw new Error(data.error.message || JSON.stringify(data.error));
Thanks!
The text was updated successfully, but these errors were encountered: