@@ -93,10 +93,13 @@ def __init__(
9393 api_key = openai_provider_config .api_key ,
9494 base_url = openai_provider_config .base_url ,
9595 )
96- self ._stream = self ._config .get (
97- "stream" ,
98- self ._config .get ("model" , "gpt-3.5-turbo" ) in list (map (lambda x : str (x .value ), AgentModel )),
99- )
96+ self ._stream = self ._config .get ("stream" )
97+ if self ._stream is None :
98+ self ._stream = (
99+ True
100+ if self ._config .get ("model" , "gpt-3.5-turbo" ) in list (map (lambda x : str (x .value ), AgentModel ))
101+ else False
102+ )
100103
101104 self ._agent_messages = []
102105 self ._tool_calls = []
@@ -290,8 +293,11 @@ def on_receive(self, message: Message) -> Any:
290293 ),
291294 )
292295 elif tool_calls_chunk and len (tool_calls_chunk ) > 0 :
296+ tool_call_index = 0
293297 for tool_call in tool_calls_chunk :
294- tool_call_index = tool_call .index if hasattr (tool_call , "index" ) else 0
298+ if hasattr (tool_call , "index" ):
299+ tool_call_index = tool_call .index
300+
295301 if len (self ._tool_calls ) < tool_call_index + 1 :
296302 # Insert at the index
297303 self ._tool_calls .insert (
@@ -313,6 +319,9 @@ def on_receive(self, message: Message) -> Any:
313319 type = "step" ,
314320 ),
315321 )
322+
323+ if not hasattr (tool_call , "index" ):
324+ tool_call_index += 1
316325 else :
317326 # Update at the index
318327 self ._tool_calls [tool_call_index ]["arguments" ] += tool_call .function .arguments
0 commit comments