desprit / tg-ai-connector

This package can be used to connect Telegram bot to AI engines such as OpenAI ChatGPT, Dall-E, Midjourney, Stable Diffusion, etc.
49 stars 9 forks source link

Trim prompt when it exceeds 4k tokens #7

Closed desprit closed 1 year ago

desprit commented 1 year ago

I'm receiving the following error:

This model's maximum context length is 4097 tokens, however you requested 4396 tokens (3896 in your prompt; 500 for the completion). Please reduce your prompt; or completion length.

since it stores 10 history entries by default, conversation gets often stuck at some point

should probably clean some old messages to stay within limits

desprit commented 1 year ago

Haven't seen this issue for a very long time. I think it got solved with one of the previous commits addressing errors handling.