Skip to content

Commit

Permalink
LangChain-Community - AzureCosmos Mongo vCore: Bug Fix when the data …
Browse files Browse the repository at this point in the history
…doesn't contain metadata field (#27772)

Thank you for contributing to LangChain!
- **Description:** Adding an empty metadata field when metadata is not
present in the data
- **Issue:** This PR fixes the issue when the data items doesn't contain
the metadata field. This happens when there is already data in the
container, or cx uses CosmosDB Python SDK to insert data.
- **Dependencies:** No dependencies required

Additional guidelines:
- Make sure optional dependencies are imported within a function.
- Please do not add dependencies to pyproject.toml files (even optional
ones) unless they are required for unit tests.
- Most PRs should not touch more than one package.
- Changes should be backwards compatible.
- If you are adding something to community, do not re-import it in
langchain.

If no one reviews your PR within a few days, please @-mention one of
baskaryan, efriis, eyurtsev, ccurme, vbarda, hwchase17.
  • Loading branch information
aayush3011 authored Oct 31, 2024
1 parent 8d8d853 commit a8a33b2
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ def _similarity_search_with_score(
continue
document_object_field = res.pop("document")
text = document_object_field.pop(self._text_key)
metadata = document_object_field.pop("metadata")
metadata = document_object_field.pop("metadata", {})
if with_embedding:
metadata[self._embedding_key] = document_object_field.pop(
self._embedding_key
Expand Down

0 comments on commit a8a33b2

Please sign in to comment.