fix: stricter static typing (#1550)
This commit is contained in:
@@ -27,21 +27,25 @@ function M.transform_tool(tool)
|
|||||||
}
|
}
|
||||||
if not field.optional then table.insert(required, field.name) end
|
if not field.optional then table.insert(required, field.name) end
|
||||||
end
|
end
|
||||||
local res = {
|
---@type AvanteOpenAIToolFunctionParameters
|
||||||
type = "function",
|
local parameters = nil
|
||||||
["function"] = {
|
if not vim.tbl_isempty(input_schema_properties) then
|
||||||
name = tool.name,
|
parameters = {
|
||||||
description = tool.description,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
if vim.tbl_count(input_schema_properties) > 0 then
|
|
||||||
res["function"].parameters = {
|
|
||||||
type = "object",
|
type = "object",
|
||||||
properties = input_schema_properties,
|
properties = input_schema_properties,
|
||||||
required = required,
|
required = required,
|
||||||
additionalProperties = false,
|
additionalProperties = false,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
---@type AvanteOpenAITool
|
||||||
|
local res = {
|
||||||
|
type = "function",
|
||||||
|
["function"] = {
|
||||||
|
name = tool.name,
|
||||||
|
description = tool.description,
|
||||||
|
parameters = parameters,
|
||||||
|
},
|
||||||
|
}
|
||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -171,12 +171,12 @@ vim.g.avante_login = vim.g.avante_login
|
|||||||
---
|
---
|
||||||
---@class AvanteOpenAIToolFunction
|
---@class AvanteOpenAIToolFunction
|
||||||
---@field name string
|
---@field name string
|
||||||
---@field description string
|
---@field description string | nil
|
||||||
---@field parameters AvanteOpenAIToolFunctionParameters
|
---@field parameters AvanteOpenAIToolFunctionParameters | nil
|
||||||
---@field strict boolean
|
---@field strict boolean | nil
|
||||||
---
|
---
|
||||||
---@class AvanteOpenAIToolFunctionParameters
|
---@class AvanteOpenAIToolFunctionParameters
|
||||||
---@field type string
|
---@field type "object"
|
||||||
---@field properties table<string, AvanteOpenAIToolFunctionParameterProperty>
|
---@field properties table<string, AvanteOpenAIToolFunctionParameterProperty>
|
||||||
---@field required string[]
|
---@field required string[]
|
||||||
---@field additionalProperties boolean
|
---@field additionalProperties boolean
|
||||||
|
|||||||
Reference in New Issue
Block a user