Skip to content

Commit

Permalink
community[minor]: Neo4j Fixed similarity docs (#23913)
Browse files Browse the repository at this point in the history
**Description:** There was missing some documentation regarding the
`filter` and `params` attributes in similarity search methods.

---------

Co-authored-by: rpereira <rafael.pereira@criticalsoftware.com>
  • Loading branch information
RafaelXokito and RafaelXokito authored Jul 11, 2024
1 parent 10d8c3c commit 092e9ee
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion libs/community/langchain_community/vectorstores/neo4j_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,11 @@ def similarity_search(
Args:
query (str): Query text to search for.
k (int): Number of results to return. Defaults to 4.
params (Dict[str, Any]): The search params for the index type.
Defaults to empty dict.
filter (Optional[Dict[str, Any]]): Dictionary of argument(s) to
filter on metadata.
Defaults to None.
Returns:
List of Documents most similar to the query.
Expand Down Expand Up @@ -936,6 +941,11 @@ def similarity_search_with_score(
Args:
query: Text to look up documents similar to.
k: Number of Documents to return. Defaults to 4.
params (Dict[str, Any]): The search params for the index type.
Defaults to empty dict.
filter (Optional[Dict[str, Any]]): Dictionary of argument(s) to
filter on metadata.
Defaults to None.
Returns:
List of Documents most similar to the query and score for each
Expand Down Expand Up @@ -972,6 +982,11 @@ def similarity_search_with_score_by_vector(
Args:
embedding (List[float]): The embedding vector to compare against.
k (int, optional): The number of top similar documents to retrieve.
filter (Optional[Dict[str, Any]]): Dictionary of argument(s) to
filter on metadata.
Defaults to None.
params (Dict[str, Any]): The search params for the index type.
Defaults to empty dict.
Returns:
List[Tuple[Document, float]]: A list of tuples, each containing
Expand Down Expand Up @@ -1077,19 +1092,25 @@ def similarity_search_by_vector(
embedding: List[float],
k: int = 4,
filter: Optional[Dict[str, Any]] = None,
params: Dict[str, Any] = {},
**kwargs: Any,
) -> List[Document]:
"""Return docs most similar to embedding vector.
Args:
embedding: Embedding to look up documents similar to.
k: Number of Documents to return. Defaults to 4.
filter (Optional[Dict[str, Any]]): Dictionary of argument(s) to
filter on metadata.
Defaults to None.
params (Dict[str, Any]): The search params for the index type.
Defaults to empty dict.
Returns:
List of Documents most similar to the query vector.
"""
docs_and_scores = self.similarity_search_with_score_by_vector(
embedding=embedding, k=k, filter=filter, **kwargs
embedding=embedding, k=k, filter=filter, params=params, **kwargs
)
return [doc for doc, _ in docs_and_scores]

Expand Down

0 comments on commit 092e9ee

Please sign in to comment.