Skip to content
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 Request]: new high-level programming interface #26

Closed
sonichi opened this issue Nov 17, 2024 · 1 comment · Fixed by #28 or #30
Closed

[Feature Request]: new high-level programming interface #26

sonichi opened this issue Nov 17, 2024 · 1 comment · Fixed by #28 or #30
Assignees
Labels
enhancement New feature or request roadmap swarm

Comments

@sonichi
Copy link
Collaborator

sonichi commented Nov 17, 2024

Is your feature request related to a problem? Please describe.

Offer a simpler high-level programming interface for common orchestration patterns such as Swarm-style handsoff.
Extend it to incorporate group chat, nested chat and sequential chats.
Offer builtin tools that an agent can register for these common chat patterns.
Enable self-execution for swarm-style agents.

Describe the solution you'd like

from autogen import SwarmAgent, autobuild_groupchat, initiate_chat

captain = SwarmAgent("captain", llm_config=..., human_input_mode="NEVER")
user_proxy = SwarmAgent("user_proxy")
planner = SwarmAgent("planner", llm_config=..., human_input_mode="NEVER")
team_creator = SwarmAgent("team_creator", llm_config=..., human_input_mode="NEVER", functions=[autobuild_groupchat])

user_proxy.register_handoff(hand_to=captain)  # always hand off to captain after human input
captain.register_handoff(
    hand_to=[
        ON_CONDITION(nested_chat=[chat_with_planner, chat_with_team_creator, ...], condition="You need help from a planner. The user does not need to be involved in the planning."),
        ON_CONDITION(agent=planner, condition="You need help from a planner. The user would like to be involved in the planning"),
        ON_CONDITION(agent=team_creator, condition="The plan has been generated. A team is needed to execute the next step in the plan.")
        AFTER_WORK(user_proxy),  # After work, choose user proxy
    ]
)
planner.register_handoff(
    hand_to=[
        AFTER_WORK("If the user would like to be involved in the planning and has't approved the latest plan, hand off to user proxy. Otherwise handoff to captain."),
    ]
)
team_creator.register_handoff(hand_to=[AFTER_WORK(captain)])

initiate_chat(sender=captain, message="How can I help you?")  # a default group chat is created automatically when omitted

Benefits:

  1. Simplify user's code in tool use, group chat, nested chat etc. They are handled by the library automatically.
  2. Offer built-in tools like autobuild_groupchat.
  3. Can still leverage all the conversation patterns we support and expand the ways to use them.
  4. Compatible with swarm-style handsoff.

Note:
Only one AFTER_WORK is allowed. Multiple ON_CONDITION is allowed.
ON_CONDITION corresponds to tool-based handoff.
AFTER_WORK corresponds to speaker selection after the work of the agent is done and no other agent is selected by a tool call. It can be both NL-based selection or PL-based.

Additional context

Will create a task list to break down the implementation plan.

@sonichi sonichi added enhancement New feature or request roadmap labels Nov 17, 2024
@marklysze marklysze mentioned this issue Nov 19, 2024
3 tasks
This was linked to pull requests Nov 20, 2024
@sonichi sonichi reopened this Nov 26, 2024
@sonichi sonichi added the swarm label Nov 28, 2024
@marklysze
Copy link
Collaborator

With Nested Chat, #107, complete and merged. Will close this. Swarm will continue to develop with additional features and these can be created in a new Issue.

davorrunje pushed a commit that referenced this issue Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request roadmap swarm
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants