Browse Source

fix token limit count

master
Hendrik Langer 2 years ago
parent
commit
f5e3679365
  1. 4
      matrix_pygmalion_bot/ai/runpod_pygmalion.py

4
matrix_pygmalion_bot/ai/runpod_pygmalion.py

@ -114,13 +114,15 @@ async def get_full_prompt(simple_prompt: str, bot, chat_history):
break break
if chat_item.message["en"].startswith('!'): if chat_item.message["en"].startswith('!'):
continue continue
if chat_item.message["en"].startswith('<ERROR>'):
continue
#if chat_item.message["en"] == bot.greeting: #if chat_item.message["en"] == bot.greeting:
# continue # continue
if chat_item.num_tokens == None: if chat_item.num_tokens == None:
chat_item.num_tokens = await num_tokens("{}: {}".format(chat_item.user_name, chat_item.message["en"])) 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?? # TODO: is it MAX_TOKENS or MAX_TOKENS - max_new_tokens??
logger.debug(f"History: " + str(chat_item) + " [" + str(chat_item.num_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) visible_history.append(chat_item)
total_num_tokens += chat_item.num_tokens total_num_tokens += chat_item.num_tokens
else: else:

Loading…
Cancel
Save