Skip to content

The agent engineering platform.

community: Fix all page numbers were the same for _BaseGoogleVertexAISearchRetriever (#19175)

k.muto8d2c34e655fa
diff --git a/libs/community/langchain_community/retrievers/google_vertex_ai_search.py b/libs/community/langchain_community/retrievers/google_vertex_ai_search.py
index b4d13203ef..78595a00cb 100644
--- a/libs/community/langchain_community/retrievers/google_vertex_ai_search.py
+++ b/libs/community/langchain_community/retrievers/google_vertex_ai_search.py
@@ -137,14 +137,15 @@ class _BaseGoogleVertexAISearchRetriever(BaseModel):
continue
for chunk in derived_struct_data[chunk_type]:
- doc_metadata["source"] = derived_struct_data.get("link", "")
+ chunk_metadata = doc_metadata.copy()
+ chunk_metadata["source"] = derived_struct_data.get("link", "")
if chunk_type == "extractive_answers":
- doc_metadata["source"] += f":{chunk.get('pageNumber', '')}"
+ chunk_metadata["source"] += f":{chunk.get('pageNumber', '')}"
documents.append(
Document(
- page_content=chunk.get("content", ""), metadata=doc_metadata
+ page_content=chunk.get("content", ""), metadata=chunk_metadata
)
)