fix: copilot's openai tool description cannot use long text (#1700)
This commit is contained in:
@@ -2,14 +2,21 @@ local Path = require("plenary.path")
|
|||||||
local Utils = require("avante.utils")
|
local Utils = require("avante.utils")
|
||||||
local Helpers = require("avante.llm_tools.helpers")
|
local Helpers = require("avante.llm_tools.helpers")
|
||||||
local Base = require("avante.llm_tools.base")
|
local Base = require("avante.llm_tools.base")
|
||||||
|
local Config = require("avante.config")
|
||||||
|
local Providers = require("avante.providers")
|
||||||
|
|
||||||
---@class AvanteLLMTool
|
---@class AvanteLLMTool
|
||||||
local M = setmetatable({}, Base)
|
local M = setmetatable({}, Base)
|
||||||
|
|
||||||
M.name = "bash"
|
M.name = "bash"
|
||||||
|
|
||||||
M.description =
|
M.get_description = function()
|
||||||
[[Executes a given bash command in a persistent shell session with optional timeout, ensuring proper handling and security measures.
|
local provider = Providers[Config.provider]
|
||||||
|
if Config.provider:match("copilot") and provider.model and provider.model:match("gpt") then
|
||||||
|
return [[Executes a given bash command in a persistent shell session with optional timeout, ensuring proper handling and security measures.]]
|
||||||
|
end
|
||||||
|
|
||||||
|
return [[Executes a given bash command in a persistent shell session with optional timeout, ensuring proper handling and security measures.
|
||||||
|
|
||||||
Before executing the command, please follow these steps:
|
Before executing the command, please follow these steps:
|
||||||
|
|
||||||
@@ -154,6 +161,7 @@ EOF
|
|||||||
Important:
|
Important:
|
||||||
- Return an empty response - the user will see the gh output directly
|
- Return an empty response - the user will see the gh output directly
|
||||||
- Never update git config]]
|
- Never update git config]]
|
||||||
|
end
|
||||||
|
|
||||||
---@type AvanteLLMToolParam
|
---@type AvanteLLMToolParam
|
||||||
M.param = {
|
M.param = {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ function M:transform_tool(tool)
|
|||||||
local input_schema_properties, required = Utils.llm_tool_param_fields_to_json_schema(tool.param.fields)
|
local input_schema_properties, required = Utils.llm_tool_param_fields_to_json_schema(tool.param.fields)
|
||||||
return {
|
return {
|
||||||
name = tool.name,
|
name = tool.name,
|
||||||
description = tool.description,
|
description = tool.get_description and tool.get_description() or tool.description,
|
||||||
input_schema = {
|
input_schema = {
|
||||||
type = "object",
|
type = "object",
|
||||||
properties = input_schema_properties,
|
properties = input_schema_properties,
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ function M:transform_tool(tool)
|
|||||||
type = "function",
|
type = "function",
|
||||||
["function"] = {
|
["function"] = {
|
||||||
name = tool.name,
|
name = tool.name,
|
||||||
description = tool.description,
|
description = tool.get_description and tool.get_description() or tool.description,
|
||||||
parameters = parameters,
|
parameters = parameters,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -345,7 +345,8 @@ vim.g.avante_login = vim.g.avante_login
|
|||||||
---
|
---
|
||||||
---@class AvanteLLMTool
|
---@class AvanteLLMTool
|
||||||
---@field name string
|
---@field name string
|
||||||
---@field description string
|
---@field description? string
|
||||||
|
---@field get_description? fun(): string
|
||||||
---@field func? AvanteLLMToolFunc
|
---@field func? AvanteLLMToolFunc
|
||||||
---@field param AvanteLLMToolParam
|
---@field param AvanteLLMToolParam
|
||||||
---@field returns AvanteLLMToolReturn[]
|
---@field returns AvanteLLMToolReturn[]
|
||||||
@@ -360,7 +361,8 @@ vim.g.avante_login = vim.g.avante_login
|
|||||||
|
|
||||||
---@class AvanteLLMToolParamField
|
---@class AvanteLLMToolParamField
|
||||||
---@field name string
|
---@field name string
|
||||||
---@field description string
|
---@field description? string
|
||||||
|
---@field get_description? fun(): string
|
||||||
---@field type 'string' | 'integer' | 'boolean' | 'object'
|
---@field type 'string' | 'integer' | 'boolean' | 'object'
|
||||||
---@field fields? AvanteLLMToolParamField[]
|
---@field fields? AvanteLLMToolParamField[]
|
||||||
---@field optional? boolean
|
---@field optional? boolean
|
||||||
|
|||||||
@@ -1208,14 +1208,14 @@ function M.llm_tool_param_fields_to_json_schema(fields)
|
|||||||
local properties_, required_ = M.llm_tool_param_fields_to_json_schema(field.fields)
|
local properties_, required_ = M.llm_tool_param_fields_to_json_schema(field.fields)
|
||||||
properties[field.name] = {
|
properties[field.name] = {
|
||||||
type = field.type,
|
type = field.type,
|
||||||
description = field.description,
|
description = field.get_description and field.get_description() or field.description,
|
||||||
properties = properties_,
|
properties = properties_,
|
||||||
required = required_,
|
required = required_,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
properties[field.name] = {
|
properties[field.name] = {
|
||||||
type = field.type,
|
type = field.type,
|
||||||
description = field.description,
|
description = field.get_description and field.get_description() or field.description,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
if not field.optional then table.insert(required, field.name) end
|
if not field.optional then table.insert(required, field.name) end
|
||||||
|
|||||||
Reference in New Issue
Block a user