Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests to show that the excess turns are discarded when creating the readable tracker #12924

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions tests/shared/utils/test_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,49 @@ def test_tracker_as_readable_transcript_handles_tracker_with_events_and_max_turn
assert tracker_as_readable_transcript(tracker, max_turns=1) == ("""AI: hi""")


def test_tracker_as_readable_transcript_and_discard_excess_turns_with_default_max_turns(
domain: Domain,
):
tracker = DialogueStateTracker(sender_id="test", slots=domain.slots)
tracker.update_with_events(
[
UserUttered("A0"),
BotUttered("B1"),
UserUttered("C2"),
BotUttered("D3"),
UserUttered("E4"),
BotUttered("F5"),
UserUttered("G6"),
BotUttered("H7"),
UserUttered("I8"),
BotUttered("J9"),
UserUttered("K10"),
BotUttered("L11"),
UserUttered("M12"),
BotUttered("N13"),
UserUttered("O14"),
BotUttered("P15"),
UserUttered("Q16"),
BotUttered("R17"),
UserUttered("S18"),
BotUttered("T19"),
UserUttered("U20"),
BotUttered("V21"),
UserUttered("W22"),
BotUttered("X23"),
UserUttered("Y24"),
],
domain,
)
response = tracker_as_readable_transcript(tracker)
assert response == (
"""AI: F5\nUSER: G6\nAI: H7\nUSER: I8\nAI: J9\nUSER: K10\nAI: L11\n"""
"""USER: M12\nAI: N13\nUSER: O14\nAI: P15\nUSER: Q16\nAI: R17\nUSER: S18\n"""
"""AI: T19\nUSER: U20\nAI: V21\nUSER: W22\nAI: X23\nUSER: Y24"""
)
assert response.count("\n") == 19


def test_sanitize_message_for_prompt_handles_none():
assert sanitize_message_for_prompt(None) == ""

Expand Down
Loading