Spaces:
Running
Running
| from app.pipeline.nodes.generate import _format_history | |
| def test_format_history_uses_summary_when_present() -> None: | |
| state = { | |
| "conversation_summary": "User asked about PersonaBot architecture and caching.", | |
| "conversation_history": [ | |
| {"q": "Q1", "a": "A1"}, | |
| {"q": "Q2", "a": "A2"}, | |
| ], | |
| } | |
| rendered = _format_history(state) | |
| assert "Running conversation context:" in rendered | |
| assert "PersonaBot architecture" in rendered | |
| assert "Q1" not in rendered | |
| def test_format_history_caps_raw_history_to_three_turns() -> None: | |
| state = { | |
| "conversation_summary": None, | |
| "conversation_history": [ | |
| {"q": "Q1", "a": "A1"}, | |
| {"q": "Q2", "a": "A2"}, | |
| {"q": "Q3", "a": "A3"}, | |
| {"q": "Q4", "a": "A4"}, | |
| ], | |
| } | |
| rendered = _format_history(state) | |
| assert "Q1" not in rendered | |
| assert "Q2" in rendered | |
| assert "Q3" in rendered | |
| assert "Q4" in rendered | |