#Json file content not getting passed to api after exceeding specific amount of content

4 messages · Page 1 of 1 (latest)

tight mango
#

I need some help with the Completion.create method.
I'm saving previous messages in a .json file with the following layout: ```json
{
"\nUser: Who are you Rachel?": "\n\nRachel: I am Rachel, a chatbot!.\n",
"\nUser: Rachel how old are you?": "\n\nRachel: I don't have a exact age but I was created on xxxxx.\n",
"\nUser: You are funny Rachel": "\n\nRachel: Why thank you :).\n",
}


I'm passing the log to my openai call with this line: `prompt_text = f'{chat_log}{restart_sequence}: {question}{start_sequence}'`, where chat_log being the content of the `.json` file, restart_sequence being "\nUser:", question being the discord message and start_sequence being "\n\nRachel".

When my `.json` file exceeds the exact amount of 83 lines (aka. 83 messages), it won't get passed to the openai api anymore and my bot won't generate any new message.

Is that a bug, do I need do change something or did I miss something or anything else? Any help or advice is highly appreciated!
#

Json file content not getting passed to api after exceeding specific amount of content

#

if needed, this is the function in my discord api (py) ```py
if msg_content.startswith("rachel") or pattern.search(msg_content):
loading_message: discord.Message = await message.channel.send(content="thinking...",
reference=message)
with open("assets/session_prompt.json", encoding='utf-8') as rachel_brain:
chat_log = json.load(rachel_brain)
answer = await ask(question=msg_content, chat_log=chat_log)
thought = await loading_message.edit(content=answer)
if thought.content == "I don't want to talk about this.":
return
else:
with open("assets/session_prompt.json", encoding='utf-8') as knowledge:
braincells = json.load(knowledge)
braincells[f'{restart_sequence} {msg_content}'] = f'{start_sequence} {thought.content}\n'
with open("assets/session_prompt.json", "w", encoding='utf-8') as new_knowledge:
json.dump(braincells, new_knowledge, indent=2, ensure_ascii=False)

tight mango
#

bump