diff --git a/src/agents/common/toolkits/mysql/tools.py b/src/agents/common/toolkits/mysql/tools.py index 17a681d0..f163b24d 100644 --- a/src/agents/common/toolkits/mysql/tools.py +++ b/src/agents/common/toolkits/mysql/tools.py @@ -52,9 +52,9 @@ class TableListModel(BaseModel): pass -@tool(name_or_callable="查询表名及说明", args_schema=TableListModel) +@tool(name_or_callable="mysql_list_tables", args_schema=TableListModel) def mysql_list_tables() -> str: - """获取数据库中的所有表名 + """【查询表名及说明】获取数据库中的所有表名 这个工具用来列出当前数据库中所有的表名,帮助你了解数据库的结构。 """ @@ -107,9 +107,9 @@ class TableDescribeModel(BaseModel): table_name: str = Field(description="要查询的表名", example="users") -@tool(name_or_callable="描述表", args_schema=TableDescribeModel) +@tool(name_or_callable="mysql_describe_table", args_schema=TableDescribeModel) def mysql_describe_table(table_name: Annotated[str, "要查询结构的表名"]) -> str: - """获取指定表的详细结构信息 + """【描述表】获取指定表的详细结构信息 这个工具用来查看表的字段信息、数据类型、是否允许NULL、默认值、键类型等。 帮助你了解表的结构,以便编写正确的SQL查询。 @@ -203,12 +203,12 @@ class QueryModel(BaseModel): timeout: int | None = Field(default=60, description="查询超时时间(秒),默认60秒,最大600秒", ge=1, le=600) -@tool(name_or_callable="执行 SQL 查询", args_schema=QueryModel) +@tool(name_or_callable="mysql_query", args_schema=QueryModel) def mysql_query( sql: Annotated[str, "要执行的SQL查询语句(只能是SELECT语句)"], timeout: Annotated[int | None, "查询超时时间(秒),默认60秒,最大600秒"] = 60, ) -> str: - """执行只读的SQL查询语句 + """【执行 SQL 查询】执行只读的SQL查询语句 这个工具用来执行SQL查询并返回结果。支持复杂的SELECT查询,包括JOIN、GROUP BY等。 注意:只能执行查询操作,不能修改数据。 diff --git a/web/src/components/ToolCallingResult/ToolCallRenderer.vue b/web/src/components/ToolCallingResult/ToolCallRenderer.vue index 0b9c5626..6310c79b 100644 --- a/web/src/components/ToolCallingResult/ToolCallRenderer.vue +++ b/web/src/components/ToolCallingResult/ToolCallRenderer.vue @@ -38,6 +38,15 @@ + + + + + + + + + @@ -61,6 +70,9 @@ import ListDirectoryTool from './tools/ListDirectoryTool.vue' import SearchFileContentTool from './tools/SearchFileContentTool.vue' import GlobTool from './tools/GlobTool.vue' import EditFileTool from './tools/EditFileTool.vue' +import MysqlQueryTool from './tools/MysqlQueryTool.vue' +import MysqlDescribeTableTool from './tools/MysqlDescribeTableTool.vue' +import MysqlListTablesTool from './tools/MysqlListTablesTool.vue' const props = defineProps({ toolCall: { @@ -170,6 +182,18 @@ const isEditFileResult = computed(() => { return toolName.value === 'edit_file' || toolName.value === 'replace' }) +const isMysqlQueryResult = computed(() => { + return toolName.value === 'mysql_query' +}) + +const isMysqlDescribeTableResult = computed(() => { + return toolName.value === 'mysql_describe_table' +}) + +const isMysqlListTablesResult = computed(() => { + return toolName.value === 'mysql_list_tables' +}) + // 处理知识图谱刷新 const graphToolCallRef = ref(null) const refreshGraph = () => { diff --git a/web/src/components/ToolCallingResult/index.js b/web/src/components/ToolCallingResult/index.js index 15a8c361..577d0bfe 100644 --- a/web/src/components/ToolCallingResult/index.js +++ b/web/src/components/ToolCallingResult/index.js @@ -15,3 +15,6 @@ export { default as ListDirectoryTool } from './tools/ListDirectoryTool.vue' export { default as SearchFileContentTool } from './tools/SearchFileContentTool.vue' export { default as GlobTool } from './tools/GlobTool.vue' export { default as EditFileTool } from './tools/EditFileTool.vue' +export { default as MysqlQueryTool } from './tools/MysqlQueryTool.vue' +export { default as MysqlDescribeTableTool } from './tools/MysqlDescribeTableTool.vue' +export { default as MysqlListTablesTool } from './tools/MysqlListTablesTool.vue' diff --git a/web/src/components/ToolCallingResult/tools/MysqlDescribeTableTool.vue b/web/src/components/ToolCallingResult/tools/MysqlDescribeTableTool.vue new file mode 100644 index 00000000..b7ae5afe --- /dev/null +++ b/web/src/components/ToolCallingResult/tools/MysqlDescribeTableTool.vue @@ -0,0 +1,83 @@ + + + + + 描述表结构: + {{ extractTableName(toolCall.args || toolCall.function?.arguments) }} + + + + + + {{ formatResult(resultContent) }} + + + + + + + + diff --git a/web/src/components/ToolCallingResult/tools/MysqlListTablesTool.vue b/web/src/components/ToolCallingResult/tools/MysqlListTablesTool.vue new file mode 100644 index 00000000..104e3f49 --- /dev/null +++ b/web/src/components/ToolCallingResult/tools/MysqlListTablesTool.vue @@ -0,0 +1,67 @@ + + + + + 列出数据库表 + + + + + + {{ formatResult(resultContent) }} + + + + + + + + diff --git a/web/src/components/ToolCallingResult/tools/MysqlQueryTool.vue b/web/src/components/ToolCallingResult/tools/MysqlQueryTool.vue new file mode 100644 index 00000000..4c04e1fd --- /dev/null +++ b/web/src/components/ToolCallingResult/tools/MysqlQueryTool.vue @@ -0,0 +1,119 @@ + + + + + 执行SQL查询: + {{ truncateSql(extractSql(toolCall.args || toolCall.function?.arguments)) }} + + + + + + {{ extractSql(args) }} + + + + + + {{ formatResult(resultContent) }} + + + + + + + +
{{ formatResult(resultContent) }}
{{ extractSql(args) }}