From 8366aef668924b33af4601c87fdf9adc9161c0d1 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 21 Feb 2024 16:49:10 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20remove=20stop=20token=20from=20h?= =?UTF-8?q?f=20response?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/llm/llms/HuggingFaceInferenceAPI.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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; + } } } }