From 0a888733ce3d3eef5a38cfe10e697290e9f021d7 Mon Sep 17 00:00:00 2001 From: kuangquanshuisn Date: Mon, 28 Oct 2024 11:28:04 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20Resolve=20the=20issue=20o?= =?UTF-8?q?f=20the=20Huggingface=20API=20interrupting=20when=20the=20outpu?= =?UTF-8?q?t=20exceeds=20140=20tokens?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 解决Huggingface API在输出超过140多个token时中断的问题 --- src/libs/agent-runtime/huggingface/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/agent-runtime/huggingface/index.ts b/src/libs/agent-runtime/huggingface/index.ts index 78aa41b36fabc..b31a12b1af276 100644 --- a/src/libs/agent-runtime/huggingface/index.ts +++ b/src/libs/agent-runtime/huggingface/index.ts @@ -21,8 +21,10 @@ export const LobeHuggingFaceAI = LobeOpenAICompatibleFactory({ }, customClient: { createChatCompletionStream: (client: HfInference, payload, instance) => { + const { max_tokens = 4096} = payload; const hfRes = client.chatCompletionStream({ endpointUrl: instance.baseURL, + max_tokens: max_tokens, messages: payload.messages, model: payload.model, stream: true,