Skip to content

Commit

Permalink
Merge branch 'main' into converse
Browse files Browse the repository at this point in the history
  • Loading branch information
sonichi authored Sep 10, 2023
2 parents 16136ab + f70df31 commit dc40c41
Show file tree
Hide file tree
Showing 11 changed files with 604 additions and 12 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<br>
</p>

:fire: Heads-up: We're preparing to migrate [autogen](https://microsoft.github.io/FLAML/docs/Use-Cases/Autogen) into a dedicated github repository. Alongside this move, we'll also launch a dedicated Discord server and a website for comprehensive documentation.

:fire: The automated multi-agent chat framework in [autogen](https://microsoft.github.io/FLAML/docs/Use-Cases/Autogen) is in preview from v2.0.0.

:fire: FLAML is highlighted in OpenAI's [cookbook](https://github.com/openai/openai-cookbook#related-resources-from-around-the-web).
Expand Down
36 changes: 26 additions & 10 deletions flaml/autogen/agentchat/groupchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class GroupChat:
agents: List[Agent]
messages: List[Dict]
max_round: int = 10
admin_name: str = "Admin" # the name of the admin agent

@property
def agent_names(self) -> List[str]:
Expand Down Expand Up @@ -97,21 +98,36 @@ def run_chat(
messages = self._oai_messages[sender]
message = messages[-1]
speaker = sender
for i in range(config.max_round):
groupchat = config
for i in range(groupchat.max_round):
# set the name to speaker's name if the role is not function
if message["role"] != "function":
message["name"] = speaker.name
config.messages.append(message)
groupchat.messages.append(message)
# broadcast the message to all agents except the speaker
for agent in config.agents:
for agent in groupchat.agents:
if agent != speaker:
self.send(message, agent, request_reply=False, silent=True)
if i != config.max_round - 1:
# speaker selection msg from an agent
speaker = config.select_speaker(speaker, self)
if i == groupchat.max_round - 1:
# the last round
break
try:
# select the next speaker
speaker = groupchat.select_speaker(speaker, self)
# let the speaker speak
reply = speaker.generate_reply(sender=self)
if reply is None:
break
speaker.send(reply, self, request_reply=False)
message = self.last_message(speaker)
except KeyboardInterrupt:
# let the admin agent speak if interrupted
if groupchat.admin_name in groupchat.agent_names:
# admin agent is one of the participants
speaker = groupchat.agent_by_name(groupchat.admin_name)
reply = speaker.generate_reply(sender=self)
else:
# admin agent is not found in the participants
raise
if reply is None:
break
# The speaker sends the message without requesting a reply
speaker.send(reply, self, request_reply=False)
message = self.last_message(speaker)
return True, None
2 changes: 2 additions & 0 deletions flaml/autogen/oai/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class Completion(openai_Completion):
"gpt-3.5-turbo-0301", # deprecate in Sep
"gpt-3.5-turbo-0613",
"gpt-3.5-turbo-16k",
"gpt-3.5-turbo-16k-0613",
"gpt-35-turbo",
"gpt-4",
"gpt-4-32k",
Expand All @@ -70,6 +71,7 @@ class Completion(openai_Completion):
"gpt-3.5-turbo-0301": (0.0015, 0.002), # deprecate in Sep
"gpt-3.5-turbo-0613": (0.0015, 0.002),
"gpt-3.5-turbo-16k": (0.003, 0.004),
"gpt-3.5-turbo-16k-0613": (0.003, 0.004),
"gpt-35-turbo": 0.002,
"gpt-4": (0.03, 0.06),
"gpt-4-32k": (0.06, 0.12),
Expand Down
2 changes: 1 addition & 1 deletion flaml/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.0.2"
__version__ = "2.0.3"
1 change: 1 addition & 0 deletions notebook/autogen_agentchat_chess.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"# \"model\": {\n",
"# \"gpt-3.5-turbo\",\n",
"# \"gpt-3.5-turbo-16k\",\n",
"# \"gpt-3.5-turbo-16k-0613\",\n",
"# \"gpt-3.5-turbo-0301\",\n",
"# \"chatgpt-35-turbo-0301\",\n",
"# \"gpt-35-turbo-v0301\",\n",
Expand Down
Loading

0 comments on commit dc40c41

Please sign in to comment.