test_prompts.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. from decimal import Decimal
  2. from finrep_algo_agent.prompts.builders import (
  3. build_outline_l1_user_prompt,
  4. build_outline_l2_user_prompt,
  5. build_section_user_prompt,
  6. )
  7. from finrep_algo_agent.schemas.outline import ChapterCandidate, OutlineL1Request, OutlineL2Request
  8. from finrep_algo_agent.schemas.section import SectionRequest
  9. def test_outline_l1_template_renders() -> None:
  10. req = OutlineL1Request(
  11. report_type="项目融资",
  12. agreement_amount=Decimal("100"),
  13. chapter_candidates=[ChapterCandidate(chapter_id="c1", chapter_name="测试章")],
  14. )
  15. text = build_outline_l1_user_prompt(req)
  16. assert "项目融资" in text
  17. assert "c1" in text
  18. assert "一级章节候选清单" in text
  19. def test_outline_l2_template_renders() -> None:
  20. l1 = OutlineL1Request(
  21. report_type="项目融资",
  22. agreement_amount=Decimal("50"),
  23. chapter_candidates=[],
  24. )
  25. req = OutlineL2Request(
  26. chapter_name="融资方案",
  27. chapter_no="3",
  28. chapter_paragraph_count_enum="P2",
  29. chapter_reason="保留",
  30. overall_logic="总逻辑",
  31. leaf_chapter_candidates=[{"name": "末级1", "知识单元类型": "单元呈现型"}],
  32. l1_task_snapshot=l1,
  33. )
  34. text = build_outline_l2_user_prompt(req)
  35. assert "融资方案" in text
  36. assert "末级1" in text
  37. assert "判断说明" in text
  38. def test_section_template_renders() -> None:
  39. req = SectionRequest(
  40. knowledge_unit_id="ku1",
  41. report_type="财务顾问",
  42. template_type="info",
  43. overall_logic="整体",
  44. chapter_logic="章逻辑",
  45. paragraph_position="定位",
  46. task_input={"a": 1},
  47. data_package={"b": 2},
  48. paragraph_logic="撰写",
  49. )
  50. text = build_section_user_prompt(req)
  51. assert "财务顾问" in text
  52. assert "撰写" in text