feat(prompts): prompt 版本化地基 —— 注册表 + 运行期文件覆盖

把散落各服务的硬编码 system prompt 收口为受管注册表,不重编译即可改/回滚/对比:
- shared/prompts:内置默认(随代码) + 运行期覆盖(PROMPTS_FILE) + Get/Keys,并发安全,含单测
- 接入 9 处:mcp-go(graph.extract);dispatcher(eval.quality/eval.refine/guard.jailbreak/
  coordinator.lead/memory.extract,按引用登记默认、无文本重复)
- main 启动调 LoadFile 加载 PROMPTS_FILE 覆盖
- live A/B:覆盖 graph.extract → 图谱抽取 2 条→0 条、向量仍正常(覆盖生效、管道未坏)
- v2(DB 控制面热切换 + 灰度)留后续

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Blizzard
2026-06-30 14:36:04 +08:00
parent 865a47eeea
commit 9a3a816c80
12 changed files with 196 additions and 9 deletions
+3 -1
View File
@@ -5,6 +5,8 @@ import (
"encoding/json"
"fmt"
"strings"
"github.com/sundynix/sundynix-shared/prompts"
)
// Result 是一次输出评测的结果。各分 ∈ [0,1]。
@@ -135,7 +137,7 @@ func (e *Evaluator) llmJudge(ctx context.Context, input, output string) (float64
user := fmt.Sprintf("【用户输入】%s\n\n【模型输出】%s\n\n%s\n\n"+
"只输出 JSON{\"score\":1到5整数,\"reason\":\"先点最主要的缺陷(没有就说无明显缺陷)再给结论,一句话\"},不要多余文字。",
evalTruncate(input, 500), evalReviewOutput(output), evalQualityRubric)
txt, err := e.chat(ctx, evalQualitySys, user)
txt, err := e.chat(ctx, prompts.Get(prompts.EvalQuality), user)
if err != nil {
return 0, "", false
}