feat: supports OpenAI Response API and copilot's gpt-5-codex model (#2802)

* fix: upgrade vscode version

* feat: support openai response api

* refactor: refine todos tools

* fix: trim suffix empty lines
This commit is contained in:
yetone
2025-10-30 02:18:48 +08:00
committed by GitHub
parent 7e9f7b57de
commit b95e27b5a6
15 changed files with 484 additions and 169 deletions

View File

@@ -783,8 +783,8 @@ M._tools = {
require("avante.llm_tools.ls"),
require("avante.llm_tools.grep"),
require("avante.llm_tools.delete_tool_use_messages"),
require("avante.llm_tools.add_todos"),
require("avante.llm_tools.update_todo_status"),
require("avante.llm_tools.read_todos"),
require("avante.llm_tools.write_todos"),
{
name = "read_file_toplevel_symbols",
description = [[Read the top-level symbols of a file in current project scope.

View File

@@ -0,0 +1,40 @@
local Base = require("avante.llm_tools.base")
---@class AvanteLLMTool
local M = setmetatable({}, Base)
M.name = "read_todos"
M.description = "Read TODOs from the current task"
---@type AvanteLLMToolParam
M.param = {
type = "table",
fields = {},
usage = {},
}
---@type AvanteLLMToolReturn[]
M.returns = {
{
name = "todos",
description = "The TODOs from the current task",
type = "array",
},
}
M.on_render = function() return {} end
function M.func(input, opts)
local on_complete = opts.on_complete
local sidebar = require("avante").get()
if not sidebar then return false, "Avante sidebar not found" end
local todos = sidebar.chat_history.todos or {}
if on_complete then
on_complete(vim.json.encode(todos), nil)
return nil, nil
end
return todos, nil
end
return M

View File

@@ -8,6 +8,15 @@ local M = setmetatable({}, Base)
M.name = "think"
function M.enabled()
local Providers = require("avante.providers")
local Config = require("avante.config")
local provider = Providers[Config.provider]
local model = provider.model
if model and model:match("gpt%-5") then return false end
return true
end
M.description =
[[Use the tool to think about something. It will not obtain new information or make any changes to the repository, but just log the thought. Use it when complex reasoning or brainstorming is needed. For example, if you explore the repo and discover the source of a bug, call this tool to brainstorm several unique ways of fixing the bug, and assess which change(s) are likely to be simplest and most effective. Alternatively, if you receive some test results, call this tool to brainstorm ways to fix the failing tests.

View File

@@ -1,66 +0,0 @@
local Base = require("avante.llm_tools.base")
---@class AvanteLLMTool
local M = setmetatable({}, Base)
M.name = "update_todo_status"
M.description = "Update the status of TODO"
---@type AvanteLLMToolParam
M.param = {
type = "table",
fields = {
{
name = "id",
description = "The ID of the TODO to update",
type = "string",
},
{
name = "status",
description = "The status of the TODO to update",
type = "string",
choices = { "todo", "doing", "done", "cancelled" },
},
},
}
---@type AvanteLLMToolReturn[]
M.returns = {
{
name = "success",
description = "Whether the TODO was updated successfully",
type = "boolean",
},
{
name = "error",
description = "Error message if the TODOs could not be updated",
type = "string",
optional = true,
},
}
M.on_render = function() return {} end
---@type AvanteLLMToolFunc<{ id: string, status: string }>
function M.func(input, opts)
local on_complete = opts.on_complete
local sidebar = require("avante").get()
if not sidebar then return false, "Avante sidebar not found" end
local todos = sidebar.chat_history.todos
if #todos == 0 then return false, "No todos found" end
for _, todo in ipairs(todos) do
if tostring(todo.id) == tostring(input.id) then
todo.status = input.status
break
end
end
sidebar:update_todos(todos)
if on_complete then
on_complete(true, nil)
return nil, nil
end
return true, nil
end
return M

View File

@@ -3,9 +3,9 @@ local Base = require("avante.llm_tools.base")
---@class AvanteLLMTool
local M = setmetatable({}, Base)
M.name = "add_todos"
M.name = "write_todos"
M.description = "Add TODOs to the current task"
M.description = "Write TODOs to the current task"
---@type AvanteLLMToolParam
M.param = {
@@ -13,7 +13,7 @@ M.param = {
fields = {
{
name = "todos",
description = "The TODOs to add",
description = "The entire TODOs array to write",
type = "array",
items = {
name = "items",