fix: add support for tool usage for azure openai (#1922)
This commit is contained in:
@@ -19,6 +19,7 @@ setmetatable(M, { __index = O })
|
|||||||
|
|
||||||
function M:parse_curl_args(prompt_opts)
|
function M:parse_curl_args(prompt_opts)
|
||||||
local provider_conf, request_body = P.parse_config(self)
|
local provider_conf, request_body = P.parse_config(self)
|
||||||
|
local disable_tools = provider_conf.disable_tools or false
|
||||||
|
|
||||||
local headers = {
|
local headers = {
|
||||||
["Content-Type"] = "application/json",
|
["Content-Type"] = "application/json",
|
||||||
@@ -34,6 +35,14 @@ function M:parse_curl_args(prompt_opts)
|
|||||||
|
|
||||||
self.set_allowed_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
|
||||||
|
tools = {}
|
||||||
|
for _, tool in ipairs(prompt_opts.tools) do
|
||||||
|
table.insert(tools, self:transform_tool(tool))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
url = Utils.url_join(
|
url = Utils.url_join(
|
||||||
provider_conf.endpoint,
|
provider_conf.endpoint,
|
||||||
@@ -50,6 +59,7 @@ function M:parse_curl_args(prompt_opts)
|
|||||||
body = vim.tbl_deep_extend("force", {
|
body = vim.tbl_deep_extend("force", {
|
||||||
messages = self:parse_messages(prompt_opts),
|
messages = self:parse_messages(prompt_opts),
|
||||||
stream = true,
|
stream = true,
|
||||||
|
tools = tools,
|
||||||
}, request_body),
|
}, request_body),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user