优化了agent
This commit is contained in:
@@ -13,19 +13,22 @@ class EscortAdminPrompts {
|
||||
}
|
||||
|
||||
return `
|
||||
# 角色定义
|
||||
你是小暖,暖橙陪诊平台的管理助手,直接、高效的解决平台问题。
|
||||
# 角色
|
||||
你是小暖,暖橙陪诊平台的管理助手。直接、高效地解决平台问题。
|
||||
|
||||
# 核心能力
|
||||
- 解答服务流程、价格、注意事项
|
||||
- 提供就诊准备建议
|
||||
- 通过tools和skills,为用户提供其他服务。如:查询天气、路线、查询医院信息、查询医生信息等。
|
||||
# 职责
|
||||
1. 服务咨询:依据参考信息解答陪诊流程、价格、注意事项;服务边界/流程/质量类问题遵循国标 GB/T 47801—2026(medical-escort-standard 技能),必要时查阅后回答
|
||||
2. 就诊准备:提供符合医疗规范的就诊准备建议,不提供医疗诊断
|
||||
3. 工具与技能:通过 tools/skills 查询天气、路线、医院、医生等信息
|
||||
|
||||
# 铁律(必须遵守)
|
||||
1. 思考和理解任务意图,专业、谨慎、高效、专注的完成任务。
|
||||
# 铁律
|
||||
1. 服务回答必须基于参考信息,不编造;超出能力范围如实说明。
|
||||
2. 涉及医疗问题,提醒以医生诊断为准。
|
||||
|
||||
## 参考信息
|
||||
管理员信息:${userInfo_str};
|
||||
# 参考信息
|
||||
管理员信息:${userInfo_str}
|
||||
服务项目:${JSON.stringify(services)}
|
||||
服务协议:${JSON.stringify(agreement)}
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,29 +30,26 @@ class Prompts {
|
||||
}
|
||||
|
||||
return `
|
||||
# 角色定义
|
||||
你是小橙,为需要就医和陪诊的用户提供咨询和情绪价值。温暖、共情、简洁、专业。
|
||||
# 角色
|
||||
你是小橙,陪诊服务平台顾问。温暖、共情、简洁、专业地解答就医陪诊问题,提供情绪价值。
|
||||
|
||||
# 能力
|
||||
- 基于服务项目和服务协议,解答陪诊流程、价格、注意事项
|
||||
- 提供就医规划,就诊准备建议,情绪价值(不提供医疗诊断)
|
||||
- 就诊准备要专业,符合医疗规范
|
||||
- 调用工具查询天气、路线、医院、医生等信息
|
||||
# 职责
|
||||
1. 服务咨询:依据参考信息解答陪诊流程、价格、注意事项;服务边界/流程/质量类问题遵循国标 GB/T 47801—2026(medical-escort-standard 技能),必要时查阅后回答
|
||||
2. 就医规划:提供就诊准备建议(需符合医疗规范),不提供医疗诊断
|
||||
3. 信息查询:调用工具查天气、路线、医院、医生等
|
||||
|
||||
# 铁律
|
||||
1. 服务相关回答必须基于参考信息,不编造。
|
||||
2. 服务边界、服务流程、服务质量类问题,遵循国家标准 GB/T 47801—2026《社会化陪同就医服务 基本要求》(medical-escort-standard 技能),必要时查阅后回答。
|
||||
3. 感知用户情绪,给予共情回应。
|
||||
4. 涉及医疗问题,提醒以医生诊断为准。
|
||||
5. 超出能力范围,引导联系客服。
|
||||
6. 保护用户隐私,提示AI内容需甄别。
|
||||
1. 服务回答必须基于参考信息,不编造;超出能力范围引导联系客服。
|
||||
2. 涉及医疗问题,提醒以医生诊断为准。
|
||||
3. 语音/图片识别文本可能有错漏,图片内容以【图像识别】/【原文转写】段落为准;涉及数值、单位、药名、日期先与用户确认,不臆测未显示内容。
|
||||
4. 感知用户情绪并共情回应;保护用户隐私,提示AI内容需甄别。
|
||||
|
||||
## 参考信息
|
||||
用户信息:${userInfo_str};
|
||||
用户记忆:${usermem_str};
|
||||
服务项目:${JSON.stringify(services)};
|
||||
服务协议:${JSON.stringify(agreement)};
|
||||
联系电话: 18618162956(微信同号)
|
||||
# 参考信息
|
||||
用户信息:${userInfo_str}
|
||||
用户记忆:${usermem_str}
|
||||
服务项目:${JSON.stringify(services)}
|
||||
服务协议:${JSON.stringify(agreement)}
|
||||
联系电话:18618162956(微信同号)
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: baidu-ai-map
|
||||
description: 使用百度地图 Agent Plan 直接完成地理任务:语义化地点检索、路线规划、地理编码与逆地理编码、天气查询。用户要的是地点、路线、地址或天气答案时优先使用;不用于生成地图代码、查询官方接口文档或管理百度地图账号。
|
||||
description: 使用百度地图 Agent Plan 直接完成地理任务:语义化地点检索、路线规划(含途经点/沿途搜索)、地理编码与逆地理编码、天气查询、地图展示链接生成。用户要的是地点、路线、地址或天气答案时优先使用;不用于生成地图代码、查询官方接口文档或管理百度地图账号。
|
||||
---
|
||||
|
||||
# 百度地图 Agent Plan
|
||||
@@ -56,12 +56,13 @@ http_get({
|
||||
4. 不得编造坐标;`center` / `location` / `refer_pois` 仅可来自用户明确提供或可信来源。无可靠坐标时,必须先向用户澄清,或先调用 `geocoding` / `place` 获取。
|
||||
5. 经纬度至少保留小数点后 6 位,坐标类型统一为 `gcj02`。
|
||||
6. 直接解析 `http_get` 返回的 JSON,不使用正则或脚本裁剪响应后猜测字段;短时间内遇到相同或高度相似请求时,优先复用已有结果,避免重复调用。
|
||||
7. `direction` 可能返回两类结果:路线结果,或起终点澄清结果。返回澄清结果时,先根据用户需求推理最合理候选;仍无法唯一确定时,引导用户在候选中选择后再继续规划。
|
||||
8. 医疗陪诊场景只查询完成当前任务所必需的位置信息;回答中不要泄露用户精确住址或坐标。
|
||||
7. `direction` 通过 `answer_type` 区分结果:`gptmodel_navigate` 为路线结果;`gptmodel_poi_clarify` / `gptmodel_onway_search_clarify` 为澄清结果。返回澄清结果时,先根据用户需求推理最合理候选;仍无法唯一确定时,引导用户在候选中选择。用户选择后重新规划时,必须同时改写 `user_raw_request` 明确指定选中 POI,并传入该 POI 的 `refer_pois`。
|
||||
8. 用户明确要求"在地图上显示/标出"等可视化意图时,取 `place` / `direction` 响应中的 `resource_key` 生成展示链接回复用户(详见 MapRender);不要尝试打开浏览器。
|
||||
9. 医疗陪诊场景只查询完成当前任务所必需的位置信息;回答中不要泄露用户精确住址或坐标。
|
||||
|
||||
## 执行工作流
|
||||
|
||||
1. 根据需求选择 `place`、`direction`、`geocoding`、`reverse_geocoding` 或 `weather`。
|
||||
1. 根据需求选择 `place`、`direction`、`geocoding`、`reverse_geocoding`、`weather` 或 MapRender(地图展示链接)。
|
||||
2. 读取 `agent/infra/skills/baidu-ai-map/references/agent-plan-api.md` 中对应接口的必填参数、约束和示例,不要一次加载无关接口资料。
|
||||
3. 用 `http_get` 发起请求:`url` 指向 `https://api.map.baidu.com/agent_plan/v1/...`,查询参数放在 `params`。
|
||||
4. 解析返回的完整 JSON;`http_get` 返回 `{ success, status, body, truncated, ... }`,业务数据通常在 `body` 中。
|
||||
@@ -73,10 +74,11 @@ http_get({
|
||||
| 需求 | 接口 | 参考位置 |
|
||||
|---|---|---|
|
||||
| 语义化地点检索 | `GET /agent_plan/v1/place` | `references/agent-plan-api.md#place` |
|
||||
| 语义化路线规划 | `GET /agent_plan/v1/direction` | `references/agent-plan-api.md#direction` |
|
||||
| 语义化路线规划(含沿途搜索) | `GET /agent_plan/v1/direction` | `references/agent-plan-api.md#direction` |
|
||||
| 地址转坐标 | `GET /agent_plan/v1/geocoding` | `references/agent-plan-api.md#geocoding` |
|
||||
| 坐标转地址 | `GET /agent_plan/v1/reverse_geocoding` | `references/agent-plan-api.md#reverse-geocoding` |
|
||||
| 天气查询 | `GET /agent_plan/v1/weather` | `references/agent-plan-api.md#weather` |
|
||||
| 地图展示链接 | 无独立接口,用 place/direction 的 `resource_key` | `references/agent-plan-api.md#maprender地图展示` |
|
||||
|
||||
## 错误处理
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"ownerId": "kn778b6bf766ym71fdvrc5yvg98319rv",
|
||||
"slug": "baidu-ai-map",
|
||||
"version": "1.2.0",
|
||||
"version": "1.3.0",
|
||||
"publishedAt": 1793156191329
|
||||
}
|
||||
@@ -13,6 +13,7 @@
|
||||
- [Geocoding](#geocoding)
|
||||
- [Reverse Geocoding](#reverse-geocoding)
|
||||
- [Weather](#weather)
|
||||
- [MapRender](#maprender地图展示)
|
||||
- [响应与排错](#响应与排错)
|
||||
|
||||
## Place
|
||||
@@ -67,17 +68,22 @@ http_get({
|
||||
|
||||
必填参数:
|
||||
|
||||
- `user_raw_request`:包含起终点并保留完整路线约束。接口仅支持驾车、步行、骑行、公交,其他交通方式需改写为其中一种。
|
||||
- `user_raw_request`:用户原始需求,包含起点、终点、途经点;支持沿途搜索 POI(如"路上买杯咖啡");保留路线约束词。出现驾车/步行/骑行/公交以外的交通方式(如打车、坐地铁)时,需推理改写为这四种之一(如"打车"改写为"驾车")。
|
||||
- `location`:用户当前位置,格式为 `lat,lng`,坐标系为 `gcj02`;用于推理模糊或同名起点。
|
||||
|
||||
可选参数:
|
||||
|
||||
- `refer_pois`:地点精确映射,格式 `地点名称:uid,纬度,经度;地点名称:uid,纬度,经度`。仅在明确存在同名地点或别名消歧时传入。
|
||||
- `refer_pois`:地点精确映射,格式 `地点名称:uid,纬度,经度;地点名称:uid,纬度,经度`。默认不传,仅在澄清消歧后重新规划时传入。
|
||||
|
||||
规则:
|
||||
|
||||
- `location` 与 `refer_pois` 的坐标必须来自用户或可信接口结果,经纬度至少保留 6 位小数。
|
||||
- 响应可能是路线,也可能是起终点候选;无法根据用户需求唯一消歧时,再请用户选择。
|
||||
- 响应通过 `answer_type` 区分两类结果:
|
||||
- `gptmodel_navigate`:路线规划结果,直接解析路线方案回答用户。
|
||||
- `gptmodel_poi_clarify` / `gptmodel_onway_search_clarify`:起终点 POI 澄清或沿途搜索 POI 澄清。先根据用户需求推理最合理候选;无法唯一确定时展示候选并请用户选择。
|
||||
- 澄清后重新规划必须同时满足两个条件:
|
||||
1. 改写 `user_raw_request`,明确指定选中的 POI(如"路上买杯咖啡" → "先去星巴克(知春路店)买杯咖啡");
|
||||
2. 传入选中 POI 的 `refer_pois` 精确坐标映射。
|
||||
|
||||
示例:
|
||||
|
||||
@@ -104,6 +110,30 @@ http_get({
|
||||
})
|
||||
```
|
||||
|
||||
交通方式推理改写(打车 → 驾车):
|
||||
|
||||
```text
|
||||
http_get({
|
||||
url: "https://api.map.baidu.com/agent_plan/v1/direction",
|
||||
params: {
|
||||
user_raw_request: "从王府井驾车去三里屯要多久",
|
||||
location: "39.914590,116.403770"
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
沿途搜索(顺路买咖啡):
|
||||
|
||||
```text
|
||||
http_get({
|
||||
url: "https://api.map.baidu.com/agent_plan/v1/direction",
|
||||
params: {
|
||||
user_raw_request: "从百度大厦驾车到颐和园,路上顺便买一杯咖啡",
|
||||
location: "39.914590,116.403770"
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## Geocoding
|
||||
|
||||
`GET /agent_plan/v1/geocoding`
|
||||
@@ -171,6 +201,31 @@ http_get({
|
||||
})
|
||||
```
|
||||
|
||||
## MapRender(地图展示)
|
||||
|
||||
在用户明确表达"在地图上显示/标出""打开地图查看""地图里看看"等可视化意图时,基于上一步 `place` / `direction` 响应中的 `resource_key` 字段生成地图展示链接,回复给用户。
|
||||
|
||||
参数:
|
||||
|
||||
- `resource_key`(必填):取自上一步 `place` / `direction` 接口响应中的 `resource_key` 字段。
|
||||
|
||||
规则:
|
||||
|
||||
1. 必须先调用 `place` 或 `direction` 拿到 `resource_key`,才能生成展示链接。
|
||||
2. 展示链接格式:`https://lbs.baidu.com/mapstatic/agentui_resource.html?resource_key=<resource_key>`。
|
||||
3. 本环境没有浏览器/shell 工具,**不要尝试打开浏览器**;直接把链接作为回复内容发给用户,由用户自行点击查看。
|
||||
4. 仅在用户明确表达可视化意图时使用;单纯信息查询("附近有什么""怎么走""多久到")不触发。
|
||||
5. `direction` 返回非 `gptmodel_navigate` 结果(澄清列表)时,不生成展示链接。
|
||||
|
||||
示例:
|
||||
|
||||
```text
|
||||
# 用户:"帮我找北京可带宠物的咖啡馆,在地图上标出来"
|
||||
# 步骤1: 调用 place 获取 POI 列表和 resource_key
|
||||
# 步骤2: 回复用户结果,并附上链接
|
||||
https://lbs.baidu.com/mapstatic/agentui_resource.html?resource_key=abc123def456
|
||||
```
|
||||
|
||||
## 响应与排错
|
||||
|
||||
`http_get` 返回结构:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { tool } from "@langchain/core/tools"
|
||||
import { z } from "zod"
|
||||
import { Solar } from "lunar-javascript"
|
||||
import logger from "../../../../utils/logger.js"
|
||||
|
||||
/**
|
||||
* 日历工具
|
||||
@@ -75,7 +76,7 @@ async function getBeijingNow() {
|
||||
success: true
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(`获取网络时间失败,使用本机时间: ${error.message}`)
|
||||
logger.warn(`获取网络时间失败,使用本机时间: ${error.message}`)
|
||||
const now = new Date()
|
||||
return {
|
||||
...getBeijingDateParts(now),
|
||||
@@ -118,7 +119,7 @@ export const getCalendarInfoTool = tool(
|
||||
const solar = Solar.fromYmd(now.year, now.month, now.day)
|
||||
return JSON.stringify({ now, ...buildDayInfo(solar) }, null, 2)
|
||||
} catch (error) {
|
||||
console.error("Error in calendar tool:", error)
|
||||
logger.error("Error in calendar tool:", error)
|
||||
return JSON.stringify({ error: error.message }, null, 2)
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { tool } from "langchain"
|
||||
import lunarLib from "lunar-javascript"
|
||||
import { tool } from "@langchain/core/tools";
|
||||
import { z } from "zod";
|
||||
import lunarLib from "lunar-javascript";
|
||||
const { Solar, HolidayUtil } = lunarLib
|
||||
|
||||
/**
|
||||
@@ -36,17 +37,8 @@ export const getYearHolidaysTool = tool(
|
||||
{
|
||||
name: "get_year_holidays",
|
||||
description: "查询给定年份节日所在日期列表,包括法定节假日安排(含调休)与传统节日",
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
year: {
|
||||
type: "number",
|
||||
description: "年份",
|
||||
minimum: 1900,
|
||||
maximum: 2100
|
||||
}
|
||||
},
|
||||
required: ["year"]
|
||||
}
|
||||
schema: z.object({
|
||||
year: z.number().int().min(1900).max(2100).describe("年份")
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { tool } from "@langchain/core/tools";
|
||||
import z from "zod";
|
||||
import { z } from "zod";
|
||||
import { DBModel } from "../../../../models/index.js";
|
||||
import { escapeRegex } from "./utils.js";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { tool } from "@langchain/core/tools";
|
||||
import z from "zod";
|
||||
import { z } from "zod";
|
||||
import mongoose from "mongoose";
|
||||
import { DBModel } from "../../../../models/index.js";
|
||||
import { canTransition, STATUS_TRANSITIONS } from "../../../../utils/record_state.js";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { tool } from "@langchain/core/tools";
|
||||
import z from "zod";
|
||||
import { z } from "zod";
|
||||
import mongoose from "mongoose";
|
||||
import { DBModel } from "../../../../models/index.js";
|
||||
import { escapeRegex } from "./utils.js";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { tool } from "@langchain/core/tools";
|
||||
import z from "zod";
|
||||
import { z } from "zod";
|
||||
import mongoose from "mongoose";
|
||||
import { DBModel } from "../../../../models/index.js";
|
||||
import { genPinyin, genPinyinFL } from "../../../../models/schema/health_profile.js";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { tool } from "@langchain/core/tools";
|
||||
import z from "zod";
|
||||
import { z } from "zod";
|
||||
import { DBModel } from "../../../../models/index.js";
|
||||
import { escapeRegex } from "./utils.js";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { tool } from "@langchain/core/tools";
|
||||
import z from "zod";
|
||||
import { z } from "zod";
|
||||
import mongoose from "mongoose";
|
||||
import { DBModel } from "../../../../models/index.js";
|
||||
import { escapeRegex } from "./utils.js";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { tool } from "@langchain/core/tools";
|
||||
import z from "zod";
|
||||
import { z } from "zod";
|
||||
import { DBModel } from "../../../../models/index.js";
|
||||
import { escapeRegex } from "./utils.js";
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Tool 模块统一导出入口
|
||||
|
||||
// Web 工具
|
||||
export { webFetchTool } from './web/fetch.js';
|
||||
export { webSearchTool } from './web/search.js';
|
||||
export { webSearchTool, webFetchTool } from './web/tavily.js';
|
||||
export { httpGetTool } from './web/http_get.js';
|
||||
|
||||
// 日历工具
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
import { TavilyExtract } from "@langchain/tavily";
|
||||
import { tool } from "@langchain/core/tools";
|
||||
import { z } from "zod";
|
||||
import config from "../../../../config.js";
|
||||
|
||||
const webFetchTool = tool(
|
||||
async ({
|
||||
extractDepth = "basic",
|
||||
includeImages = false,
|
||||
format = "markdown",
|
||||
urls = [],
|
||||
}) => {
|
||||
const tavilyExtract = new TavilyExtract({
|
||||
tavilyApiKey: config.agent.tavily.apiKey,
|
||||
extractDepth,
|
||||
includeImages,
|
||||
format
|
||||
});
|
||||
return await tavilyExtract._call({ urls });
|
||||
},
|
||||
{
|
||||
name: "web_fetch",
|
||||
description:
|
||||
"抓取并提取指定网页的正文内容(默认 Markdown),适合阅读医院官网、政策公告、新闻等长文页面。",
|
||||
schema: z.object({
|
||||
urls: z.array(z.string()).min(1).max(5).describe("要抓取的网页 URL 列表(1-5 个)"),
|
||||
extractDepth: z.enum(["basic", "advanced"]).default("basic").describe("提取深度:basic 更快,advanced 更完整"),
|
||||
includeImages: z.boolean().default(false).describe("是否包含图片"),
|
||||
format: z.enum(["markdown", "json"]).default("markdown").describe("返回格式"),
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
export { webFetchTool };
|
||||
@@ -1,5 +1,5 @@
|
||||
import { tool } from 'langchain';
|
||||
import * as z from 'zod';
|
||||
import { tool } from "@langchain/core/tools";
|
||||
import { z } from "zod";
|
||||
import { safeFetch } from './http_client.js';
|
||||
|
||||
const BAIDU_MAP_HOST = 'api.map.baidu.com';
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
import { TavilySearch } from "@langchain/tavily";
|
||||
import { tool } from "@langchain/core/tools";
|
||||
import { z } from "zod";
|
||||
import config from "../../../../config.js";
|
||||
|
||||
const webSearchTool = tool(
|
||||
async ({
|
||||
query,
|
||||
maxResults = 5,
|
||||
topic = "general",
|
||||
includeRawContent = false,
|
||||
}) => {
|
||||
const tavilySearch = new TavilySearch({
|
||||
maxResults,
|
||||
tavilyApiKey: config.agent.tavily.apiKey,
|
||||
includeRawContent,
|
||||
topic,
|
||||
});
|
||||
return await tavilySearch._call({ query });
|
||||
},
|
||||
{
|
||||
name: "web_search",
|
||||
description:
|
||||
"联网搜索公开网页信息,返回摘要与链接。适合查询医院公示、就医政策、停诊/号源公告等时效性信息。",
|
||||
schema: z.object({
|
||||
query: z.string().describe("搜索关键词或问题"),
|
||||
maxResults: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(10)
|
||||
.optional()
|
||||
.default(5)
|
||||
.describe("返回结果数量(1-10),默认 5"),
|
||||
topic: z
|
||||
.enum(["general", "news", "finance"])
|
||||
.optional()
|
||||
.default("general")
|
||||
.describe("搜索主题,政策/新闻类查询建议用 news"),
|
||||
includeRawContent: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.default(false)
|
||||
.describe("是否返回网页原文(内容较长,默认关闭)"),
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
export { webSearchTool };
|
||||
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* Tavily 联网工具:搜索 + 网页正文提取。
|
||||
* 两个工具共用同一个 Tavily apiKey,合并在一个文件里便于维护。
|
||||
*/
|
||||
import { TavilySearch, TavilyExtract } from "@langchain/tavily";
|
||||
import { tool } from "@langchain/core/tools";
|
||||
import { z } from "zod";
|
||||
import config from "../../../../config.js";
|
||||
|
||||
const webSearchTool = tool(
|
||||
async ({ query, maxResults = 5, topic = "general", includeRawContent = false }) => {
|
||||
const tavilySearch = new TavilySearch({
|
||||
maxResults,
|
||||
tavilyApiKey: config.agent.tavily.apiKey,
|
||||
includeRawContent,
|
||||
topic,
|
||||
});
|
||||
return await tavilySearch._call({ query });
|
||||
},
|
||||
{
|
||||
name: "web_search",
|
||||
description:
|
||||
"联网搜索公开网页信息,返回摘要与链接。适合查询医院公示、就医政策、停诊/号源公告等时效性信息。",
|
||||
schema: z.object({
|
||||
query: z.string().describe("搜索关键词或问题"),
|
||||
maxResults: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(10)
|
||||
.optional()
|
||||
.default(5)
|
||||
.describe("返回结果数量(1-10),默认 5"),
|
||||
topic: z
|
||||
.enum(["general", "news", "finance"])
|
||||
.optional()
|
||||
.default("general")
|
||||
.describe("搜索主题,政策/新闻类查询建议用 news"),
|
||||
includeRawContent: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.default(false)
|
||||
.describe("是否返回网页原文(内容较长,默认关闭)"),
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
const webFetchTool = tool(
|
||||
async ({
|
||||
extractDepth = "basic",
|
||||
includeImages = false,
|
||||
format = "markdown",
|
||||
urls = [],
|
||||
}) => {
|
||||
const tavilyExtract = new TavilyExtract({
|
||||
tavilyApiKey: config.agent.tavily.apiKey,
|
||||
extractDepth,
|
||||
includeImages,
|
||||
format
|
||||
});
|
||||
return await tavilyExtract._call({ urls });
|
||||
},
|
||||
{
|
||||
name: "web_fetch",
|
||||
description:
|
||||
"抓取并提取指定网页的正文内容(默认 Markdown),适合阅读医院官网、政策公告、新闻等长文页面。",
|
||||
schema: z.object({
|
||||
urls: z.array(z.string()).min(1).max(5).describe("要抓取的网页 URL 列表(1-5 个)"),
|
||||
extractDepth: z.enum(["basic", "advanced"]).default("basic").describe("提取深度:basic 更快,advanced 更完整"),
|
||||
includeImages: z.boolean().default(false).describe("是否包含图片"),
|
||||
format: z.enum(["markdown", "json"]).default("markdown").describe("返回格式"),
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
export { webSearchTool, webFetchTool };
|
||||
@@ -249,8 +249,7 @@ EmployeeSchema.statics.findOnlineAttendants = async function (options = {}) {
|
||||
// ==================== 索引定义 ====================
|
||||
|
||||
EmployeeSchema.index({ "profile.name": 1 });
|
||||
EmployeeSchema.index({ employeeNo: 1 });
|
||||
EmployeeSchema.index({ userId: 1 });
|
||||
// 注意:employeeNo(unique+sparse)与 userId 的索引在字段定义处声明,勿在此重复声明
|
||||
EmployeeSchema.index({ orgId: 1, role: 1, status: 1 });
|
||||
EmployeeSchema.index({ role: 1, status: 1 });
|
||||
EmployeeSchema.index({ "profile.phone": 1 });
|
||||
|
||||
@@ -192,8 +192,6 @@ HealthProfileSchema.statics.deleteProfileById = async function (id) {
|
||||
};
|
||||
|
||||
// ==================== 索引定义 ====================
|
||||
|
||||
HealthProfileSchema.index({ userId: 1 }, { sparse: true });
|
||||
HealthProfileSchema.index({ "profile.mobile": 1 });
|
||||
// 注意:userId(sparse)与 profile.mobile 的索引在字段定义处声明,勿在此重复声明
|
||||
|
||||
export { HealthProfileSchema, genPinyin, genPinyinFL };
|
||||
@@ -196,8 +196,7 @@ OrganizationSchema.statics.updateOrg = async function (id, update) {
|
||||
|
||||
// ==================== 索引定义 ====================
|
||||
|
||||
OrganizationSchema.index({ name: 1 });
|
||||
OrganizationSchema.index({ code: 1 });
|
||||
// 注意:name 与 code(unique+sparse)的索引在字段定义处声明,勿在此重复声明
|
||||
OrganizationSchema.index({ type: 1, status: 1 });
|
||||
OrganizationSchema.index({ "address.city": 1, "address.district": 1 });
|
||||
OrganizationSchema.index({ status: 1 });
|
||||
|
||||
Reference in New Issue
Block a user