fuzhengwei / fuzhengwei/WaLiAPI

Prompt 模板版本化:表存储 + 源码字面量种子 + 版本管理页

Open
#89 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
128
Forks
39
Avg merge
15h 25m
Merged PRs (30d)
44

Description

### 现状

RAG 系统提示词硬编码于源码——经核实实为 **7 处**(4 个固定 system 词 + 3 个带命名占位符的模板:深度研究轮次×2 + 综合模板),改一个词 = 发一个版本;无版本、无回滚、无审计。

### 方案

- `prompt_templates` 表(key+version 唯一、active 标记,迁移 034);**启动种子**:按 key 检测空表则把源码字面量**逐字节**写入 v1 并激活——升级后 RAG 行为与升级前完全一致(硬保证,测试断言逐字节一致 + 幂等)。
- 运行时按 key+active 读取;表损坏/清空/读取失败回退编译期默认(双保险,服务不中断)。
- **占位符校验**:模板必须恰好包含该 key 声明的全部命名占位符(缺 = 渲染丢上下文,多 = 留残片),非法拒绝创建/激活。
- 管理页 `/prompt-templates`:按 key 分组列版本、当前激活高亮、编辑保存新版本、一键激活/回滚;变更写请求日志(mode=prompt_admin)可追溯。命令 Tauri + Web invoke 双注册。
- 首批 7 个 key:RAG 问答系统词、研究查询生成、深度研究系统词×3、轮次模板×2、综合模板。渠道转发类内容是用户请求的一部分,不属于系统模板,不纳入。

### 测试

种子逐字节一致 + 幂等、激活切换与回滚立即生效 + 激活行唯一性(事务)、空表/清空回退编译期默认、非法占位符拒绝(未知占位/缺失/未知 key)、命名占位符渲染、管理列表排序与字段往返。

### 开放点

1. **Wiki 方案对比**:Wiki 引擎已支持版本化页面,prompt 模板可做成特殊 Wiki 页面复用其版本化 UI——代价是引入 Wiki 依赖,收益是零新页面。本 PR 用独立表,请维护者定夺。
2. 模板 key 集是否需要贡献指南(新 prompt 进表的流程)。

---
对应分支:`feat/capability-c07-prompt-templates`(迁移 034)。

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with migration 034, the seven hard-coded prompt literals, and the /prompt-templates entry point; then trace the Tauri command and Web invoke registrations. Review the tests listed in the issue first. Done means versioned storage, byte-identical idempotent seeding, safe fallback, placeholder validation, activation and rollback, and the management page with request logging.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, rust, tauri
Domain
backend, database, desktop, frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.