diff --git a/sdks/python/apache_beam/ml/rag/enrichment/milvus_search.py b/sdks/python/apache_beam/ml/rag/enrichment/milvus_search.py index a0f597f5366f..e35d31cc8a5d 100644 --- a/sdks/python/apache_beam/ml/rag/enrichment/milvus_search.py +++ b/sdks/python/apache_beam/ml/rag/enrichment/milvus_search.py @@ -417,6 +417,9 @@ def __enter__(self): def __call__(self, request: Union[Chunk, List[Chunk]], *args, **kwargs) -> List[Tuple[Chunk, Dict[str, Any]]]: reqs = request if isinstance(request, list) else [request] + # Early return for empty requests to avoid unnecessary connection attempts + if not reqs: + return [] search_result = self._search_documents(reqs) return self._get_call_response(reqs, search_result)