mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-28 17:38:36 +00:00
add tests to redis vectorstore (#8116)
# What - Add function to get similarity with score with threshold in Redis vector store. - Add tests to Redis vector store.
This commit is contained in:
parent
c19a0b9c10
commit
de61ebd9e0
@ -124,3 +124,38 @@ def test_ip(texts: List[str]) -> None:
|
|||||||
_, score = output[1]
|
_, score = output[1]
|
||||||
assert score == IP_SCORE
|
assert score == IP_SCORE
|
||||||
assert drop(docsearch.index_name)
|
assert drop(docsearch.index_name)
|
||||||
|
|
||||||
|
|
||||||
|
def test_similarity_search_limit_score(texts: List[str]) -> None:
|
||||||
|
"""Test similarity search limit score."""
|
||||||
|
docsearch = Redis.from_texts(
|
||||||
|
texts, FakeEmbeddings(), redis_url=TEST_REDIS_URL, distance_metric="COSINE"
|
||||||
|
)
|
||||||
|
output = docsearch.similarity_search_limit_score("far", k=2, score_threshold=0.1)
|
||||||
|
assert len(output) == 1
|
||||||
|
_, score = output[0]
|
||||||
|
assert score == COSINE_SCORE
|
||||||
|
assert drop(docsearch.index_name)
|
||||||
|
|
||||||
|
|
||||||
|
def test_similarity_search_with_score_with_limit_score(texts: List[str]) -> None:
|
||||||
|
"""Test similarity search with score with limit score."""
|
||||||
|
docsearch = Redis.from_texts(
|
||||||
|
texts, FakeEmbeddings(), redis_url=TEST_REDIS_URL, distance_metric="COSINE"
|
||||||
|
)
|
||||||
|
output = docsearch.similarity_search_with_relevance_scores(
|
||||||
|
"far", k=2, score_threshold=0.1
|
||||||
|
)
|
||||||
|
assert len(output) == 1
|
||||||
|
_, score = output[0]
|
||||||
|
assert score == COSINE_SCORE
|
||||||
|
assert drop(docsearch.index_name)
|
||||||
|
|
||||||
|
|
||||||
|
def test_delete(texts: List[str]) -> None:
|
||||||
|
"""Test deleting a new document"""
|
||||||
|
docsearch = Redis.from_texts(texts, FakeEmbeddings(), redis_url=TEST_REDIS_URL)
|
||||||
|
ids = docsearch.add_texts(["foo"])
|
||||||
|
got = docsearch.delete(ids=ids)
|
||||||
|
assert got
|
||||||
|
assert drop(docsearch.index_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user