再新建配置文件./config/tools.yaml,配置示例如下
更多配置项可参考官网文档:https://googleapis.github.io/genai-toolbox/getting-started/configure/
sources:
mysql-source:
kind: mysql
host: 127.0.0.1
port: 3306
database: test
user: root
password: root
tools:
search-user-by-name:
kind: mysql-sql
source: mysql-source
description: 根据名称关键字查询用户信息
templateParameters:
- name: name
type: string
description: 名称关键字
statement: SELECT id,name,status,created_at,updated_at FROM user WHERE name LIKE "%{{.name}}%"
create-fake-user:
kind: mysql-sql
source: mysql-source
description: 新增插入一个用户数据,只要调用正常即为成功,不需要判断具体的返回结果
templateParameters:
- name: name
type: string
description: 用户名称,这是唯一索引
- name: status
type: integer
description: 状态,0-禁用,1-启用
- name: created_at
type: string
description: 创建时间,格式:2025-07-20 12:12:12
- name: updated_at
type: string
description: 更新时间,格式:2025-07-20 12:12:12
statement: |
INSERT INTO user (name, status, created_at, updated_at)
VALUES ('{{.name}}', {{.status}}, '{{.created_at}}', '{{.updated_at}}')