Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I found a conflict with
maxResponseTokens
@transitive-bullshitProblem 1
From one side,
buildMessages()
now has logic to limit prompt length, because we include "history messages" and wanna know when to stop adding them. From another hand, prompt length defines a length of response, because total sub should not exceedmaxModelTokens
. The we have the following:parentMessageId
s in my chatbot, so my users send short prompts, but get responses only of 1000 tokens length, because it's a default valuemaxResponseTokens: 4096
as max allowed value, expect maximum length responsesmaxResponseTokens
, but don't know for how much because I want to use full capacity of 4096 tokens but don't know what user prompt length isSolution
If user passed a prompt and it exceeds the limits, we should throw exception to him, instead of skipping the userPrompt and sending systemMessage only. Then let's mark systemMessage and userPromp as "required" messages, which means that if they are passed the take prioritized tokens space. And if they exceed limits - we throw exception.
Now the flow looks like this:
maxModelTokens - 1
value, ignoringmaxResponseTokens
. Where1
- minimum space for response. If user entersmaxModelTokens - 1
tokens length prompt, he will get 1 token inresponse. If he enters prompt bigger than
maxModelTokens - 1
, there will be an exceptionmaxModelTokens - maxResponseTokens
valuenumTokens
andmaxResponseTokens