@@ -93,10 +93,13 @@ def __init__(
93
93
api_key = openai_provider_config .api_key ,
94
94
base_url = openai_provider_config .base_url ,
95
95
)
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
+ )
100
103
101
104
self ._agent_messages = []
102
105
self ._tool_calls = []
@@ -290,8 +293,11 @@ def on_receive(self, message: Message) -> Any:
290
293
),
291
294
)
292
295
elif tool_calls_chunk and len (tool_calls_chunk ) > 0 :
296
+ tool_call_index = 0
293
297
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
+
295
301
if len (self ._tool_calls ) < tool_call_index + 1 :
296
302
# Insert at the index
297
303
self ._tool_calls .insert (
@@ -313,6 +319,9 @@ def on_receive(self, message: Message) -> Any:
313
319
type = "step" ,
314
320
),
315
321
)
322
+
323
+ if not hasattr (tool_call , "index" ):
324
+ tool_call_index += 1
316
325
else :
317
326
# Update at the index
318
327
self ._tool_calls [tool_call_index ]["arguments" ] += tool_call .function .arguments
0 commit comments