From 81562cba4db2e53de9182e5fe09dae646375e8e4 Mon Sep 17 00:00:00 2001 From: Lex Lim Date: Thu, 29 Jun 2023 14:59:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BE=93=E5=85=A5=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E8=BF=87=E9=95=BF=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/chat_complete.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/service/chat_complete.py b/service/chat_complete.py index 6c9e09f..79d360f 100644 --- a/service/chat_complete.py +++ b/service/chat_complete.py @@ -131,14 +131,15 @@ class ChatCompleteService: self.question_tokens = await self.get_question_tokens(question) else: self.question_tokens = question_tokens + if self.question_tokens == 0: + self.question_tokens = len(question) * 3 max_input_tokens = Config.get("chatcomplete.max_input_tokens", 768, int) if ( - len(question) * 4 > max_input_tokens - and self.question_tokens > max_input_tokens + self.question_tokens > max_input_tokens ): # If the question is too long, we need to truncate it - raise web.HTTPRequestEntityTooLarge() + raise web.HTTPRequestEntityTooLarge(max_input_tokens, self.question_tokens) if self.conversation_info is not None: self.bot_id = self.conversation_info.extra.get("bot_id") or "default"