File tree Expand file tree Collapse file tree 1 file changed +4
-16
lines changed
libs/genai/langchain_google_genai Expand file tree Collapse file tree 1 file changed +4
-16
lines changed Original file line number Diff line number Diff line change @@ -116,22 +116,10 @@ def validate_environment(self) -> Self:
116116 client_options = self .client_options ,
117117 transport = self .transport ,
118118 )
119- # Only initialize async client if there's an event loop running
120- # to avoid RuntimeError during synchronous initialization
121- if _is_event_loop_running ():
122- # async clients don't support "rest" transport
123- transport = self .transport
124- if transport == "rest" :
125- transport = "grpc_asyncio"
126- self .async_client = build_generative_async_service (
127- credentials = self .credentials ,
128- api_key = google_api_key ,
129- client_info = client_info ,
130- client_options = self .client_options ,
131- transport = transport ,
132- )
133- else :
134- self .async_client = None
119+ # Always defer async client initialization to first async call.
120+ # Avoids implicit event loop creation and aligns with lazy init
121+ # in chat models.
122+ self .async_client = None
135123 return self
136124
137125 @property
You can’t perform that action at this time.
0 commit comments