test_answer_prompt_static.py 1.05 KB
import unittest


from src.rag.retrieval.answer import _answer_system_prompt


class AnswerPromptStaticTest(unittest.TestCase):
    def test_prompt_aligns_with_llm_query_answer_templates(self):
        prompt = _answer_system_prompt()

        required_phrases = [
            "【差异化回答格式】",
            "scripts(话术类)",
            "troubleshooting(系统排障类)",
            "policies(政策/合规红线类)",
            "products(产品类)",
            "procedures(流程/SOP 类)",
            "comparisons / synthesis(对比分析/综合类)",
            "concepts(概念类)",
            "当前知识库中暂无关于「{关键词}」的 {意图类型} 信息。",
            "类型:{推荐的页面 type,如 scripts / products / policies}",
            "路径建议:raw/sources/{品牌}/{文档名}.md",
        ]

        for phrase in required_phrases:
            with self.subTest(phrase=phrase):
                self.assertIn(phrase, prompt)


if __name__ == "__main__":
    unittest.main()