From d1f2075bde2db98c2667ad93f2208d33168b61de Mon Sep 17 00:00:00 2001 From: Tom Piaggio Date: Wed, 13 Sep 2023 15:45:07 -0300 Subject: [PATCH] Fix `GoogleEnterpriseSearchRetriever` (#10546) Replace this entire comment with: - Description: fixed Google Enterprise Search Retriever where it was consistently returning empty results, - Issue: related to [issue 8219](https://github.com/langchain-ai/langchain/issues/8219), - Dependencies: no dependencies, - Tag maintainer: @hwchase17 , - Twitter handle: [Tomas Piaggio](https://twitter.com/TomasPiaggio)! --- .../langchain/retrievers/google_cloud_enterprise_search.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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":