File tree 5 files changed +19
-5
lines changed
5 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -230,7 +230,7 @@ def _page_down() -> str:
230
230
def _find_on_page_ctrl_f (
231
231
search_string : Annotated [
232
232
str , "The string to search for on the page. This search string supports wildcards like '*'"
233
- ]
233
+ ],
234
234
) -> str :
235
235
find_result = self .browser .find_on_page (search_string )
236
236
header , content = _browser_state ()
@@ -344,7 +344,17 @@ def generate_surfer_reply(
344
344
345
345
# Clone the messages to give context
346
346
self ._assistant .chat_messages [self ._user_proxy ] = list ()
347
- history = messages [0 : len (messages ) - 1 ]
347
+
348
+ # If the last message is a tool message it has to be included in context,
349
+ # otherwise openAI will throw exception that not all tool calls are followed by corresponding tool messages
350
+ # In a case where the last message is not a tool message, we fallback to default behavior in the library
351
+ # which is copying all messages except the last one
352
+ # Issue is described more thoroughly in PR https://github.com/microsoft/autogen/pull/4050
353
+ if messages [- 1 ].get ("role" , "assistant" ) == "tool" :
354
+ history = messages [:]
355
+ else :
356
+ history = messages [0 : len (messages ) - 1 ]
357
+
348
358
for message in history :
349
359
self ._assistant .chat_messages [self ._user_proxy ].append (message )
350
360
Original file line number Diff line number Diff line change @@ -1264,6 +1264,10 @@ async def a_run_chat(
1264
1264
else :
1265
1265
# admin agent is not found in the participants
1266
1266
raise
1267
+ except NoEligibleSpeaker :
1268
+ # No eligible speaker, terminate the conversation
1269
+ break
1270
+
1267
1271
if reply is None :
1268
1272
break
1269
1273
# The speaker sends the message without requesting a reply
Original file line number Diff line number Diff line change @@ -1069,7 +1069,7 @@ def extract_text_or_completion_object(
1069
1069
1070
1070
def _throttle_api_calls (self , idx : int ) -> None :
1071
1071
"""Rate limit api calls."""
1072
- if self ._rate_limiters [idx ]:
1072
+ if idx < len ( self . _rate_limiters ) and self ._rate_limiters [idx ]:
1073
1073
limiter = self ._rate_limiters [idx ]
1074
1074
1075
1075
assert limiter is not None
Original file line number Diff line number Diff line change 1
- __version__ = "0.2.37 "
1
+ __version__ = "0.2.39 "
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ pip install autogen-agentchat~=0.2
45
45
import os
46
46
from autogen import AssistantAgent, UserProxyAgent
47
47
48
- llm_config = {" model" : " gpt-4" , " api_key" : os.environ[ " OPENAI_API_KEY" ] }
48
+ llm_config = { " config_list " : [{ " model" : " gpt-4" , " api_key" : os.environ.get( " OPENAI_API_KEY" ) }] }
49
49
assistant = AssistantAgent(" assistant" , llm_config = llm_config)
50
50
user_proxy = UserProxyAgent(" user_proxy" , code_execution_config = False )
51
51
You can’t perform that action at this time.
0 commit comments