22from  typing  import  Optional , List , TYPE_CHECKING , Any , Dict 
33
44from  google  import  genai 
5- from  google .genai .client  import  AsyncClient 
5+ from  google .genai .client  import  AsyncClient ,  Client 
66from  google .genai  import  types 
77from  google .genai .types  import  GenerateContentResponse , GenerateContentConfig 
88
@@ -55,7 +55,7 @@ def __init__(self, model: str, api_key: Optional[str] = None, client: Optional[A
5555        if  client  is  not   None :
5656            self .client  =  client 
5757        else :
58-             self .client  =  AsyncClient (api_key = api_key )
58+             self .client  =  Client (api_key = api_key ). aio 
5959
6060    async  def  simple_response (self , text : str , processors : Optional [List [Processor ]] =  None , participant : Optional [Any ] =  None ) ->  LLMResponseEvent [Any ]:
6161        """ 
@@ -108,7 +108,8 @@ async def send_message(self, *args, **kwargs):
108108        # Gemini API does not have an item_id, we create it here and add it to all events 
109109        item_id  =  str (uuid .uuid4 ())
110110
111-         for  idx , chunk  in  enumerate (iterator ):
111+         idx  =  0 
112+         async  for  chunk  in  iterator :
112113            response_chunk : GenerateContentResponse  =  chunk 
113114            final_chunk  =  response_chunk 
114115            self ._standardize_and_emit_event (response_chunk , text_parts , item_id , idx )
@@ -120,6 +121,8 @@ async def send_message(self, *args, **kwargs):
120121            except  Exception :
121122                pass   # Ignore errors in chunk processing 
122123
124+             idx  +=  1 
125+ 
123126        # Check if there were function calls in the response 
124127        if  pending_calls :
125128            # Multi-hop tool calling loop 
0 commit comments