Skip to content

The agent engineering platform.

Fix `GoogleEnterpriseSearchRetriever` (#10546)

Tom Piaggiod1f2075bde2d
diff --git a/libs/langchain/langchain/retrievers/google_cloud_enterprise_search.py b/libs/langchain/langchain/retrievers/google_cloud_enterprise_search.py
index 4e9c478d2b..faf10e1be7 100644
--- a/libs/langchain/langchain/retrievers/google_cloud_enterprise_search.py
+++ b/libs/langchain/langchain/retrievers/google_cloud_enterprise_search.py
@@ -156,7 +156,10 @@ class GoogleCloudEnterpriseSearchRetriever(BaseRetriever):
else "extractive_segments"
)
- for chunk in derived_struct_data.get(chunk_type, []):
+ if chunk_type not in derived_struct_data:
+ continue
+
+ for chunk in derived_struct_data[chunk_type]:
doc_metadata["source"] = derived_struct_data.get("link", "")
if chunk_type == "extractive_answers":