From 0d62ffd1cb159107a6c66e9157b0f23eaf880e28 Mon Sep 17 00:00:00 2001 From: kernitus <2789734+kernitus@users.noreply.github.com> Date: Tue, 24 Dec 2024 15:40:59 +0100 Subject: [PATCH] fix: azure o1 unsupported options (#995) --- lua/avante/providers/azure.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lua/avante/providers/azure.lua b/lua/avante/providers/azure.lua index 29e9f2111..076023872 100644 --- a/lua/avante/providers/azure.lua +++ b/lua/avante/providers/azure.lua @@ -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) @@ -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, @@ -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