Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/google/adk/tools/retrieval/vertex_ai_rag_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from __future__ import annotations

import logging
import asyncio
from typing import Any
from typing import TYPE_CHECKING

Expand Down Expand Up @@ -94,13 +95,13 @@ async def run_async(
) -> Any:
from ...dependencies.vertexai import rag

response = rag.retrieval_query(
response = asyncio.to_thread(rag.retrieval_query(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current fix will still block the event loop because the function is being executed immediately inside the parentheses, and it’s also missing an await to actually get the response back.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! sorry, late debug 😅 Should be better now!

text=args['query'],
rag_resources=self.vertex_rag_store.rag_resources,
rag_corpora=self.vertex_rag_store.rag_corpora,
similarity_top_k=self.vertex_rag_store.similarity_top_k,
vector_distance_threshold=self.vertex_rag_store.vector_distance_threshold,
)
))

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

Expand Down
Loading