Prioritize doctor instructions in AI report prompts

- Extract AI prompt construction into a tested utility for report editor generation.

- Make doctor instructions and structured report fields higher priority than old template body and target-region HTML.

- Tell the AI not to carry over default gallbladder or liver descriptions when the doctor asks for another procedure or body part.

- Limit old full-report context length to reduce anchoring on default template content.

- Update README, AGENTS, report editor, design, progress, and testing docs for the AI prompt priority model.

- Add unit tests covering AI prompt priority and old-content truncation.
This commit is contained in:
2026-05-02 04:39:18 +08:00
parent 44decaa396
commit 55622368e3
9 changed files with 129 additions and 8 deletions

View File

@@ -90,7 +90,7 @@ src/
- `data-mode="frame"` 或无 `manual` 标记的占位符可接收关键帧。
- `data-mode="manual"` 用于 Logo、签名等静态图片不接收视频关键帧拖入。
AI 可编辑区域通过 `.ai-region[data-ai-id]` 和内部 `.ai-content` 定位。AI 返回 `updatedHtml` 后,系统先显示差异确认,再注入目标区域。
AI 可编辑区域通过 `.ai-region[data-ai-id]` 和内部 `.ai-content` 定位。AI 返回 `updatedHtml` 后,系统先显示差异确认,再注入目标区域。AI prompt 会把医生指令和结构化报告字段放在最高优先级,旧目标区域 HTML 和整份报告正文只作为低优先级参考,避免默认模板中的旧术式描述持续影响新生成内容。
## 打印导出设计

View File

@@ -71,6 +71,16 @@ AI 面板支持两种模式:
- 对话模式:根据当前报告内容和图片上下文回答问题。
- 修改模式:选中 `.ai-region` 后要求模型返回 JSON其中包含 `reply``updatedHtml`
AI 提议版本由以下内容生成:
- 医生在 AI 输入框中的指令。
- 当前结构化报告字段,包括手术名称、术前诊断、术中/术后诊断、麻醉方式和报告备注。
- 整份报告正文文本,作为低优先级上下文。
- 当前选中的 AI 可编辑区域 HTML作为低优先级格式和旧内容参考。
- 用户选择的报告图片或上传给 AI 的图片。
Prompt 明确规定优先级为:医生指令 > 当前结构化报告字段 > 图片内容 > 旧目标区域/整份报告正文。默认模板中的胆囊、肝脏等旧术式描述不得覆盖医生新指令如果医生要求生成新的术式或不同部位AI 应围绕新术式重写目标区域。
编辑器会监听正文中的 `.ai-region` 变化;用户插入新的 AI 可编辑区域后AI 撰写面板的目标下拉栏会立即更新,不需要离开页面或刷新。
模型返回 HTML 后,系统会清理换行和 `<br>`,生成差异预览。用户确认后才写入目标 `.ai-content`

View File

@@ -89,3 +89,4 @@
| 2026-05-02 | 修复报告编辑器新增 AI 可编辑区域后 AI 撰写下拉栏不立即更新的问题,并补充 E2E。 |
| 2026-05-02 | 移除前端用户可见 JSON 导出入口,保留模板历史 JSON 导入兼容。 |
| 2026-05-02 | 模板 HTML 导出包补充模板字段和字段管理设置,导入时恢复字段库元数据。 |
| 2026-05-02 | 调整报告编辑器 AI Prompt 优先级,医生指令和结构化报告字段优先于默认模板旧术式内容。 |

View File

@@ -82,6 +82,7 @@ AI 第三方接口、讯飞语音上游 WebSocket、麦克风权限和真实视
| 系统设置混淆兼容 | 已覆盖 | `storage.test.ts` |
| 默认报告模板结构 | 已覆盖 | `defaultContent.test.ts` |
| 默认字段和 AI Provider | 已覆盖 | `defaultContent.test.ts` |
| AI Prompt 优先级 | 已覆盖 | `aiPrompt.test.ts`,覆盖医生指令和结构化字段优先于旧模板内容。 |
| 打印导出入口 | 已覆盖 | `print.test.ts` |
| 模板列表合并工具 | 已覆盖 | `templateList.test.ts`,防止新增模板被旧本地缓存覆盖。 |
| 模板导入导出工具 | 已覆盖 | `templateExport.test.ts`,覆盖 HTML 模板包、字段库元数据回导、旧 JSON 导入兼容和文件名清理。 |