Skip to content

Commit

Permalink
fix: azure o1 unsupported options (yetone#995)
Browse files Browse the repository at this point in the history
  • Loading branch information
kernitus authored Dec 24, 2024
1 parent 01e05a5 commit 0d62ffd
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lua/avante/providers/azure.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ M.api_key_name = "AZURE_OPENAI_API_KEY"

M.parse_messages = O.parse_messages
M.parse_response = O.parse_response
M.parse_response_without_stream = O.parse_response_without_stream

M.parse_curl_args = function(provider, code_opts)
local base, body_opts = P.parse_config(provider)
Expand All @@ -24,6 +25,14 @@ M.parse_curl_args = function(provider, code_opts)
}
if P.env.require_api_key(base) then headers["api-key"] = provider.parse_api_key() end

-- NOTE: When using "o1" set the supported parameters only
local stream = true
if base.model and string.find(base.model, "o1") then
body_opts.max_tokens = nil
body_opts.temperature = 1
stream = false
end

return {
url = Utils.url_join(
base.endpoint,
Expand All @@ -34,7 +43,7 @@ M.parse_curl_args = function(provider, code_opts)
headers = headers,
body = vim.tbl_deep_extend("force", {
messages = M.parse_messages(code_opts),
stream = true,
stream = stream,
}, body_opts),
}
end
Expand Down

0 comments on commit 0d62ffd

Please sign in to comment.