Files
AIclinicalresearch/backend/src/modules/rvw/services/promptProtocols.ts
HaHafeng ba464082cb feat(core): finalize rvw stability updates and pending module changes
Summary:
- Harden RVW prompt protocol handling and methodology review flow with 20-checkpoint coverage, divide-and-conquer execution, and timeout tuning
- Update RVW frontend methodology report rendering to show real structured outputs and grouped checkpoint sections
- Include pending backend/frontend updates across IIT admin, SSA, extraction forensics, and related integration files
- Sync system and RVW status documentation, deployment checklist, and RVW architecture/plan docs

Validation:
- Verified lint diagnostics for touched RVW backend/frontend files show no new errors
- Kept backup dump files and local test artifacts untracked

Made-with: Cursor
2026-03-14 00:00:04 +08:00

110 lines
3.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* RVW 提示词协议固化层(动静分离)
*
* 设计原则:
* - 动态部分(业务标准):来自 PromptService运营管理端可编辑
* - 静态部分(输出协议):由研发在代码中固化,运营端不可编辑
*/
export type RvwPromptChannel = 'editorial' | 'methodology' | 'clinical' | 'data_validation';
const RVW_PROTOCOLS: Record<RvwPromptChannel, string> = {
editorial: `【系统输出协议(研发固化,不可更改)】
请严格仅输出 JSON不要 Markdown、不要代码块、不要解释文字结构如下
{
"overall_score": 0,
"summary": "总体评价",
"items": [
{
"criterion": "检查项名称",
"status": "pass",
"score": 0,
"issues": ["问题1"],
"suggestions": ["建议1"]
}
]
}
约束:
1) overall_score、items[].score 必须是 0-100 数字
2) status 只能是 "pass" | "warning" | "fail"
3) issues/suggestions 必须是数组,无内容时返回 []
4) items 至少包含 1 项`,
methodology: `【系统输出协议(研发固化,不可更改)】
请严格仅输出 JSON不要 Markdown、不要代码块、不要解释文字结构如下
{
"overall_score": 0,
"summary": "总体评价",
"conclusion": "小修",
"checkpoints": [
{
"id": 1,
"item": "设计类型界定",
"status": "major_issue",
"finding": "该检查点的发现",
"suggestion": "可执行建议"
}
],
"parts": [
{
"part": "科研设计评估",
"score": 0,
"issues": [
{
"type": "问题类型",
"severity": "major",
"description": "问题描述",
"location": "位置方法学第2段",
"suggestion": "可执行修改建议"
}
]
}
]
}
约束:
1) overall_score、parts[].score 必须是 0-100 数字
2) severity 只能是 "major" 或 "minor"
3) 若某 part 无问题issues 返回 []
4) conclusion 必须是以下之一:"直接接收" | "小修" | "大修" | "拒稿"
5) 必须包含 "科研设计评估"、"统计学方法描述评估"、"统计分析与结果评估" 三个 part
6) checkpoints 必须严格包含 20 项id = 1..20 且不重复,不可缺失)
7) checkpoints[].status 只能是 "pass" | "minor_issue" | "major_issue" | "not_mentioned"
8) 若某检查点未发现问题finding 也要给出简短判断依据,不可空`,
clinical: `【系统输出协议(研发固化,不可更改)】
请严格按以下结构输出(可用 Markdown
1. 总体评价
2. 详细问题清单与建议(按“严重问题”“一般问题”分组)
3. 审稿结论(仅限:直接接收 / 小修 / 大修 / 拒稿)
要求:
- 用中文
- 不要输出与上述结构无关的前后缀话术`,
data_validation: `【系统输出协议(研发固化,不可更改)】
请逐表输出,每个表必须以“## 表N: <表格标题>”开头N 从 1 开始连续编号)。
每个表按以下结构输出:
1. 核心发现与问题清单
- 计算错误
- 方法误用
- 逻辑矛盾
- 规范性建议
2. 最终核查结论
- [ ] 通过
- [ ] 条件通过
- [ ] 未通过
注意:除上述结构外,不要输出无关前后缀。`,
};
/**
* 组装 RVW 最终系统提示词(动静分离)
*/
export function composeRvwSystemPrompt(channel: RvwPromptChannel, businessPrompt: string): string {
const protocol = RVW_PROTOCOLS[channel];
return `${businessPrompt}\n\n${protocol}`;
}
export function getRvwProtocol(channel: RvwPromptChannel): string {
return RVW_PROTOCOLS[channel];
}