修复输入内容过长报错

master
落雨楓 2 years ago
parent 9ab83270e7
commit 81562cba4d

@ -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"

Loading…
Cancel
Save