dify学习笔记之一些工具的openai schema
在dify中添加一些自定义工具通常是我们较为常见的需求,添加过程需要使用json格式或yaml格式的openai schema,下面是一些我用过的工具集合:
1.获取ip
- (1) 工具地址:https://ip-moe.zerodream.net
- (2) 对应openai schema的json
{
"openapi": "3.1.0",
"info": {
"title": "Moe IP IPv4地址归属地查询接口",
"version": "1.0.0",
"description": "该接口用于查询IPv4地址的归属地信息,数据整合自纯真IP库、ip2region和GeoIP2"
},
"servers": [
{
"url": "https://ip-moe.zerodream.net",
"description": "Get ip location"
}
],
"paths": {
"/": {
"get": {
"summary": "查询IPv4地址归属地",
"operationId": "get_ip_location",
"description": "通过传入的IPv4地址,获取其归属地的相关信息",
"parameters": [
{
"name": "ip",
"in": "query",
"description": "需要查询归属地的IPv4地址",
"required": true,
"schema": {
"type": "string"
}
}
]
}
}
}
}
2.高德天气查询
- (1) api key注册地址:https://console.amap.com/dev/index
- (2) 对应openai schema的json
{
"openapi": "3.1.0",
"info": {
"title": "高德天气助手",
"description": "这是一个获取高德天气的API",
"version": "1.0.0"
},
"servers": [
{
"url": "https://restapi.amap.com/v3/weather/weatherInfo?parameters",
"description": "获取天气信息"
}
],
"paths": {
"/": {
"get": {
"summary": "获取天气信息",
"operationId": "get_weather",
"description": "通过传入的位置地址,获取相关天气相关信息",
"parameters": [
{
"name": "city",
"in": "query",
"description": "需要查询城市名",
"required": true,
"schema": {
"type": "string"
}
}
]
}
}
}
}
注意需要将鉴权方式设置为 API Key
,并填入你的app key: