Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
StanChan03 committed Dec 27, 2024
1 parent 0de3d6e commit e403921
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions .github/tests/lm_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,10 @@ def test_operator_cache(setup_models, model):
pd.testing.assert_frame_equal(result_1, expected_response)
pd.testing.assert_frame_equal(result_2, expected_response)

lm.reset_cache()
lm.reset_stats()
assert lm.stats.total_usage.operator_cache_hits == 0


@pytest.mark.parametrize("model", get_enabled("gpt-4o-mini"))
def test_disable_operator_cache(setup_models, model):
Expand Down Expand Up @@ -573,9 +577,11 @@ def test_disable_operator_cache(setup_models, model):

# Now enable operator cache.
lotus.settings.configure(enable_operator_cache=True)
first_responses = df.sem_map(user_instruction)["_map"].str.replace(r"[^a-zA-Z\s]", "", regex=True)
first_responses = df.sem_map(user_instruction)
first_responses = first_responses[first_responses["_map"].str.replace(r"[^a-zA-Z\s]", "", regex=True)]
assert lm.stats.total_usage.operator_cache_hits == 0
second_responses = df.sem_map(user_instruction)["_map"].str.replace(r"[^a-zA-Z\s]", "", regex=True)
second_responses = df.sem_map(user_instruction)
second_responses = second_responses[second_responses["_map"].str.replace(r"[^a-zA-Z\s]", "", regex=True)]
assert lm.stats.total_usage.operator_cache_hits == 1

pd.testing.assert_frame_equal(first_responses, second_responses)
Expand Down

0 comments on commit e403921

Please sign in to comment.