🐛 remove stop token from hf response

This commit is contained in:
Nate Sesti 2024-02-21 16:49:10 -08:00
parent 2c395fb66b
commit 8366aef668

View file

@ -35,7 +35,12 @@ class HuggingFaceInferenceAPI extends BaseLLM {
}),
});
for await (const chunk of streamSse(response)) {
yield chunk?.token?.text || "";
let text = chunk?.token?.text ?? "";
if (text.endsWith("</s>")) {
yield text.slice(0, -5);
} else {
yield text;
}
}
}
}