decrease default number of tokens in UI #351
Merged
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.
This is a temporary fix for the Cohere assistants. Although in theory they support a 4k context window
ragna/ragna/assistants/_cohere.py
Lines 12 to 13 in 8b0b0f3
they seem to be using a very different tokenizer than what we use. When trying the assistant in the web UI with a document that actually supply 4k tokens, I get the following error message in the response
So the number of tokens actually differs by almost 40%.
In this PR I simply reduce the default number of tokens that we pull from the source storage to feed into the assistant. Setting this automatically depending on the assistant is a larger task that I'll open an issue about. Plus, the tokenizer would actually need to be dependent on the assistant as well.
Functionally, this change should make too much of a difference. Unless the user has a very complex query, by default we are still going to pull in four sources. That should be sufficient.