fix: do not allow max_tokens & max_completion_tokens at the same time (#1633)

* fix: do not allow max_tokens & max_completion_tokens at the same time

* chore: fix formatting
This commit is contained in:
kernitus
2025-03-18 17:44:41 +00:00
committed by GitHub
parent 191d7b8783
commit 7d137d32cb
2 changed files with 5 additions and 6 deletions

View File

@@ -32,8 +32,7 @@ function M:parse_curl_args(prompt_opts)
end
end
-- NOTE: When using reasoning models set supported parameters
self.set_reasoning_params(provider_conf, request_body)
self.set_allowed_params(provider_conf, request_body)
return {
url = Utils.url_join(

View File

@@ -69,13 +69,14 @@ end
function M.is_reasoning_model(model) return model and string.match(model, "^o%d+") ~= nil end
function M.set_reasoning_params(provider_conf, request_body)
function M.set_allowed_params(provider_conf, request_body)
if M.is_reasoning_model(provider_conf.model) then
request_body.temperature = 1
request_body.reasoning_effort = request_body.reasoning_effort
else
request_body.reasoning_effort = nil
end
-- If max_tokens is set in config, unset max_completion_tokens
if request_body.max_tokens then request_body.max_completion_tokens = nil end
end
function M:parse_messages(opts)
@@ -305,8 +306,7 @@ function M:parse_curl_args(prompt_opts)
request_body.include_reasoning = true
end
-- NOTE: When using reasoning models set supported parameters
self.set_reasoning_params(provider_conf, request_body)
self.set_allowed_params(provider_conf, request_body)
local tools = nil
if not disable_tools and prompt_opts.tools then