mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[PR #9082] [MERGED] FIX max_tokens not being set properly #9110
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/9082
Author: @Alex1607
Created: 1/29/2025
Status: ✅ Merged
Merged: 1/29/2025
Merged by: @tjbck
Base:
dev← Head:main📝 Commits (1)
c2e742aFix max_tokens not being set properly📊 Changes
1 file changed (+3 additions, -0 deletions)
View changed files
📝
backend/open_webui/utils/middleware.py(+3 -0)📄 Description
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.
Before submitting, make sure you've checked the following:
devbranch.Changelog Entry
Description
While using OpenWebUI a user normally wants to set the max tokens in order to control the length of the output. However, OpenWebUI has a bug since at the very least a month which resulted in this value not being set. The fix was to add it to the
apply_params_to_form_datamethode in the middleware.Fixed
max_tokenswasn't being set for any requestsAdditional Information
Please note, I wasn't able to test if parameters like
max_completion_tokenswork as intended, as I do not use the OpenAI API.If someone with access to the OpenAI API would be able to check if the
max_completion_tokensparameter is being used properly, that would be lovely. If it has the same issue, please let me know so I can add it in the method as well, or feel free to add it yourself.Also, some room for discussion with the authors / contributes:
In this method which contained the bug, why are the form data values being set manually and only ollama is using all parameters?
Can't this method be shortened to:
If that's not possible, this might happen again in the future as all new parameters have to added there one by one. So a better solution would probably be required.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.