|
|
@ -131,14 +131,15 @@ class ChatCompleteService:
|
|
|
|
self.question_tokens = await self.get_question_tokens(question)
|
|
|
|
self.question_tokens = await self.get_question_tokens(question)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.question_tokens = question_tokens
|
|
|
|
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)
|
|
|
|
max_input_tokens = Config.get("chatcomplete.max_input_tokens", 768, int)
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
len(question) * 4 > max_input_tokens
|
|
|
|
self.question_tokens > max_input_tokens
|
|
|
|
and self.question_tokens > max_input_tokens
|
|
|
|
|
|
|
|
):
|
|
|
|
):
|
|
|
|
# If the question is too long, we need to truncate it
|
|
|
|
# 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:
|
|
|
|
if self.conversation_info is not None:
|
|
|
|
self.bot_id = self.conversation_info.extra.get("bot_id") or "default"
|
|
|
|
self.bot_id = self.conversation_info.extra.get("bot_id") or "default"
|
|
|
|