The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
community: fix issue with nested field extraction in MongodbLoader (#22801)
RUO2b87e330b0a8
diff --git a/libs/community/langchain_community/document_loaders/mongodb.py b/libs/community/langchain_community/document_loaders/mongodb.pyindex 57b4f35217..b1e0622265 100644--- a/libs/community/langchain_community/document_loaders/mongodb.py+++ b/libs/community/langchain_community/document_loaders/mongodb.py@@ -77,7 +77,19 @@ class MongodbLoader(BaseLoader):# Extract text content from filtered fields or use the entire documentif self.field_names is not None:- fields = {name: doc[name] for name in self.field_names}+ fields = {}+ for name in self.field_names:+ # Split the field names to handle nested fields+ keys = name.split(".")+ value = doc+ for key in keys:+ if key in value:+ value = value[key]+ else:+ value = ""+ break+ fields[name] = value+texts = [str(value) for value in fields.values()]text = " ".join(texts)else: