Skip to content

Commit

Permalink
Test formatted history from Granite (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
tisnik authored Jan 27, 2025
1 parent 9ec4e1f commit 3ed25b7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/unit/utils/test_token_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from langchain_core.messages import AIMessage, HumanMessage

from ols.constants import TOKEN_BUFFER_WEIGHT, ModelFamily
from ols.src.prompts.prompt_generator import restructure_history
from ols.utils.token_handler import PromptTooLongError, TokenHandler
from tests.mock_classes.mock_retrieved_node import MockRetrievedNode

Expand Down Expand Up @@ -282,3 +283,12 @@ def test_limit_conversation_history(self):
# history should truncate to empty list and flag should be True
assert truncated_history == []
assert truncated

# Test formatted history for granite
model = ModelFamily.GRANITE
truncated_history, truncated = (
self._token_handler_obj.limit_conversation_history(history, model, 22)
)
assert len(truncated_history) == 1
assert truncated_history[-1] == restructure_history(history[-1], model)
assert truncated

0 comments on commit 3ed25b7

Please sign in to comment.