mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-04-11 21:42:36 +00:00
fix: avoid forcing lazy client construction in lightweight accessors
Two sites that were mechanically rewritten by the lazy-getter regex shouldn't actually go through the lazy getter: - `BedrockCompletion._ensure_async_client` manages its own client lifecycle through `aiobotocore` inside an exit stack. Its trailing `return self._get_async_client()` was a redundant indirection through a stub method that doesn't even attempt to build a client. Return the cached attribute directly. - `GeminiCompletion._get_client_params` is a lightweight config accessor used at `to_config_dict()` time. Calling `_get_sync_client()` here forced client construction (and would raise `ValueError` when credentials aren't set) just to check the `vertexai` attribute. Read `self._client` directly and null-guard before the `hasattr` check.
This commit is contained in:
@@ -1198,7 +1198,7 @@ class BedrockCompletion(BaseLLM):
|
||||
)
|
||||
self._async_client = client
|
||||
self._async_client_initialized = True
|
||||
return self._get_async_client()
|
||||
return self._async_client
|
||||
|
||||
async def _ahandle_converse(
|
||||
self,
|
||||
|
||||
@@ -244,8 +244,9 @@ class GeminiCompletion(BaseLLM):
|
||||
|
||||
if (
|
||||
hasattr(self, "client")
|
||||
and hasattr(self._get_sync_client(), "vertexai")
|
||||
and self._get_sync_client().vertexai
|
||||
and self._client is not None
|
||||
and hasattr(self._client, "vertexai")
|
||||
and self._client.vertexai
|
||||
):
|
||||
# Vertex AI configuration
|
||||
params.update(
|
||||
|
||||
Reference in New Issue
Block a user