feat:增加大模型工具使用说明文档

This commit is contained in:
2026-06-29 11:01:32 +08:00
parent eadbf47c5f
commit 911429d591
3 changed files with 79 additions and 1 deletions

View File

@@ -60,6 +60,7 @@ export const routers = [
{ text: 'Agent开发', link: '/Web/AI/Langchain' },
{ text: 'Text To SQL开发', link: '/Web/AI/TextToSQL' },
{ text: 'RAG开发', link: '/Web/AI/RAG' },
{ text: 'Tools开发', link: '/Web/AI/Tools' },
]
},
{

View File

@@ -1,6 +1,6 @@
---
title: RAG开发
date: 2026-06-245
date: 2026-06-24
---
# 一、工作流程

77
docs/Web/AI/Tools.md Normal file
View File

@@ -0,0 +1,77 @@
---
title: Tools开发
date: 2026-06-29
---
# 一、工作流程
```text
【定义工具能力】
【约定输入输出】
【实现工具逻辑】
【注册到模型】
用户自然语言请求
【模型选择工具】
【执行工具】
【返回结果】
```
# 二、实战
## 2.1 工具定义
  实现一个根据接口查询数据的工具:
```python
@tool
def repair_search(date: list[str]) -> str:
"""
查询维修工单列表。
参数说明:
- date (list[str], 必填):
- 日期范围,格式:["YYYY-MM-DD", "YYYY-MM-DD"]
- 示例:["2026-07-01", "2026-08-01"]
"""
if date is None:
date = []
params = {
"currentPage": 0,
"pageSize": 0,
"customer": "",
"deviceName": "",
"deviceModel": "",
"date": date
}
token = get_token()
headers = {
"satoken": token
}
try:
resp = requests.get(f"{BASE_URL}repair", params=params, headers=headers, timeout=10)
resp.raise_for_status()
return resp.text
except Exception as e:
return f"查询维修工单失败: {e}"
```
## 2.2 注册到模型
```python
integrate_agent = create_agent(
model=model,
tools=[repair_search],
system_prompt=integrate_prompt
)
```
::: tip
工具里面的注释大模型是无法查看的,需要把工具的使用说明,例如接口返回值的含义,写在提示词里面。
:::