From 1cf3ca52853439ee39c361559fe7a3018bd98371 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Sat, 6 May 2023 19:07:13 +0200 Subject: [PATCH] be a bit more conservative when summarizing in-line --- matrix_pygmalion_bot/bot/ai/langchain.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/matrix_pygmalion_bot/bot/ai/langchain.py b/matrix_pygmalion_bot/bot/ai/langchain.py index 40b03aa..3d4359c 100644 --- a/matrix_pygmalion_bot/bot/ai/langchain.py +++ b/matrix_pygmalion_bot/bot/ai/langchain.py @@ -243,8 +243,8 @@ class AI(object): tmp_prompt_text = prompt.format(chat_history=conversation_memory.buffer, input=message.content) prompt_len = self.llm_chat.get_num_tokens(tmp_prompt_text) - if prompt_len+256 > 2000: - logger.warning(f"Prompt too large. Estimated {prompt_len} tokens") + if prompt_len+200 > 2048: + logger.warning(f"Prompt too large. Estimated {prompt_len} tokens. Summarizing...") await reply_fn(f" Prompt too large. Estimated {prompt_len} tokens") if i == 0: await conversation_memory.prune_memory(conversation_memory.min_len)