Remove None default value for FAISS relevance_score_fn (#7085)

## Description

The type hint for `FAISS.__init__()`'s `relevance_score_fn` parameter
allowed the parameter to be set to `None`. However, a default function
is provided by the constructor. This led to an unnecessary check in the
code, as well as a test to verify this check.

**ASSUMPTION**: There's no reason to ever set `relevance_score_fn` to
`None`.

This PR changes the type hint and removes the unnecessary code.
This commit is contained in:
Mike Salvatore
2023-07-03 12:11:49 -04:00
committed by GitHub
parent 719316e84c
commit d0c7f7c317
2 changed files with 1 additions and 17 deletions

View File

@@ -195,12 +195,3 @@ def test_faiss_invalid_normalize_fn() -> None:
)
with pytest.warns(Warning, match="scores must be between"):
docsearch.similarity_search_with_relevance_scores("foo", k=1)
def test_missing_normalize_score_fn() -> None:
"""Test doesn't perform similarity search without a normalize score function."""
with pytest.raises(ValueError):
texts = ["foo", "bar", "baz"]
faiss_instance = FAISS.from_texts(texts, FakeEmbeddings())
faiss_instance.relevance_score_fn = None
faiss_instance.similarity_search_with_relevance_scores("foo", k=2)