Browse Source

be a bit more conservative when summarizing in-line

master
Hendrik Langer 1 year ago
parent
commit
1cf3ca5285
  1. 4
      matrix_pygmalion_bot/bot/ai/langchain.py

4
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"<WARNING> Prompt too large. Estimated {prompt_len} tokens")
if i == 0:
await conversation_memory.prune_memory(conversation_memory.min_len)

Loading…
Cancel
Save