Skip to content

Commit

Permalink
adds test coverage for messages property
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-cechmanek committed Jun 17, 2024
1 parent d666fad commit 158eb52
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/integration/test_session_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,26 @@ def test_standard_add_messages(standard_session):
]


def test_standard_messages_property(standard_session):
standard_session.add_messages(
[
{"role": "user", "content": "first prompt"},
{"role": "llm", "content": "first response"},
{"role": "user", "content": "second prompt"},
{"role": "llm", "content": "second response"},
{"role": "user", "content": "third prompt"},
]
)

assert standard_session.messages == [
{"role": "user", "content": "first prompt"},
{"role": "llm", "content": "first response"},
{"role": "user", "content": "second prompt"},
{"role": "llm", "content": "second response"},
{"role": "user", "content": "third prompt"},
]


def test_standard_set_scope(standard_session, app_name, user_tag, session_tag):
# test calling set_scope with no params does not change scope
current_key = standard_session.key
Expand Down Expand Up @@ -443,6 +463,30 @@ def test_semantic_store_and_get_recent(semantic_session):
bad_context = semantic_session.get_recent(top_k="3")


def test_semantic_messages_property(semantic_session):
semantic_session.add_messages(
[
{"role": "user", "content": "first prompt"},
{"role": "llm", "content": "first response"},
{"role": "user", "content": "second prompt"},
{"role": "llm", "content": "second response"},
{"role": "user", "content": "third prompt"},
{"role": "llm", "content": "fourth response"},
{"role": "user", "content": "fourth prompt"},
]
)

assert semantic_session.messages == [
{"role": "user", "content": "first prompt"},
{"role": "llm", "content": "first response"},
{"role": "user", "content": "second prompt"},
{"role": "llm", "content": "second response"},
{"role": "user", "content": "third prompt"},
{"role": "llm", "content": "fourth response"},
{"role": "user", "content": "fourth prompt"},
]


def test_semantic_store_and_get_relevant(semantic_session):
semantic_session.add_message(
{"role": "system", "content": "discussing common fruits and vegetables"}
Expand Down

0 comments on commit 158eb52

Please sign in to comment.