Skip to content

Commit ff504ed

Browse files
committed
Fix: prevent VertexAiRagRetrieval from blocking event loop
1 parent f973673 commit ff504ed

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/google/adk/tools/retrieval/vertex_ai_rag_retrieval.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from __future__ import annotations
1818

1919
import logging
20+
import asyncio
2021
from typing import Any
2122
from typing import TYPE_CHECKING
2223

@@ -94,13 +95,13 @@ async def run_async(
9495
) -> Any:
9596
from ...dependencies.vertexai import rag
9697

97-
response = rag.retrieval_query(
98+
response = asyncio.to_thread(rag.retrieval_query(
9899
text=args['query'],
99100
rag_resources=self.vertex_rag_store.rag_resources,
100101
rag_corpora=self.vertex_rag_store.rag_corpora,
101102
similarity_top_k=self.vertex_rag_store.similarity_top_k,
102103
vector_distance_threshold=self.vertex_rag_store.vector_distance_threshold,
103-
)
104+
))
104105

105106
logging.debug('RAG raw response: %s', response)
106107

0 commit comments

Comments
 (0)