Skip to content

Commit

Permalink
Remove embeddings from results + cleanup comments
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahStapp committed Dec 18, 2023
1 parent 8169c90 commit 2e929bd
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions libs/community/langchain_community/vectorstores/mongodb_atlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ def _similarity_search_with_score(
for res in cursor:
text = res.pop(self._text_key)
score = res.pop("score")
del res["embedding"]
docs.append((Document(page_content=text, metadata=res), score))
return docs

Expand All @@ -205,20 +206,16 @@ def similarity_search_with_score(
) -> List[Tuple[Document, float]]:
"""Return MongoDB documents most similar to the given query and their scores.
Uses the knnBeta Operator available in MongoDB Atlas Search.
This feature is in early access and available only for evaluation purposes, to
validate functionality, and to gather feedback from a small closed group of
early access users. It is not recommended for production deployments as we
may introduce breaking changes.
For more: https://www.mongodb.com/docs/atlas/atlas-search/knn-beta
Uses the vectorSearch operator available in MongoDB Atlas Search.
For more: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/
Args:
query: Text to look up documents similar to.
k: (Optional) number of documents to return. Defaults to 4.
pre_filter: (Optional) dictionary of argument(s) to prefilter document
fields on.
post_filter_pipeline: (Optional) Pipeline of MongoDB aggregation stages
following the knnBeta vector search.
following the vectorSearch stage.
Returns:
List of documents most similar to the query and their scores.
Expand All @@ -242,20 +239,16 @@ def similarity_search(
) -> List[Document]:
"""Return MongoDB documents most similar to the given query.
Uses the knnBeta Operator available in MongoDB Atlas Search.
This feature is in early access and available only for evaluation purposes, to
validate functionality, and to gather feedback from a small closed group of
early access users. It is not recommended for production deployments as we
may introduce breaking changes.
For more: https://www.mongodb.com/docs/atlas/atlas-search/knn-beta
Uses the vectorSearch operator available in MongoDB Atlas Search.
For more: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/
Args:
query: Text to look up documents similar to.
k: (Optional) number of documents to return. Defaults to 4.
pre_filter: (Optional) dictionary of argument(s) to prefilter document
fields on.
post_filter_pipeline: (Optional) Pipeline of MongoDB aggregation stages
following the knnBeta vector search.
following the vectorSearch stage.
Returns:
List of documents most similar to the query and their scores.
Expand Down Expand Up @@ -300,7 +293,7 @@ def max_marginal_relevance_search(
pre_filter: (Optional) dictionary of argument(s) to prefilter on document
fields.
post_filter_pipeline: (Optional) pipeline of MongoDB aggregation stages
following the knnBeta vector search.
following the vectorSearch stage.
Returns:
List of documents selected by maximal marginal relevance.
"""
Expand Down

0 comments on commit 2e929bd

Please sign in to comment.