-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Get Nested Agents in a GroupChat
#1636
Feature: Get Nested Agents in a GroupChat
#1636
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1636 +/- ##
===========================================
+ Coverage 39.41% 50.93% +11.51%
===========================================
Files 56 57 +1
Lines 5990 6006 +16
Branches 1334 1456 +122
===========================================
+ Hits 2361 3059 +698
+ Misses 3436 2702 -734
- Partials 193 245 +52
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@microsoft-github-policy-service agree |
@sonichi let me know what you think of this approach. One downside of this approach is it doesn't account for conflicting names. I have two solutions in mind:
I'm leaning towards 1, it's simpler to implement, and conflicting names can't happen |
I don't know the downstream use case, so I don't know if name conflict is an issue. Presumably it is. One way to handle it is to add a bool "raise_on_name_conflict". The desired structure of it also depends on the downstream use case. I recommend moving the public methods into |
@WaelKarkoub Thanks for the PR! Could you share your usage scenario that requires this feature? I am curious why you need to access all agents from a specific team? What's the operation you are performing on these agents? |
I'm not sure if this is relevant to this discussion or @WaelKarkoub 's PR, but a paper came out saying that the more agents used for a task, the better the performance, as long as the result is voted on by the agents. Perhaps adding all agents to a group chat manager would allow the user to run more agents at once? |
Hi @ekzhu! My specific use case requires me to access the history between specific agents in nested teams. This is my current implementation: def team(name: str) -> GroupChatManager:
member1 = autogen.AssistantAgent(name=f"member1_{name}", ...)
member2 = autogen.AssistantAgent(name=f"member2_{name}", ...)
gc = autogen.GroupChat(agents=[member_1, member_2], ...)
return autogen.GroupChatManager(groupchat=gc, ...)
def some_team() -> GroupChatManager:
engineering = team("engineering")
hr = team("hr")
gc = autogen.GroupChat(agents=[engineering, hr], ...)
return autogen.GroupChatManager(groupchat=gc, ...) -- some_chatbot.py import team_factory
class SomeChatBot:
def __init__(...):
self._user = autogen.UserProxyAgen(...)
self._some_team = team_factory.some_team()
self._gc = autogen.GroupChat(...)
self._manager = autogen.GroupChatManager(name="some_chatbot", groupchat=self._gc, ...)
...
...
def _last_message(self) -> str:
engineering = self._gc.agent_by_name("engineering")
member1 = engineering._groupchat.agent_by_name("member1_engineering")
member2 = engineering._groupchat.agent_by_name("member2_engineering")
messages = member1.chat_messages.get(member2)
... I had to access Here's an example of how I ideally want to define def __init__(...):
...
self._gc = autogen.GroupChat(...)
self._manager = autogen.GroupChatManager(groupchat=self._gc, ...)
...
def _last_message(self) -> str:
all_agents = self._gc.all_agents()
member1 = all_agents["member1_engineering"]
member2 = all_agents["member2_engineering"]
messages = member2.chat_messages[member1]
... I reworked the implementation slightly to account for @sonichi 's concerns about composability, which I agree with. This implementation should also work for deeply nested teams. Let me know what you think. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, excited about the prospect of team operations.
Quick question: If we just made the group_chat reference public in GroupChatManager, would that be sufficient? https://github.com/microsoft/autogen/blob/d01063d23122ae2a4bbaa3014519d6ae75e95de1/autogen/agentchat/groupchat.py#L467C33-L467C36 You can get all the agents from there. |
…ogen into groupchat/present-agents
* implements features * fix docstring * adds test * resolve some comments * remove unused group chat manager from test * list implementation * better naming * resolve comments * adds one more test * checks case when agent doesnt exist * clean up --------- Co-authored-by: Chi Wang <wang.chi@microsoft.com>
Why are these changes needed?
Adds the capability to get all the agents in a given a
GroupChatManager
. Improves quality of life for the following use case:--- file_a
--- file_b
Example use case.
Related issue number
Closes #1632
Checks