@@ -63,8 +63,7 @@ def __init__(
63
63
64
64
logger .debug ("config=<%s> | initializing" , self .config )
65
65
66
- client_args = client_args or {}
67
- self .client = genai .Client (** client_args )
66
+ self .client_args = client_args or {}
68
67
69
68
@override
70
69
def update_config (self , ** model_config : Unpack [GeminiConfig ]) -> None : # type: ignore[override]
@@ -366,8 +365,9 @@ async def stream(
366
365
"""
367
366
request = self ._format_request (messages , tool_specs , system_prompt , self .config .get ("params" ))
368
367
368
+ client = genai .Client (** self .client_args ).aio
369
369
try :
370
- response = await self . client . aio .models .generate_content_stream (** request )
370
+ response = await client .models .generate_content_stream (** request )
371
371
372
372
yield self ._format_chunk ({"chunk_type" : "message_start" })
373
373
yield self ._format_chunk ({"chunk_type" : "content_start" , "data_type" : "text" })
@@ -442,5 +442,6 @@ async def structured_output(
442
442
"response_schema" : output_model .model_json_schema (),
443
443
}
444
444
request = self ._format_request (prompt , None , system_prompt , params )
445
- response = await self .client .aio .models .generate_content (** request )
445
+ client = genai .Client (** self .client_args ).aio
446
+ response = await client .models .generate_content (** request )
446
447
yield {"output" : output_model .model_validate (response .parsed )}
0 commit comments