dify + BochaWebSearch 实现ollama与硅基流动deepseek的联网搜索 ...

铁佛  金牌会员 | 2025-3-22 17:04:04 | 显示全部楼层 | 阅读模式
打印 上一主题 下一主题

主题 977|帖子 977|积分 2931

一、dify 设置

1.管理员账号设置

在输入http://<your_ip>进行登岸(本地设置可以登岸 http://127.0.0.1 大概http://localhost),进行Dify的设置
默认会跳转到# 本地情况http://<your_ip>/install页面。

2.模子设置

模子设置路径位置为:主页-设置-模子供应商
如图所示:


模子设置时,可根据详细需求进行选择Ollama 模子设置大概其他模子供应商的模子。
(1)Ollama 模子设置

在模子供应商界面选择ollama。
基础URL 为ollama 服务,默认是 http://127.0.0.1:11434。如果是remote ollama 填写http://<your_ip>:port即可。

(2)硅基流动模子设置


硅基流动的api-key获取,必要首先在硅基流动官网 完成注册,然后在个人中心 > API 密钥 中创建 。如图所示:

二、deepseek 联网搜索设置

1.Web Search API设置

这里的Web Search API 利用博查,主要考虑方便购买API,并且代价相对bing,Serply等便宜不少。
设置时,通过创建自定义工具的方法,将BochaWebSearch设置为自定义工具,然后在工作流中接入BochaWebSearch 节点即可。
创建自定义工具的方法为在dify的工具界面,点击创建自定义工具。复制以下的shema 到 自定义工具的shema 设置下。
  1. openapi: 3.0.3
  2. info:
  3.   title: 博查
  4.   description: 博查是一个给AI用的中文搜索引擎,让你的AI应用从近百亿网页和生态内容源中获取高质量的世界知识,涵盖天气、新闻、百科、医疗、火车票、图片等多种领域。
  5.   version: 1.0.0
  6. servers:
  7.   - url: https://api.bochaai.com/v1
  8. paths:
  9.   /web-search:
  10.     post:
  11.       summary: 从博查搜索全网信息和网页链接,返回结果包括网页标题、网页URL、网页摘要、网站名称、网站图标、发布时间、图片链接等
  12.       operationId: BochaWebSearch
  13.       requestBody:
  14.         description: 请求参数
  15.         content:
  16.           application/json:
  17.             schema:
  18.               type: object
  19.               properties:
  20.                 query:
  21.                   type: string
  22.                   description: 搜索关键字或语句
  23.                   example: "阿里巴巴2024年的ESG报告"
  24.                 summary:
  25.                   type: boolean
  26.                   description: 是否在搜索结果中包含摘要
  27.                   default: true
  28.                   example: true
  29.                 freshness:
  30.                   type: string
  31.                   description: 搜索指定时间范围内的网页(可选值 "noLimit"、"oneDay"、"oneWeek"、"oneMonth"、"oneYear")
  32.                   default: "noLimit"
  33.                   enum:
  34.                     - "noLimit"
  35.                     - "oneDay"
  36.                     - "oneWeek"
  37.                     - "oneMonth"
  38.                     - "oneYear"
  39.                   example: "noLimit"
  40.                 count:
  41.                   type: integer
  42.                   description: 返回的搜索结果数量(1-10),默认为10
  43.                   default: 10
  44.                   minimum: 1
  45.                   maximum: 10
  46.                   example: 10
  47.               required:
  48.                 - query
  49.       responses:
  50.         '200':
  51.           description: 成功的搜索响应
  52.           content:
  53.             application/json:
  54.               schema:
  55.                 type: object
  56.                 properties:
  57.                   code:
  58.                     type: integer
  59.                     description: 响应的状态码
  60.                     example: 200
  61.                   log_id:
  62.                     type: string
  63.                     description: 请求的唯一日志ID
  64.                     example: "0d0eb34abc6eec9d"
  65.                   msg:
  66.                     type: string
  67.                     nullable: true
  68.                     description: 请求的消息提示(如果有的话)
  69.                     example: null
  70.                   data:
  71.                     type: object
  72.                     properties:
  73.                       _type:
  74.                         type: string
  75.                         description: 搜索的类型
  76.                         example: "SearchResponse"
  77.                       queryContext:
  78.                         type: object
  79.                         properties:
  80.                           originalQuery:
  81.                             type: string
  82.                             description: 原始的搜索关键字
  83.                             example: "阿里巴巴2024年的ESG报告"
  84.                       webPages:
  85.                         type: object
  86.                         properties:
  87.                           webSearchUrl:
  88.                             type: string
  89.                             description: 网页搜索的URL
  90.                             example: "https://bochaai.com/search?q=阿里巴巴2024年的ESG报告"
  91.                           totalEstimatedMatches:
  92.                             type: integer
  93.                             description: 搜索匹配的网页总数
  94.                             example: 1618000
  95.                           value:
  96.                             type: array
  97.                             items:
  98.                               type: object
  99.                               properties:
  100.                                 id:
  101.                                   type: string
  102.                                   nullable: true
  103.                                   description: 网页的排序ID
  104.                                 name:
  105.                                   type: string
  106.                                   description: 网页的标题
  107.                                 url:
  108.                                   type: string
  109.                                   description: 网页的URL
  110.                                 displayUrl:
  111.                                   type: string
  112.                                   description: 网页的展示URL
  113.                                 snippet:
  114.                                   type: string
  115.                                   description: 网页内容的简短描述
  116.                                 summary:
  117.                                   type: string
  118.                                   description: 网页内容的文本摘要
  119.                                 siteName:
  120.                                   type: string
  121.                                   description: 网页的网站名称
  122.                                 siteIcon:
  123.                                   type: string
  124.                                   description: 网页的网站图标
  125.                                 dateLastCrawled:
  126.                                   type: string
  127.                                   format: date-time
  128.                                   description: 网页的收录时间或发布时间
  129.                                 cachedPageUrl:
  130.                                   type: string
  131.                                   nullable: true
  132.                                   description: 网页的缓存页面URL
  133.                                 language:
  134.                                   type: string
  135.                                   nullable: true
  136.                                   description: 网页的语言
  137.                                 isFamilyFriendly:
  138.                                   type: boolean
  139.                                   nullable: true
  140.                                   description: 是否为家庭友好的页面
  141.                                 isNavigational:
  142.                                   type: boolean
  143.                                   nullable: true
  144.                                   description: 是否为导航性页面
  145.                       images:
  146.                         type: object
  147.                         properties:
  148.                           id:
  149.                             type: string
  150.                             nullable: true
  151.                             description: 图片搜索结果的ID
  152.                           webSearchUrl:
  153.                             type: string
  154.                             nullable: true
  155.                             description: 图片搜索的URL
  156.                           value:
  157.                             type: array
  158.                             items:
  159.                               type: object
  160.                               properties:
  161.                                 webSearchUrl:
  162.                                   type: string
  163.                                   nullable: true
  164.                                   description: 图片搜索结果的URL
  165.                                 name:
  166.                                   type: string
  167.                                   nullable: true
  168.                                   description: 图片的名称
  169.                                 thumbnailUrl:
  170.                                   type: string
  171.                                   description: 图像缩略图的URL
  172.                                   example: "http://dayu-img.uc.cn/columbus/img/oc/1002/45628755e2db09ccf7e6ea3bf22ad2b0.jpg"
  173.                                 datePublished:
  174.                                   type: string
  175.                                   nullable: true
  176.                                   description: 图像的发布日期
  177.                                 contentUrl:
  178.                                   type: string
  179.                                   description: 访问全尺寸图像的URL
  180.                                   example: "http://dayu-img.uc.cn/columbus/img/oc/1002/45628755e2db09ccf7e6ea3bf22ad2b0.jpg"
  181.                                 hostPageUrl:
  182.                                   type: string
  183.                                   description: 图片所在网页的URL
  184.                                   example: "http://dayu-img.uc.cn/columbus/img/oc/1002/45628755e2db09ccf7e6ea3bf22ad2b0.jpg"
  185.                                 contentSize:
  186.                                   type: string
  187.                                   nullable: true
  188.                                   description: 图片内容的大小
  189.                                 encodingFormat:
  190.                                   type: string
  191.                                   nullable: true
  192.                                   description: 图片的编码格式
  193.                                 hostPageDisplayUrl:
  194.                                   type: string
  195.                                   nullable: true
  196.                                   description: 图片所在网页的显示URL
  197.                                 width:
  198.                                   type: integer
  199.                                   description: 图片的宽度
  200.                                   example: 553
  201.                                 height:
  202.                                   type: integer
  203.                                   description: 图片的高度
  204.                                   example: 311
  205.                                 thumbnail:
  206.                                   type: string
  207.                                   nullable: true
  208.                                   description: 图片缩略图(如果有的话)
  209.                       videos:
  210.                         type: object
  211.                         properties:
  212.                           id:
  213.                             type: string
  214.                             nullable: true
  215.                             description: 视频搜索结果的ID
  216.                           readLink:
  217.                             type: string
  218.                             nullable: true
  219.                             description: 视频的读取链接
  220.                           webSearchUrl:
  221.                             type: string
  222.                             nullable: true
  223.                             description: 视频搜索的URL
  224.                           isFamilyFriendly:
  225.                             type: boolean
  226.                             description: 是否为家庭友好的视频
  227.                           scenario:
  228.                             type: string
  229.                             description: 视频的场景
  230.                           value:
  231.                             type: array
  232.                             items:
  233.                               type: object
  234.                               properties:
  235.                                 webSearchUrl:
  236.                                   type: string
  237.                                   description: 视频搜索结果的URL
  238.                                 name:
  239.                                   type: string
  240.                                   description: 视频的名称
  241.                                 description:
  242.                                   type: string
  243.                                   description: 视频的描述
  244.                                 thumbnailUrl:
  245.                                   type: string
  246.                                   description: 视频的缩略图URL
  247.                                 publisher:
  248.                                   type: array
  249.                                   items:
  250.                                     type: object
  251.                                     properties:
  252.                                       name:
  253.                                         type: string
  254.                                         description: 发布者名称
  255.                                 creator:
  256.                                   type: object
  257.                                   properties:
  258.                                     name:
  259.                                       type: string
  260.                                       description: 创作者名称
  261.                                 contentUrl:
  262.                                   type: string
  263.                                   description: 视频内容的URL
  264.                                 hostPageUrl:
  265.                                   type: string
  266.                                   description: 视频所在网页的URL
  267.                                 encodingFormat:
  268.                                   type: string
  269.                                   description: 视频编码格式
  270.                                 hostPageDisplayUrl:
  271.                                   type: string
  272.                                   description: 视频所在网页的显示URL
  273.                                 width:
  274.                                   type: integer
  275.                                   description: 视频的宽度
  276.                                 height:
  277.                                   type: integer
  278.                                   description: 视频的高度
  279.                                 duration:
  280.                                   type: string
  281.                                   description: 视频的长度
  282.                                 motionThumbnailUrl:
  283.                                   type: string
  284.                                   description: 动态缩略图的URL
  285.                                 embedHtml:
  286.                                   type: string
  287.                                   description: 用于嵌入视频的HTML代码
  288.                                 allowHttpsEmbed:
  289.                                   type: boolean
  290.                                   description: 是否允许HTTPS嵌入
  291.                                 viewCount:
  292.                                   type: integer
  293.                                   description: 视频的观看次数
  294.                                 thumbnail:
  295.                                   type: object
  296.                                   properties:
  297.                                     height:
  298.                                       type: integer
  299.                                       description: 视频缩略图的高度
  300.                                     width:
  301.                                       type: integer
  302.                                       description: 视频缩略图的宽度
  303.                                 allowMobileEmbed:
  304.                                   type: boolean
  305.                                   description: 是否允许移动端嵌入
  306.                                 isSuperfresh:
  307.                                   type: boolean
  308.                                   description: 是否为最新视频
  309.                                 datePublished:
  310.                                   type: string
  311.                                   description: 视频的发布日期
  312.         '400':
  313.           description: 请求参数错误
  314.         '401':
  315.           description: 未授权 - API 密钥无效或缺失
  316.         '500':
  317.           description: 搜索服务内部错误
  318.       security:
  319.         - apiKeyAuth: []
  320.   /ai-search:
  321.     post:
  322.       summary: 在博查网页搜索的基础上,AI识别搜索词语义并额外返回垂直领域内容的结构化模态卡,例如天气卡、日历卡、百科卡等
  323.       operationId: BochaAISearch
  324.       requestBody:
  325.         description: 请求参数
  326.         content:
  327.           application/json:
  328.             schema:
  329.               type: object
  330.               properties:
  331.                 query:
  332.                   type: string
  333.                   description: 搜索关键字或语句
  334.                   example: "阿里巴巴2024年的ESG报告"
  335.                 freshness:
  336.                   type: string
  337.                   description: 搜索指定时间范围内的网页(可选值 "noLimit"、"oneDay"、"oneWeek"、"oneMonth"、"oneYear")
  338.                   default: "noLimit"
  339.                   enum:
  340.                     - "noLimit"
  341.                     - "oneDay"
  342.                     - "oneWeek"
  343.                     - "oneMonth"
  344.                     - "oneYear"
  345.                   example: "noLimit"
  346.                 answer:
  347.                   type: boolean
  348.                   description: 是否返回大模型总结的答案,参数留空则不返回
  349.                 count:
  350.                   type: integer
  351.                   description: 返回的搜索结果数量(1-50),默认为10
  352.                   default: 10
  353.                   minimum: 1
  354.                   maximum: 50
  355.                   example: 10
  356.               required:
  357.                 - query
  358.       responses:
  359.         '200':
  360.           description: 成功的搜索响应
  361.           content:
  362.             application/json:
  363.               schema:
  364.                 type: object
  365.                 properties:
  366.                   code:
  367.                     type: integer
  368.                     description: 响应的状态码
  369.                     example: 200
  370.                   log_id:
  371.                     type: string
  372.                     description: 请求的唯一日志ID
  373.                     example: "0d0eb34abc6eec9d"
  374.                   conversation_id:
  375.                     type: string
  376.                     nullable: true
  377.                     description: 请求的唯一会话ID
  378.                     example: null
  379.                   messages:
  380.                     type: array
  381.                     items:
  382.                       type: object
  383.                       properties:
  384.                         role:
  385.                           type: string
  386.                           nullable: true
  387.                           description: 消息发送者(user或assistant)
  388.                         type:
  389.                           type: string
  390.                           description: 消息的类型(source,answer,follow_up等)
  391.                         content_type:
  392.                           type: string
  393.                           description: 消息的模态卡类型(webpage,image,video,baike_pro,weather_china,weather_international,medical_common,medical_pro,calendar,text等)
  394.                         content:
  395.                           type: string
  396.                           description: 消息内容(json encode后的文本)
  397.         '400':
  398.           description: 请求参数错误
  399.         '401':
  400.           description: 未授权 - API 密钥无效或缺失
  401.         '500':
  402.           description: 搜索服务内部错误
  403.       security:
  404.         - apiKeyAuth: []
  405. components:
  406.   securitySchemes:
  407.     apiKeyAuth:
  408.       type: apiKey
  409.       in: header
  410.       name: Authorization
复制代码


博查API-Key获取链接为:https://open.bochaai.com/api-keys
利用时必要充值,按最小金额充值就行。

创建完成后的效果如图所示:

2.工作流设置

这里利用导入自定义DSL文件的方式创建工作流。

DSL文件内容如下:
[code]app:
  description: 使用DeepSeek-R1+博查搜索插件,1分钟搭建一个AI搜索助手
  icon:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

铁佛

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表