-
Notifications
You must be signed in to change notification settings - Fork 308
[RFC] - Simplifying Workflow Design with AG2's High-Level API #1035
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
base: main
Are you sure you want to change the base?
Conversation
Thanks for Chi's invitation to the RFC. It is a great work! My thoughts:
|
Nice work @davorrunje, @sternakt, @davorinrusevljan! I really like the simplicity and logical approach to agent creation, tools, events, run response protocol, and the run command. The ability to iterate over the events and how this can drive any user interface is a major step forward. After today's discussion, most of my questions were answered and for others to reference, here are some questions and my understanding of the answers. Q: How will nested chats and other internal chats be catered for Q: I see GroupChat is catered for with the NewGroupChatManager, how will other orchestrations be catered for? Q: Is the ConversableAgent still used and functions as it currently does (e.g. internal generate_reply with registered reply functions) Q: How are exceptions handled, are they the event.type == "error"? Q: How would a workflow be saved and resumed? Q: How will tools be executed Q: How do you pass multiple agents to the run function
Q: Will you have to implement the event processing loop each time? Q: There's only one parameter set on ConversableAgent in the sample code. Q: Is the messages list still being used? Q: Termination not using a lambda/function? Q: Why is LLM Configuration being done this way? Q: What if you don't specify a conversation pattern/orchestration? |
... and here are some other questions: Q: Is there a way to trigger the workflow based on an event (this may be outside the scope of this implementation), e.g. a workflow triggers when a new file is added to a directory or a new post on Discord. Q: Is it possible to have asynchronous activity within the workflow (e.g. currently nested chats can be run asynchronously so multiple chats happen concurrently)? I assume this just means multiple runs and iterators, but good to understand. Q: Can a run be terminated within, for example, an agent? Or what determines the end of the run? Q: Assume multiple tool calls (e.g. an LLM recommends multiple tool calls) work as usual? |
I would like to understand this better. @davorrunje Could you help clarify?
|
I'd like the signature and docstr of Besides the swarm group chat, another question is how do we support sequential chats in |
Differences:
Swarm:
|
Expanding on my previous comment here: #1035 (comment) My understandingThe current run(alice, bob, message="Who is Leonardo da Vinci?") Which is equivalent to: alice.initiate_chat(
recipient=bob,
message="Who is Leonardo da Vinci?",
) run(
planner, reviewer, teacher,
message="Create lesson plans for 4th grade.",
chat_manager=chat_manager,
) Which is equivalent to:
Regarding my previous question 2:
It seems logical that the Extending the
|
This PR proposes a new global
run
function to be used for running workflows and explains how it can be used to integrate with console and web applications using both sync and async API-s.Motivational Examples
1. WebSocket-Based Workflow
Let's first consider the WebSocket example, where agents work together in a dynamic, interactive environment. The WebSocket server handles asynchronous communication between the agents and a client, allowing real-time interaction.
WebSocket Server Example with
websockets
LibraryExplanation:
2. Synchronous CLI Application Using
typer
The second example demonstrates a synchronous version of the same workflow, but in a CLI application built using the
typer
library.CLI Application Code with
typer
and Synchronous Event HandlingExplanation:
typer
library is used to build a simple CLI that prompts the user for input and displays agent messages.3. Group Chat Manager for Handling Transitions Between Multiple Agents
Example Code with
GroupChatManager
:Explanation:
GroupChatManager
:GroupChatManager
is used to manage the transitions between agents in this group workflow. It listens for theKeyword("DONE!")
from the teacher to terminate the workflow. This ensures that the process stops once the teacher is satisfied with the lesson plan.run()
function starts the workflow, passing the three agents (planner, reviewer, teacher) and thechat_manager
. The agents communicate through thechat_manager
, ensuring that transitions between them are handled automatically. The workflow will stop when the teacher says "DONE!".process_event_loop
function handles each event generated during the workflow. For example, if an input request event is triggered, the program prompts the user for input and responds to the agent with the provided answer.How It Works: