You've already forked adk-python
mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: lazy import VertexAiRagRetrieval
original codes try to eagerly import VertexAiRagRetrieval while it doesn't want to raise error if client try to import other names in this package and dependencies of VertexAiRagRetrieval is missing. so it swallow the import error which doesn't make sense, given vertex sdk is a must have for VertexAiRagRetrieval, we should fail fast. this fix achieve the same purpose but fail fast if client try to import VertexAiRagRetrieval from this package and miss certain dependencies (e.g. vertex sdk) PiperOrigin-RevId: 791759776
This commit is contained in:
committed by
Copybara-Service
parent
1686cc57c2
commit
e528749a1c
@@ -20,17 +20,13 @@ __all__ = [
|
||||
'BaseRetrievalTool',
|
||||
'FilesRetrieval',
|
||||
'LlamaIndexRetrieval',
|
||||
'VertexAiRagRetrieval',
|
||||
]
|
||||
|
||||
try:
|
||||
from .vertex_ai_rag_retrieval import VertexAiRagRetrieval
|
||||
|
||||
__all__.append('VertexAiRagRetrieval')
|
||||
except ImportError:
|
||||
import logging
|
||||
def __getattr__(name: str):
|
||||
if name == 'VertexAiRagRetrieval':
|
||||
from .vertex_ai_rag_retrieval import VertexAiRagRetrieval
|
||||
|
||||
logger = logging.getLogger('google_adk.' + __name__)
|
||||
logger.debug(
|
||||
'The Vertex sdk is not installed. If you want to use the Vertex RAG with'
|
||||
' agents, please install it. If not, you can ignore this warning.'
|
||||
)
|
||||
return VertexAiRagRetrieval
|
||||
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
|
||||
|
||||
Reference in New Issue
Block a user