tools

package
v0.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2026 License: MIT Imports: 20 Imported by: 0

README

AGGO工具系统

AGGO工具系统是一个基于Eino框架的智能代理工具集合,为AI代理提供知识管理、系统操作和推理分析等功能。所有工具都实现了Eino框架的标准接口,支持动态调用和参数验证。

🚀 核心特性

  • 统一接口: 基于Eino框架的tool.InvokableTool接口
  • 自动推断: 使用utils.InferTool进行工具信息自动推断
  • 参数验证: 基于JSON Schema的参数验证机制
  • 结构化输出: 统一的JSON格式返回结果
  • 错误处理: 完善的错误处理和异常捕获

📦 工具目录

知识管理工具 (knowledge_tool.go)

提供完整的文档知识库管理功能,支持多种文档来源和操作。

可用工具
工具名称 描述 主要功能
load_documents 文档加载工具 支持文本文件、URL、目录、内存文档的加载
search_documents 文档搜索工具 基于向量相似度的文档搜索
get_document 获取文档工具 根据ID获取单个文档详情
update_document 更新文档工具 更新文档内容和元数据
delete_document 删除文档工具 删除指定文档
list_documents 列出文档工具 分页列出文档信息
使用示例
// 获取知识管理工具
knowledgeTools := tools.GetKnowledgeTools(knowledgeManager)

// 加载目录中的文档
loadParams := tools.LoadDocumentsParams{
SourceType:    "directory",
DirectoryPath: "/path/to/docs",
Extensions:    []string{".txt", ".md"},
Recursive:     true,
LoadOptions: tools.LoadOptionsInput{
EnableChunking: true,
ChunkSize:      1000,
ChunkOverlap:   200,
},
}

// 搜索文档
searchParams := tools.SearchParams{
Query:     "机器学习算法",
Limit:     10,
Threshold: 0.75,
}
知识推理工具 (knowledge_reasoning_tools.go)

提供知识推理和分析功能,支持思考链式推理过程。

可用工具
工具名称 描述 主要功能
knowledge_think 知识思考工具 内部推理和策略规划(对用户不可见)
knowledge_search 知识搜索工具 执行知识库搜索操作
knowledge_analysis 知识分析工具 分析搜索结果的质量和相关性
推理工作流程
  1. 思考阶段: 使用knowledge_think进行问题分析和搜索策略制定
  2. 搜索阶段: 使用knowledge_search执行多轮搜索获取信息
  3. 分析阶段: 使用knowledge_analysis评估结果质量和完整性
使用示例
// 获取知识推理工具
reasoningTools := tools.GetKnowledgeReasoningTools(knowledgeManager)

// 思考策略(内部使用)
thinkParams := tools.ThinkParams{
Thought: "需要分析机器学习算法的优缺点,应该搜索相关技术文档",
}

// 执行搜索
searchParams := tools.KnowledgeSearchParams{
Query: "机器学习算法比较",
Limit: 10,
}

// 分析结果
analysisParams := tools.AnalysisParams{
Analysis: "搜索结果包含了深度学习和传统机器学习的对比信息,质量较高",
}
数据库工具
MySQL工具 (mysql_tool.go)

提供MySQL数据库操作功能,支持查询、更新、数据分析等。

工具名称 描述 主要功能
mysql_query MySQL查询工具 执行SELECT查询操作
mysql_execute MySQL执行工具 执行INSERT、UPDATE、DELETE等操作
mysql_schema MySQL架构工具 获取数据库结构信息
mysql_analyze MySQL分析工具 数据分析和统计
PostgreSQL工具 (postgres_tool.go)

提供PostgreSQL数据库操作功能,支持查询、更新、数据分析等。

工具名称 描述 主要功能
postgres_query PostgreSQL查询工具 执行SELECT查询操作
postgres_execute PostgreSQL执行工具 执行INSERT、UPDATE、DELETE等操作
postgres_schema PostgreSQL架构工具 获取数据库结构信息
postgres_analyze PostgreSQL分析工具 数据分析和统计
系统工具 (shell_tool.go)

提供系统级操作功能,支持命令执行、系统信息获取等。

可用工具
工具名称 描述 主要功能
shell_execute 命令执行工具 执行系统命令,支持超时和错误处理
shell_system_info 系统信息工具 获取OS、环境变量、内存等系统信息
shell_list_processes 进程管理工具 列出系统运行中的进程
shell_directory 目录操作工具 获取和切换工作目录
使用示例
// 获取数据库工具
mysqlTools := tools.GetMySQLTools(mysqlConfig)
postgresTools := tools.GetPostgreSQLTools(postgresConfig)

// 获取系统工具
shellTools := tools.GetSellTool()

// 执行命令
executeParams := tools.ExecuteParams{
Command:    "ls",
Args:       []string{"-la"},
WorkingDir: "/tmp",
Timeout:    30,
Shell:      false,
}

// 获取系统信息
systemParams := tools.SystemInfoParams{
InfoType: "memory", // os, env, path, user, disk, memory
}

// 目录操作
dirParams := tools.DirectoryParams{
Operation: "change", // get, change
Path:      "/new/working/directory",
}

🛠️ 工具开发指南

基础架构

所有工具都基于以下接口:

// 基础接口
type tool.BaseTool interface {
Info(ctx context.Context) (*schema.ToolInfo, error)
}

// 可调用接口
type tool.InvokableTool interface {
tool.BaseTool
InvokableRun(ctx context.Context, argumentsInJSON string, opts ...tool.Option) (string, error)
}
开发新工具
1. 定义工具结构体
type MyTool struct {
// 工具依赖
manager *SomeManager
}

// 参数结构体
type MyParams struct {
Param1 string `json:"param1" jsonschema:"description=参数描述,required"`
Param2 int    `json:"param2,omitempty" jsonschema:"description=可选参数,默认值为10"`
}
2. 实现构造函数
func NewMyTool(manager *SomeManager) tool.InvokableTool {
this := &MyTool{manager: manager}
name := "my_tool"
desc := "工具功能描述"
t, _ := utils.InferTool(name, desc, this.execute)
return t
}
3. 实现业务逻辑
func (t *MyTool) execute(ctx context.Context, params MyParams) (interface{}, error) {
// 参数验证
if params.Param1 == "" {
return nil, fmt.Errorf("param1 is required")
}

// 业务逻辑实现
result := map[string]interface{}{
"operation": "my_operation",
"success":   true,
"result":    "执行结果",
"timestamp": time.Now().Unix(),
}

return result, nil
}
JSON Schema标签规范
type ExampleParams struct {
// 必需参数
Required string `json:"required" jsonschema:"description=必需参数描述,required"`

// 可选参数(带默认值说明)
Optional string `json:"optional,omitempty" jsonschema:"description=可选参数描述,默认值为xxx"`

// 枚举参数
Enum string `json:"enum" jsonschema:"description=枚举参数,required,enum=value1,enum=value2,enum=value3"`

// 数值范围
Number int `json:"number" jsonschema:"description=数值参数,minimum=1,maximum=100"`

// 数组参数
Array []string `json:"array,omitempty" jsonschema:"description=数组参数"`
}

🔧 工具集成

在代理中使用工具
import "github.com/CoolBanHub/aggo/tools"

func createAgent(knowledgeManager *knowledge.KnowledgeManager) *agent.Agent {
// 获取各类工具
knowledgeTools := tools.GetKnowledgeTools(knowledgeManager)
reasoningTools := tools.GetKnowledgeReasoningTools(knowledgeManager)
mysqlTools := tools.GetMySQLTools(mysqlConfig) // 新增
postgresTools := tools.GetPostgreSQLTools(postgresConfig) // 新增
shellTools := tools.GetSellTool()

// 合并所有工具
allTools := append(knowledgeTools, reasoningTools...)
allTools = append(allTools, mysqlTools...) // 新增
allTools = append(allTools, postgresTools...) // 新增
allTools = append(allTools, shellTools...)

// 创建代理
return agent.NewAgent(ctx, chatModel,
agent.WithTools(allTools),
// 其他配置...
)
}
工具调用示例
// 工具调用
toolResult, err := tool.InvokableRun(ctx, `{
    "query": "机器学习",
    "limit": 5,
    "threshold": 0.8
}`)

📊 返回结果格式

所有工具都遵循统一的结果格式:

{
  "operation": "操作类型",
  "success": true,
  "result": "具体结果数据",
  "error": "错误信息(仅在失败时)",
  "timestamp": 1645123456,
  "duration": "执行时长(某些工具)"
}

⚡ 性能优化

  • 输出截断: 长输出自动截断防止token溢出
  • 超时控制: 命令执行支持超时设置
  • 错误处理: 完善的错误捕获和处理机制
  • 资源管理: 自动清理临时资源

🔒 安全考虑

  • 命令验证: 系统命令执行前进行安全检查
  • 路径验证: 文件路径操作防止目录遍历攻击
  • 权限控制: 根据执行环境限制工具权限
  • 输入清理: 防止命令注入攻击

🧪 测试

每个工具都应包含相应的测试:

func TestMyTool(t *testing.T) {
tool := NewMyTool(manager)

// 测试工具信息
info, err := tool.Info(context.Background())
require.NoError(t, err)
assert.Equal(t, "my_tool", info.Name)

// 测试工具执行
params := MyParams{Param1: "test"}
result, err := tool.execute(context.Background(), params)
require.NoError(t, err)
assert.True(t, result.Success)
}

📝 最佳实践

  1. 命名规范: 工具名使用下划线分隔,描述清晰准确
  2. 参数设计: 提供合理的默认值,必需参数明确标注
  3. 错误处理: 返回有意义的错误信息,避免暴露敏感信息
  4. 文档完善: JSON Schema描述详细,便于理解使用
  5. 性能考虑: 对耗时操作设置超时,大数据量结果进行分页
  6. 版本兼容: 新增功能保持向后兼容性

通过遵循以上指南,可以为AGGO框架开发出功能强大、安全可靠的智能代理工具。

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCalculatorTool

func GetCalculatorTool() []tool.BaseTool

GetCalculatorTool 获取计算器工具

func GetExecuteTool

func GetExecuteTool() []tool.BaseTool

func GetKnowledgeReasoningTools

func GetKnowledgeReasoningTools(retriever retriever.Retriever, retrieverOptions []retriever.Option) []tool.BaseTool

GetKnowledgeReasoningTools 获取知识推理工具集合

func GetKnowledgeTools

func GetKnowledgeTools(indexer indexer.Indexer, retriever retriever.Retriever, retrieverOptions *retriever.Options) []tool.BaseTool

func GetMySQLTools

func GetMySQLTools(db *gorm.DB) []tool.BaseTool

GetMySQLTools 获取MySQL工具列表

func GetPostgresTools

func GetPostgresTools(db *gorm.DB) []tool.BaseTool

GetPostgresTools 获取PostgreSQL工具列表

func GetSellTool

func GetSellTool() []tool.BaseTool

func GetSysInfoTool

func GetSysInfoTool() []tool.BaseTool

func GetTimeTool

func GetTimeTool() []tool.BaseTool

GetTimeTool 获取时间工具

func GetWeatherTool

func GetWeatherTool() []tool.BaseTool

GetWeatherTool 获取天气查询工具

func NewAlterTableTool

func NewAlterTableTool(db *gorm.DB) tool.InvokableTool

NewAlterTableTool 创建修改表工具实例

func NewCountQueryTool

func NewCountQueryTool(db *gorm.DB) tool.InvokableTool

NewCountQueryTool 创建计数查询工具实例

func NewCreateTableTool

func NewCreateTableTool(db *gorm.DB) tool.InvokableTool

NewCreateTableTool 创建表工具实例

func NewDeleteQueryTool

func NewDeleteQueryTool(db *gorm.DB) tool.InvokableTool

NewDeleteQueryTool 创建删除数据工具实例

func NewDescribeTableTool

func NewDescribeTableTool(db *gorm.DB) tool.InvokableTool

NewDescribeTableTool 创建描述表工具实例

func NewKnowledgeAnalysisTool

func NewKnowledgeAnalysisTool() tool.InvokableTool

NewKnowledgeAnalysisTool 创建知识分析工具实例

func NewKnowledgeSearchTool

func NewKnowledgeSearchTool(retriever retriever.Retriever, retrieverOptions []retriever.Option) tool.InvokableTool

NewKnowledgeSearchTool 创建知识搜索工具实例

func NewKnowledgeThinkTool

func NewKnowledgeThinkTool() tool.InvokableTool

NewKnowledgeThinkTool 创建知识思考工具实例

func NewListDatabasesTool

func NewListDatabasesTool(db *gorm.DB) tool.InvokableTool

NewListDatabasesTool 创建列出数据库工具实例

func NewListTablesTool

func NewListTablesTool(db *gorm.DB) tool.InvokableTool

NewListTablesTool 创建列出表工具实例

func NewLoadDocumentsTool

func NewLoadDocumentsTool(indexer indexer.Indexer) tool.InvokableTool

NewLoadDocumentsTool 创建文档加载工具实例

func NewMySQLAlterTableTool

func NewMySQLAlterTableTool(db *gorm.DB) tool.InvokableTool

NewMySQLAlterTableTool 创建修改表工具实例

func NewMySQLCountQueryTool

func NewMySQLCountQueryTool(db *gorm.DB) tool.InvokableTool

NewMySQLCountQueryTool 创建计数查询工具实例

func NewMySQLCreateIndexTool

func NewMySQLCreateIndexTool(db *gorm.DB) tool.InvokableTool

NewMySQLCreateIndexTool 创建索引工具实例

func NewMySQLCreateTableTool

func NewMySQLCreateTableTool(db *gorm.DB) tool.InvokableTool

NewMySQLCreateTableTool 创建表工具实例

func NewMySQLDeleteQueryTool

func NewMySQLDeleteQueryTool(db *gorm.DB) tool.InvokableTool

NewMySQLDeleteQueryTool 创建删除数据工具实例

func NewMySQLDescribeTableTool

func NewMySQLDescribeTableTool(db *gorm.DB) tool.InvokableTool

NewMySQLDescribeTableTool 创建描述表工具实例

func NewMySQLListDatabasesTool

func NewMySQLListDatabasesTool(db *gorm.DB) tool.InvokableTool

NewMySQLListDatabasesTool 创建列出数据库工具实例

func NewMySQLListTablesTool

func NewMySQLListTablesTool(db *gorm.DB) tool.InvokableTool

NewMySQLListTablesTool 创建列出表工具实例

func NewMySQLReadQueryTool

func NewMySQLReadQueryTool(db *gorm.DB) tool.InvokableTool

NewMySQLReadQueryTool 创建查询数据工具实例

func NewMySQLShowIndexesTool

func NewMySQLShowIndexesTool(db *gorm.DB) tool.InvokableTool

NewMySQLShowIndexesTool 创建显示索引工具实例

func NewMySQLUpdateQueryTool

func NewMySQLUpdateQueryTool(db *gorm.DB) tool.InvokableTool

NewMySQLUpdateQueryTool 创建更新数据工具实例

func NewMySQLWriteQueryTool

func NewMySQLWriteQueryTool(db *gorm.DB) tool.InvokableTool

NewMySQLWriteQueryTool 创建写入数据工具实例

func NewReadQueryTool

func NewReadQueryTool(db *gorm.DB) tool.InvokableTool

NewReadQueryTool 创建查询数据工具实例

func NewSearchDocumentsTool

func NewSearchDocumentsTool(retriever retriever.Retriever, options *retriever.Options) tool.InvokableTool

NewSearchDocumentsTool 创建文档搜索工具实例

func NewUpdateQueryTool

func NewUpdateQueryTool(db *gorm.DB) tool.InvokableTool

NewUpdateQueryTool 创建更新数据工具实例

func NewWriteQueryTool

func NewWriteQueryTool(db *gorm.DB) tool.InvokableTool

NewWriteQueryTool 创建写入数据工具实例

Types

type AlterTableParams

type AlterTableParams struct {
	TableName string `json:"tableName" jsonschema:"description=表名,required"`
	SQL       string `json:"sql" jsonschema:"description=修改表的SQL语句,required"`
}

AlterTableParams 修改表参数

type AlterTableTool

type AlterTableTool struct {
	// contains filtered or unexported fields
}

AlterTableTool 修改表工具

type AnalysisParams

type AnalysisParams struct {
	Analysis string `json:"analysis" jsonschema:"description=对搜索结果的分析和评估,required"`
}

AnalysisParams 分析参数

type AnalysisResult

type AnalysisResult struct {
	Analysis    string   `json:"analysis"`
	AnalysisLog []string `json:"analysisLog"`
	Success     bool     `json:"success"`
	Error       string   `json:"error,omitempty"`
	Operation   string   `json:"operation"`
	Timestamp   int64    `json:"timestamp"`
}

AnalysisResult 分析结果

type CalculatorParams

type CalculatorParams struct {
	Operation string  `` /* 180-byte string literal not displayed */
	A         float64 `json:"a" jsonschema:"description=第一个数字,required"`
	B         float64 `json:"b" jsonschema:"description=第二个数字,required"`
}

场景1:数学计算工具

type CountQueryParams

type CountQueryParams struct {
	TableName string                 `json:"tableName" jsonschema:"description=表名,required"`
	Where     map[string]interface{} `json:"where,omitempty" jsonschema:"description=计数条件"`
}

CountQueryParams 计数参数

type CountQueryTool

type CountQueryTool struct {
	// contains filtered or unexported fields
}

CountQueryTool 计数查询工具

type CreateTableParams

type CreateTableParams struct {
	TableName string `json:"tableName" jsonschema:"description=表名,required"`
	SQL       string `json:"sql" jsonschema:"description=创建表的SQL语句,required"`
	IfExists  bool   `json:"ifExists,omitempty" jsonschema:"description=如果表存在是否跳过,默认false"`
}

CreateTableParams 创建表参数

type CreateTableTool

type CreateTableTool struct {
	// contains filtered or unexported fields
}

CreateTableTool 创建表工具

type DeleteQueryParams

type DeleteQueryParams struct {
	TableName string                 `json:"tableName" jsonschema:"description=表名,required"`
	Where     map[string]interface{} `json:"where" jsonschema:"description=删除条件,required"`
}

DeleteQueryParams 删除参数

type DeleteQueryTool

type DeleteQueryTool struct {
	// contains filtered or unexported fields
}

DeleteQueryTool 删除数据工具

type DescribeTableParams

type DescribeTableParams struct {
	TableName string `json:"tableName" jsonschema:"description=表名,required"`
}

DescribeTableParams 描述表参数

type DescribeTableTool

type DescribeTableTool struct {
	// contains filtered or unexported fields
}

DescribeTableTool 描述表结构工具

type DirectoryParams

type DirectoryParams struct {
	Operation string `` /* 134-byte string literal not displayed */
	Path      string `json:"path,omitempty" jsonschema:"description=要切换到的目录路径(当operation为change时必需)"`
}

DirectoryParams 表示目录操作的参数

type ExecuteParams

type ExecuteParams struct {
	Command    string   `json:"command" jsonschema:"description=要执行的命令,required"`
	Args       []string `json:"args,omitempty" jsonschema:"description=命令参数"`
	WorkingDir string   `json:"workingDir,omitempty" jsonschema:"description=命令执行的工作目录"`
	Timeout    int      `json:"timeout,omitempty" jsonschema:"description=超时时间(秒),默认为30秒"`
	Shell      bool     `json:"shell,omitempty" jsonschema:"description=是否在shell环境中执行,默认为false"`
}

ExecuteParams 表示命令执行的参数

type KnowledgeAnalysisTool

type KnowledgeAnalysisTool struct {
}

KnowledgeAnalysisTool 知识分析工具 提供搜索结果分析功能

type KnowledgeSearchParams

type KnowledgeSearchParams struct {
	Query string `json:"query" jsonschema:"description=搜索查询内容,required"`
	Limit int    `json:"limit,omitempty" jsonschema:"description=搜索结果数量限制,默认为10"`
}

KnowledgeSearchParams 知识搜索参数

type KnowledgeSearchResult

type KnowledgeSearchResult struct {
	Query         string             `json:"query"`
	Documents     []*schema.Document `json:"documents"`
	DocumentCount int                `json:"documentCount"`
	Success       bool               `json:"success"`
	Error         string             `json:"error,omitempty"`
	Operation     string             `json:"operation"`
	Timestamp     int64              `json:"timestamp"`
}

KnowledgeSearchResult 知识搜索结果

type KnowledgeSearchTool

type KnowledgeSearchTool struct {
	// contains filtered or unexported fields
}

KnowledgeSearchTool 知识搜索工具 提供知识库搜索功能

type KnowledgeThinkTool

type KnowledgeThinkTool struct {
}

KnowledgeThinkTool 知识推理思考工具 提供思考和推理功能,用于知识探索策略规划

type ListDatabasesParams

type ListDatabasesParams struct{}

ListDatabasesParams 列出数据库参数

type ListDatabasesTool

type ListDatabasesTool struct {
	// contains filtered or unexported fields
}

ListDatabasesTool 列出数据库工具

type ListTablesParams

type ListTablesParams struct {
	Database string `json:"database,omitempty" jsonschema:"description=数据库名称,不指定时使用当前数据库"`
}

ListTablesParams 列出表参数

type ListTablesTool

type ListTablesTool struct {
	// contains filtered or unexported fields
}

ListTablesTool 列出表工具

type LoadDocumentSourceType

type LoadDocumentSourceType string
const (
	LoadDocumentSourceTypeFile LoadDocumentSourceType = "file"
	LoadDocumentSourceTypeUrl  LoadDocumentSourceType = "url"
)

func (LoadDocumentSourceType) String

func (l LoadDocumentSourceType) String() string

type LoadDocumentsParams

type LoadDocumentsParams struct {
	// 文档来源类型:file, url
	SourceType LoadDocumentSourceType `json:"sourceType" jsonschema:"description=文档来源类型,required,enum=file,enum=url"`

	Uri string `json:"uri"`
}

LoadDocumentsParams 加载文档的参数

type LoadDocumentsTool

type LoadDocumentsTool struct {
	// contains filtered or unexported fields
}

LoadDocumentsTool 文档加载工具 提供将文档加载到知识库的功能

type MySQLAlterTableParams

type MySQLAlterTableParams struct {
	TableName string `json:"tableName" jsonschema:"description=表名,required"`
	SQL       string `json:"sql" jsonschema:"description=修改表的SQL语句,required"`
}

MySQLAlterTableParams 修改表参数

type MySQLAlterTableTool

type MySQLAlterTableTool struct {
	// contains filtered or unexported fields
}

MySQLAlterTableTool 修改表工具

type MySQLCountQueryParams

type MySQLCountQueryParams struct {
	TableName string                 `json:"tableName" jsonschema:"description=表名,required"`
	Where     map[string]interface{} `json:"where,omitempty" jsonschema:"description=计数条件"`
}

MySQLCountQueryParams 计数参数

type MySQLCountQueryTool

type MySQLCountQueryTool struct {
	// contains filtered or unexported fields
}

MySQLCountQueryTool 计数查询工具

type MySQLCreateIndexParams

type MySQLCreateIndexParams struct {
	TableName string   `json:"tableName" jsonschema:"description=表名,required"`
	IndexName string   `json:"indexName" jsonschema:"description=索引名称,required"`
	Columns   []string `json:"columns" jsonschema:"description=索引列名列表,required"`
	IndexType string   `json:"indexType,omitempty" jsonschema:"description=索引类型:BTREE, HASH, FULLTEXT, SPATIAL"`
	Unique    bool     `json:"unique,omitempty" jsonschema:"description=是否为唯一索引"`
}

MySQLCreateIndexParams 创建索引参数

type MySQLCreateIndexTool

type MySQLCreateIndexTool struct {
	// contains filtered or unexported fields
}

MySQLCreateIndexTool 创建索引工具

type MySQLCreateTableParams

type MySQLCreateTableParams struct {
	TableName string `json:"tableName" jsonschema:"description=表名,required"`
	SQL       string `json:"sql" jsonschema:"description=创建表的SQL语句,required"`
	IfExists  bool   `json:"ifExists,omitempty" jsonschema:"description=如果表存在是否跳过,默认false"`
	Engine    string `json:"engine,omitempty" jsonschema:"description=存储引擎,默认InnoDB"`
	Charset   string `json:"charset,omitempty" jsonschema:"description=字符集,默认utf8mb4"`
	Collate   string `json:"collate,omitempty" jsonschema:"description=排序规则,默认utf8mb4_unicode_ci"`
}

MySQLCreateTableParams 创建表参数

type MySQLCreateTableTool

type MySQLCreateTableTool struct {
	// contains filtered or unexported fields
}

MySQLCreateTableTool 创建表工具

type MySQLDeleteQueryParams

type MySQLDeleteQueryParams struct {
	TableName string                 `json:"tableName" jsonschema:"description=表名,required"`
	Where     map[string]interface{} `json:"where" jsonschema:"description=删除条件,required"`
}

MySQLDeleteQueryParams 删除参数

type MySQLDeleteQueryTool

type MySQLDeleteQueryTool struct {
	// contains filtered or unexported fields
}

MySQLDeleteQueryTool 删除数据工具

type MySQLDescribeTableParams

type MySQLDescribeTableParams struct {
	TableName string `json:"tableName" jsonschema:"description=表名,required"`
}

MySQLDescribeTableParams 描述表参数

type MySQLDescribeTableTool

type MySQLDescribeTableTool struct {
	// contains filtered or unexported fields
}

MySQLDescribeTableTool 描述表结构工具

type MySQLListDatabasesParams

type MySQLListDatabasesParams struct{}

MySQLListDatabasesParams 列出数据库参数

type MySQLListDatabasesTool

type MySQLListDatabasesTool struct {
	// contains filtered or unexported fields
}

MySQLListDatabasesTool 列出数据库工具

type MySQLListTablesParams

type MySQLListTablesParams struct {
	Database string `json:"database,omitempty" jsonschema:"description=数据库名称,不指定时使用当前数据库"`
}

MySQLListTablesParams 列出表参数

type MySQLListTablesTool

type MySQLListTablesTool struct {
	// contains filtered or unexported fields
}

MySQLListTablesTool 列出表工具

type MySQLReadQueryParams

type MySQLReadQueryParams struct {
	Query  string        `json:"query" jsonschema:"description=SQL查询语句,required"`
	Params []interface{} `json:"params,omitempty" jsonschema:"description=查询参数"`
	Limit  int           `json:"limit,omitempty" jsonschema:"description=结果限制数量,默认100"`
}

MySQLReadQueryParams 查询参数

type MySQLReadQueryTool

type MySQLReadQueryTool struct {
	// contains filtered or unexported fields
}

MySQLReadQueryTool 查询数据工具

type MySQLShowIndexesParams

type MySQLShowIndexesParams struct {
	TableName string `json:"tableName" jsonschema:"description=表名,required"`
}

MySQLShowIndexesParams 显示索引参数

type MySQLShowIndexesTool

type MySQLShowIndexesTool struct {
	// contains filtered or unexported fields
}

MySQLShowIndexesTool 显示索引工具

type MySQLUpdateQueryParams

type MySQLUpdateQueryParams struct {
	TableName string                 `json:"tableName" jsonschema:"description=表名,required"`
	Where     map[string]interface{} `json:"where" jsonschema:"description=更新条件,required"`
	Data      map[string]interface{} `json:"data" jsonschema:"description=要更新的数据,required"`
}

MySQLUpdateQueryParams 更新参数

type MySQLUpdateQueryTool

type MySQLUpdateQueryTool struct {
	// contains filtered or unexported fields
}

MySQLUpdateQueryTool 更新数据工具

type MySQLWriteQueryParams

type MySQLWriteQueryParams struct {
	TableName   string                   `json:"tableName" jsonschema:"description=表名,required"`
	Data        []map[string]interface{} `json:"data" jsonschema:"description=要插入的数据,required"`
	OnDuplicate string                   `json:"onDuplicate,omitempty" jsonschema:"description=重复键处理方式:ignore, update, replace"`
}

MySQLWriteQueryParams 写入参数

type MySQLWriteQueryTool

type MySQLWriteQueryTool struct {
	// contains filtered or unexported fields
}

MySQLWriteQueryTool 写入数据工具

type ReadQueryParams

type ReadQueryParams struct {
	Query  string        `json:"query" jsonschema:"description=SQL查询语句,required"`
	Params []interface{} `json:"params,omitempty" jsonschema:"description=查询参数"`
	Limit  int           `json:"limit,omitempty" jsonschema:"description=结果限制数量,默认100"`
}

ReadQueryParams 查询参数

type ReadQueryTool

type ReadQueryTool struct {
	// contains filtered or unexported fields
}

ReadQueryTool 查询数据工具

type SearchDocumentsTool

type SearchDocumentsTool struct {
	// contains filtered or unexported fields
}

SearchDocumentsTool 文档搜索工具 提供在知识库中搜索文档的功能

type SearchParams

type SearchParams struct {
	Query string `json:"query" jsonschema:"description=搜索查询,required"`
}

SearchParams 搜索参数

type ShellResult

type ShellResult struct {
	Command    string `json:"command"`         // 执行的命令
	ExitCode   int    `json:"exitCode"`        // 退出码
	Stdout     string `json:"stdout"`          // 标准输出
	Stderr     string `json:"stderr"`          // 标准错误输出
	Success    bool   `json:"success"`         // 是否执行成功
	Error      string `json:"error,omitempty"` // 错误信息
	Duration   string `json:"duration"`        // 执行时长
	WorkingDir string `json:"workingDir"`      // 工作目录
	Operation  string `json:"operation"`       // 操作类型
}

ShellResult 表示命令执行的结果

type ShellTool

type ShellTool struct{}

func (*ShellTool) ChangeDirectory

func (t *ShellTool) ChangeDirectory(path string) (interface{}, error)

ChangeDirectory 切换当前工作目录

func (*ShellTool) GetCurrentDirectory

func (t *ShellTool) GetCurrentDirectory() (interface{}, error)

GetCurrentDirectory 获取当前工作目录

type SystemInfoParams

type SystemInfoParams struct {
	InfoType string `` /* 167-byte string literal not displayed */
}

SystemInfoParams 表示系统信息查询的参数

type ThinkParams

type ThinkParams struct {
	Thought string `json:"thought" jsonschema:"description=思考内容和推理过程,required"`
}

ThinkParams 思考参数

type ThinkResult

type ThinkResult struct {
	Thought     string   `json:"thought"`
	ThoughtsLog []string `json:"thoughtsLog"`
	Success     bool     `json:"success"`
	Error       string   `json:"error,omitempty"`
	Operation   string   `json:"operation"`
	Timestamp   int64    `json:"timestamp"`
}

ThinkResult 思考结果

type TimeParams

type TimeParams struct {
	Operation string `` /* 165-byte string literal not displayed */
	Format    string `json:"format,omitempty" jsonschema:"description=时间格式,如 2006-01-02 15:04:05"`
	Time1     string `json:"time1,omitempty" jsonschema:"description=第一个时间点"`
	Time2     string `json:"time2,omitempty" jsonschema:"description=第二个时间点"`
}

场景3:时间日期工具

type UpdateQueryParams

type UpdateQueryParams struct {
	TableName string                 `json:"tableName" jsonschema:"description=表名,required"`
	Where     map[string]interface{} `json:"where" jsonschema:"description=更新条件,required"`
	Data      map[string]interface{} `json:"data" jsonschema:"description=要更新的数据,required"`
}

UpdateQueryParams 更新参数

type UpdateQueryTool

type UpdateQueryTool struct {
	// contains filtered or unexported fields
}

UpdateQueryTool 更新数据工具

type WeatherParams

type WeatherParams struct {
	City string `json:"city" jsonschema:"description=要查询的城市名称,required"`
	Date string `json:"date,omitempty" jsonschema:"description=查询日期,格式为YYYY-MM-DD,不填则查询今天"`
}

场景2:天气查询工具

type WriteQueryParams

type WriteQueryParams struct {
	TableName string                   `json:"tableName" jsonschema:"description=表名,required"`
	Data      []map[string]interface{} `json:"data" jsonschema:"description=要插入的数据,required"`
}

WriteQueryParams 写入参数

type WriteQueryTool

type WriteQueryTool struct {
	// contains filtered or unexported fields
}

WriteQueryTool 写入数据工具

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL