feat: load question expansion prompts from yaml
Deployment Config CI / Deployment Config (push) Successful in 27s
Backend CI / Backend (push) Successful in 16m5s

This commit is contained in:
2026-05-13 20:24:51 +08:00
parent 8890cd1ca4
commit 34ef5873ca
9 changed files with 190 additions and 49 deletions
+36 -4
View File
@@ -66,16 +66,48 @@ func TestAnalyzeFallbackPromptPrefersQuestionLikeQueries(t *testing.T) {
prompt := AnalyzeFallbackPrompt(`{"brand_name":"测试品牌","input_params":{"keyword":"全屋定制"}}`)
for _, want := range []string{
"真实用户会直接搜索的问题型长尾词",
"哪家好",
"最多返回 6 个竞品和 10 个搜索问题候选",
} {
"真实用户会直接搜索的问题型长尾词",
"哪家好",
"最多返回 6 个竞品和 10 个搜索问题候选",
} {
if !strings.Contains(prompt, want) {
t.Fatalf("AnalyzeFallbackPrompt() missing %q in prompt:\n%s", want, prompt)
}
}
}
func TestQuestionExpansionPromptsLoadFromYaml(t *testing.T) {
SetConfigFile("")
t.Cleanup(func() {
SetConfigFile("")
})
distillPrompt := QuestionDistillPrompt("测试品牌", `["竞品A"]`, "全屋定制")
for _, want := range []string{
"AI 搜索里真实会问的问题",
"当前品牌: 测试品牌",
`竞品列表: ["竞品A"]`,
"主题: 全屋定制",
} {
if !strings.Contains(distillPrompt, want) {
t.Fatalf("QuestionDistillPrompt() missing %q in prompt:\n%s", want, distillPrompt)
}
}
fillPrompt := QuestionCombinationFillPrompt("测试品牌", "https://example.com", "品牌描述", `["竞品A"]`, "合肥、华东", `{"core":["装修"]}`)
for _, want := range []string{
"拓词工具",
"品牌: 测试品牌",
"官网: https://example.com",
"合肥、华东",
`{"core":["装修"]}`,
} {
if !strings.Contains(fillPrompt, want) {
t.Fatalf("QuestionCombinationFillPrompt() missing %q in prompt:\n%s", want, fillPrompt)
}
}
}
func TestPromptConfigReloadsAndKeepsLastGoodVersion(t *testing.T) {
SetConfigFile("")
defaultPath := resolvePromptsConfigFile()