diff --git a/core/llm/llms/HuggingFaceInferenceAPI.ts b/core/llm/llms/HuggingFaceInferenceAPI.ts index 8cb2b928d..81c29e79a 100644 --- a/core/llm/llms/HuggingFaceInferenceAPI.ts +++ b/core/llm/llms/HuggingFaceInferenceAPI.ts @@ -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("")) { + yield text.slice(0, -5); + } else { + yield text; + } } } }