agent-team/internal/room/tools/definitions.go

166 lines
3.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package tools
import "github.com/sashabaranov/go-openai"
var FileTools = []openai.Tool{
{
Type: openai.ToolTypeFunction,
Function: &openai.FunctionDefinition{
Name: "glob",
Description: "模式匹配查找文件,支持 * ** ? 等通配符",
Parameters: `{
"type": "object",
"properties": {
"pattern": {
"type": "string",
"description": "glob 模式,如 **/*.go, *.ts"
}
},
"required": ["pattern"]
}`,
},
},
{
Type: openai.ToolTypeFunction,
Function: &openai.FunctionDefinition{
Name: "grep",
Description: "在文件中搜索内容,支持正则表达式",
Parameters: `{
"type": "object",
"properties": {
"pattern": {
"type": "string",
"description": "正则表达式搜索模式"
},
"path": {
"type": "string",
"description": "搜索目录路径"
},
"include": {
"type": "string",
"description": "文件过滤,如 *.go, *.ts"
}
},
"required": ["pattern"]
}`,
},
},
{
Type: openai.ToolTypeFunction,
Function: &openai.FunctionDefinition{
Name: "read_file",
Description: "读取文件内容,支持大文件分段读取",
Parameters: `{
"type": "object",
"properties": {
"filename": {
"type": "string",
"description": "文件名(相对于 workspace"
},
"offset": {
"type": "integer",
"description": "起始行号(从 0 开始)"
},
"limit": {
"type": "integer",
"description": "读取行数,默认 100"
}
},
"required": ["filename"]
}`,
},
},
{
Type: openai.ToolTypeFunction,
Function: &openai.FunctionDefinition{
Name: "edit_file",
Description: "编辑文件内容,使用字符串替换",
Parameters: `{
"type": "object",
"properties": {
"filename": {
"type": "string",
"description": "文件名(相对于 workspace"
},
"old_string": {
"type": "string",
"description": "要替换的原始内容"
},
"new_string": {
"type": "string",
"description": "替换后的新内容"
}
},
"required": ["filename", "old_string", "new_string"]
}`,
},
},
{
Type: openai.ToolTypeFunction,
Function: &openai.FunctionDefinition{
Name: "write_file",
Description: "写入或创建文件",
Parameters: `{
"type": "object",
"properties": {
"filename": {
"type": "string",
"description": "文件名(相对于 workspace"
},
"content": {
"type": "string",
"description": "文件内容"
}
},
"required": ["filename", "content"]
}`,
},
},
{
Type: openai.ToolTypeFunction,
Function: &openai.FunctionDefinition{
Name: "list_workspace",
Description: "列出工作区的所有文件",
Parameters: `{
"type": "object",
"properties": {}
}`,
},
},
{
Type: openai.ToolTypeFunction,
Function: &openai.FunctionDefinition{
Name: "git_status",
Description: "查看 Git 工作区状态",
Parameters: `{"type": "object", "properties": {}}`,
},
},
{
Type: openai.ToolTypeFunction,
Function: &openai.FunctionDefinition{
Name: "git_diff",
Description: "查看文件变更",
Parameters: `{
"type": "object",
"properties": {
"filename": {"type": "string", "description": "文件名"}
}
}`,
},
},
{
Type: openai.ToolTypeFunction,
Function: &openai.FunctionDefinition{
Name: "git_commit",
Description: "提交更改",
Parameters: `{
"type": "object",
"properties": {
"message": {"type": "string", "description": "提交信息"}
},
"required": ["message"]
}`,
},
},
}