Closed kawuwa closed 1 year ago
I'll try to explain the error, and suggest a workaround.
When sending a request to GPT, the app has to estimate in advance the token length of the input, and add it to the desired length of the output (so that input length + output length = max tokens).
This can either be done using model-specific tools (tokenizers), or roughly estimated using heuristics. I use the latter at the moment, because I ran into trouble using a tokenizer. Therefore, Jarvis' estimation is not perfect, and sometimes underestimates the true length of the input. This is especially true for shorter prompts, where the estimation error tends to be larger. In your example, Jarvis estimated the input length at 2 tokens, but in practice, on the OpenAI server, it turned out to be 23.
The best solution I can offer for now is to set the max_tokens
to something close to 4097 but a little lower, like 4000. When I do that, I rarely get these error messages.
In any case, the error is automatically resolved by Jarvis, by decreasing the token estimation and re-sending the request.
I think I will change the maximal value to be lower than 4096 (at least for short prompts), to try to avoid these problems in the future.
BTW, this is why the default value of max_tokens
was set to 4000 since v0.3.0
Successfully! Thank you very much!😃
How to speak English? erro:~~~ after I click ok