联网搜索
这篇解决什么
对话里勾选搜索后,结果写在哪、打哪家接口。读完能对上 useSearch 和 ai_chat_message.web_search_pages,不要去建独立搜索菜单。
默认端口 48080。对话入口见 AI 聊天对话。
示意图:没有 /ai/web-search Controller。搜索嵌在发消息里。
从哪改
当前唯一实现是博查 https://api.bochaai.com/v1/web-search。Bean 要 yudao.ai.web-search.enable=true 才注入。
| 名称 | 说明 | 仓库路径 |
|---|---|---|
| 发送 | POST /ai/chat/message/send-stream | ruoyi-office/yudao-module-ai/.../controller/admin/chat/AiChatMessageController.java |
| 开关 | yudao.ai.web-search.enable / api-key | YudaoAiProperties.WebSearch |
| 客户端 | 仅 Bocha | AiBoChaWebSearchClient |
| 落库 | web_search_pages | AiChatMessageDO |
| 前端开关 | enableWebSearch | ruoyi-office-vben/apps/web-antd/src/views/ai/chat/index/ |
官方菜单仍是 AI 对话 2759。没有「联网搜索」叶子。
条件:useSearch == true 且 webSearchClient != null。条数常量 WEB_SEARCH_COUNT = 10,请求带 summary=true。命中页拼进 Prompt 的 <WebSearch title url>,同时写入 assistant 行。
字段
AiWebSearchResponse.WebPage:name、icon、title、url、snippet、summary。不是独立表。
| 名称 | 说明 | 仓库路径 |
|---|---|---|
useSearch | 本次是否搜 | AiChatMessageSendReqVO |
webSearchPages | 引用页 JSON | AiChatMessageDO |
YAML 关掉 enable 时,前端开关无效,webSearchClient 不注册。
换厂商要换实现
没有第二家 Client。换搜索源改 AiAutoConfiguration#webSearchClient 或新增 AiWebSearchClient,不要另开一张搜索表。
和推理、附件并行
同一条发送还可以带 useContext、attachmentUrls。搜索失败时对话仍可能只用原文回答。
按本仓库 DO 生成的 ER。搜索不是第二张表。
配置与操作
没有独立搜索菜单。YAML yudao.ai.web-search.enable=true 并填 api-key 后才会注入博查客户端。对话页打开开关,发送带 useSearch=true。命中页写入 web_search_pages,并拼进 Prompt。条数固定 10。
关掉 enable 时前端开关无效。没有第二家 Client。开启见 AI 功能设计。

本系统截图:AI 对话。联网搜索是发送参数 useSearch,没有单独菜单。
