iongpt / LLM-for-Whatsapp

WhatsApp client with LLM integration. It support OpenAI API and also local LLMs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Context length limit

ViolentVotan opened this issue · comments

For OpenAI, a context length limitation would be great to control cost when using gpt4.

Currently, the maximum context is set at 4000 CHARACTERS, around 1300 tokens.
At every message, there is a context trimming function that deletes older messages to fit into 4000 characters limit.

The code is here:

function trimMessages(contact) {

I am going to change the scope of this ticket to make that 4000, currently hardcoded value, configurable from UI.

For now, the work around is to change the 4000 value in this line:

while (totalChars > 4000 && contact.messages.length > 1) {
with the desired value and rebuild the app