From f5e3679365d29fdc27799edf81f53d41c7911151 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Mon, 3 Apr 2023 00:13:21 +0200 Subject: [PATCH] fix token limit count --- matrix_pygmalion_bot/ai/runpod_pygmalion.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/matrix_pygmalion_bot/ai/runpod_pygmalion.py b/matrix_pygmalion_bot/ai/runpod_pygmalion.py index 2a367d5..30ee8ba 100644 --- a/matrix_pygmalion_bot/ai/runpod_pygmalion.py +++ b/matrix_pygmalion_bot/ai/runpod_pygmalion.py @@ -114,13 +114,15 @@ async def get_full_prompt(simple_prompt: str, bot, chat_history): break if chat_item.message["en"].startswith('!'): continue + if chat_item.message["en"].startswith(''): + continue #if chat_item.message["en"] == bot.greeting: # continue if chat_item.num_tokens == None: chat_item.num_tokens = await num_tokens("{}: {}".format(chat_item.user_name, chat_item.message["en"])) # TODO: is it MAX_TOKENS or MAX_TOKENS - max_new_tokens?? logger.debug(f"History: " + str(chat_item) + " [" + str(chat_item.num_tokens) + "]") - if total_num_tokens < (MAX_TOKENS - max_new_tokens): + if total_num_tokens + chat_item.num_tokens < MAX_TOKENS - max_new_tokens: visible_history.append(chat_item) total_num_tokens += chat_item.num_tokens else: