Skip to content

Commit

Permalink
Merge branch '0.2' into feature/import-endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
MohMaz authored Nov 26, 2024
2 parents 604d2da + ebb3e24 commit 4bbd542
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
14 changes: 12 additions & 2 deletions autogen/agentchat/contrib/web_surfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def _page_down() -> str:
def _find_on_page_ctrl_f(
search_string: Annotated[
str, "The string to search for on the page. This search string supports wildcards like '*'"
]
],
) -> str:
find_result = self.browser.find_on_page(search_string)
header, content = _browser_state()
Expand Down Expand Up @@ -344,7 +344,17 @@ def generate_surfer_reply(

# Clone the messages to give context
self._assistant.chat_messages[self._user_proxy] = list()
history = messages[0 : len(messages) - 1]

# If the last message is a tool message it has to be included in context,
# otherwise openAI will throw exception that not all tool calls are followed by corresponding tool messages
# In a case where the last message is not a tool message, we fallback to default behavior in the library
# which is copying all messages except the last one
# Issue is described more thoroughly in PR https://github.com/microsoft/autogen/pull/4050
if messages[-1].get("role", "assistant") == "tool":
history = messages[:]
else:
history = messages[0 : len(messages) - 1]

for message in history:
self._assistant.chat_messages[self._user_proxy].append(message)

Expand Down
4 changes: 4 additions & 0 deletions autogen/agentchat/groupchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,10 @@ async def a_run_chat(
else:
# admin agent is not found in the participants
raise
except NoEligibleSpeaker:
# No eligible speaker, terminate the conversation
break

if reply is None:
break
# The speaker sends the message without requesting a reply
Expand Down
2 changes: 1 addition & 1 deletion autogen/oai/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ def extract_text_or_completion_object(

def _throttle_api_calls(self, idx: int) -> None:
"""Rate limit api calls."""
if self._rate_limiters[idx]:
if idx < len(self._rate_limiters) and self._rate_limiters[idx]:
limiter = self._rate_limiters[idx]

assert limiter is not None
Expand Down
2 changes: 1 addition & 1 deletion autogen/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.37"
__version__ = "0.2.39"
2 changes: 1 addition & 1 deletion website/docs/Getting-Started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pip install autogen-agentchat~=0.2
import os
from autogen import AssistantAgent, UserProxyAgent

llm_config = {"model": "gpt-4", "api_key": os.environ["OPENAI_API_KEY"]}
llm_config = { "config_list": [{ "model": "gpt-4", "api_key": os.environ.get("OPENAI_API_KEY") }] }
assistant = AssistantAgent("assistant", llm_config=llm_config)
user_proxy = UserProxyAgent("user_proxy", code_execution_config=False)

Expand Down

0 comments on commit 4bbd542

Please sign in to comment.