Dify+Anspire AI Search教程
Dify 0.15.x版本自定义工具:
自定义工具名称:
Anspire-AI-Tools
Schema在线地址:
https://plugin.anspire.cn/api/common/schema
Schema离线文件:
{
"openapi": "3.0.1",
"info": {
"title": "Anspire AISearch",
"description": "",
"version": "1.0.0"
},
"tags": [
{
"name": "ntsearch"
}
],
"paths": {
"/api/ntsearch/search": {
"get": {
"summary": "联网搜索",
"deprecated": false,
"description": "联网搜索",
"operationId": "Anspire_AI_Search",
"tags": ["ntsearch"],
"parameters": [
{
"name": "query",
"in": "query",
"description": "查询内容",
"required": false,
"example": "黄金价格",
"schema": {
"type": "string",
"default": "",
"title": "Query"
}
},
{
"name": "mode",
"in": "query",
"description": "查询类型(0: 自然检索结果 1: 垂类结果)",
"required": false,
"example": "",
"schema": {
"type": "string"
}
},
{
"name": "top_k",
"in": "query",
"description": "返回条数(示例值: 10/20/30/40/50)",
"required": false,
"example": "",
"schema": {
"type": "string"
}
},
{
"name": "Insite",
"in": "query",
"description": "指定站点",
"required": false,
"example": "",
"schema": {
"type": "string"
}
},
{
"name": "FromTime",
"in": "query",
"description": "起始时间(示例值: 2025-01-01 00:00:00)",
"required": false,
"example": "",
"schema": {
"type": "string"
}
},
{
"name": "ToTime",
"in": "query",
"description": "结束时间(示例值: 2025-01-01 00:00:00)",
"required": false,
"example": "",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"query": {
"type": "string"
},
"Uuid": {
"type": "string"
},
"results": {
"type": "array",
"items": {
"type": "object",
"properties": {
"title": {
"type": "string"
},
"content": {
"type": "string"
},
"url": {
"type": "string"
},
"score": {
"type": "number"
}
},
"required": ["title", "content", "url", "score"]
}
}
},
"required": ["query", "Uuid", "results"]
}
}
},
"headers": {}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
},
"headers": {}
}
},
"security": []
}
}
},
"components": {
"schemas": {
"HTTPValidationError": {
"properties": {
"detail": {
"items": {
"$ref": "#/components/schemas/ValidationError"
},
"type": "array",
"title": "Detail"
}
},
"type": "object",
"title": "HTTPValidationError"
},
"ValidationError": {
"properties": {
"loc": {
"items": {
"anyOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
},
"type": "array",
"title": "Location"
},
"msg": {
"type": "string",
"title": "Message"
},
"type": {
"type": "string",
"title": "Error Type"
}
},
"type": "object",
"required": ["loc", "msg", "type"],
"title": "ValidationError"
}
},
"securitySchemes": {}
},
"servers": [
{
"url": "https://plugin.anspire.cn",
"description": "正式环境"
}
],
"security": []
}
下载完整文件
输出Schemas:
自然类查询结果
{
"query": "你好",
"Uuid": "1985e607-b4e4-408b-a193-69b351f63df3",
"results": [
{
"title": "你好 - 搜狗百科",
"content": "你好(英文:hello、hi),读音为nǐ hǎo,汉语词语,指用于有礼貌的打招呼或表示与人见面时的问候。 “你好”是对别人的一种尊敬,遇到认识的人或陌生的人都可以说的。 “你好”主要用于打招呼请教别人问题前的时候,或者单纯表示礼貌的时候等。 “你好”的表达情感比较中性,与熟人说有点过于拘束,多和非熟人群体应用,表达一种礼貌。 “你好”主要用于打招呼请教别人问题前的时候,或者单纯表示礼貌的时候等。 “你好”的表达情感比较中性,与熟人说有点过于拘束,多和非熟人群体应用,表达一种礼貌。",
"url": "http://baike.sogou.com/v61690479.htm?fromTitle=%E4%BD%A0%E5%A5%BD",
"score": 0.8691385
}
]
}
工具导入步骤:
1. 获取授权api_key
2. dify平台自定义工具添加
- 登录dify进入工具=>自定义页面
- 点击创建自定义工具
-
输入工具名称eg: Anspire-AI-Tools
-
点击按钮《从URL导入》并输入在线URL
-
点击按钮《好的》导入schame
-
添加鉴权方法并选择API Key,鉴权头部前缀选择Bearer 并输入api_key值点击保存
-
配置完成
- 点击测试
- 参数query:输入查询内容;其他参数可选
- 点击测试
- 关闭测试页面点击保存
Dify 1.x.x版本插件(插件市场安装):
Endpoint : https://plugin.anspire.cn/api/ntsearch/search
1. 获取授权api_key
2. 安装插件
- 登录Dify平台->进入插件页面
- Marketplace->搜索Anspire
- 选择插件进行安装
- 授权:在已安装插件列表点击《安思派联网搜索》
- 点击:去授权=》输入终结点、授权码保存
- 插件详情
Dify 1.x.x版本插件(本地安装):
Endpoint : https://plugin.anspire.cn/api/ntsearch/search
1. 获取授权api_key
2. 获取插件安装包(20250410更新)
下载完整文件
3. 导入插件
- 登录Dify平台=》进入插件页面
- 安装插件=>本地插件=》选择插件包
- 点击安装
-
授权:在已安装插件列表点击《安思派联网搜索》
-
点击:去授权=》输入授权码保存
-
插件详情