Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion redisvl/extensions/cache/llm/semantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ async def acheck(
num_results=num_results,
return_score=True,
filter_expression=filter_expression,
normalize_vector_distance=True,
dtype=self._vectorizer.dtype,
)

# Search the cache!
Expand Down
23 changes: 23 additions & 0 deletions tests/integration/test_llmcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,29 @@ async def test_async_store_and_check(cache, vectorizer):
assert "metadata" not in check_result[0]


@pytest.mark.asyncio
async def test_check_acheck_consistency(cache, vectorizer):
"""Test that acheck and check return the same results."""
cache.store(
prompt="Who is the CEO?",
response="John Smith",
)

prompt = "Who is CEO?"
sync_result = cache.check(prompt=prompt)
async_result = await cache.acheck(prompt=prompt)
print(sync_result, async_result, flush=True)
assert sync_result # Both should return a result
assert sync_result == async_result

prompt = "Who is CFO?"
sync_result = cache.check(prompt=prompt)
async_result = await cache.acheck(prompt=prompt)
print(sync_result, async_result, flush=True)
assert not sync_result # Both should return no result
assert sync_result == async_result


def test_return_fields(cache, vectorizer):
prompt = "This is a test prompt."
response = "This is a test response."
Expand Down