Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
|
|
1 year ago | |
|---|---|---|
| .. | ||
| public | 1 year ago | |
| .gitignore | 1 year ago | |
| README.md | 1 year ago | |
| _agents.py | 1 year ago | |
| _types.py | 1 year ago | |
| _utils.py | 1 year ago | |
| config.yaml | 1 year ago | |
| run.sh | 1 year ago | |
| run_editor_agent.py | 1 year ago | |
| run_group_chat_manager.py | 1 year ago | |
| run_host.py | 1 year ago | |
| run_ui.py | 1 year ago | |
| run_writer_agent.py | 1 year ago | |
from autogen_core.application import WorkerAgentRuntimeHost
This example runs a gRPC server using WorkerAgentRuntimeHost and instantiates three distributed runtimes using WorkerAgentRuntime. These runtimes connect to the gRPC server as hosts and facilitate a round-robin distributed group chat. This example leverages the Azure OpenAI Service to implement writer and editor LLM agents. Agents are instructed to provide concise answers, as the primary goal of this example is to showcase the distributed runtime rather than the quality of agent responses.
uv pip install chainlit in the same virtual environmentIn the config.yaml file, you can configure the client_config section to connect the code to the Azure OpenAI Service.
The recommended method for authentication is through Azure Active Directory (AAD), as explained in Model Clients - Azure AI. This example works with both the AAD approach (recommended) and by providing the api_key in the config.yaml file.
The run.sh file provides commands to run the host and agents using tmux. The steps for this approach are:
source .venv/bin/activate../run.sh.Here is a screen recording of the execution:
Note: Some asyncio.sleep commands have been added to the example code to make the ./run.sh execution look sequential and visually easy to follow. In practice, these lines are not necessary.
If you prefer to run Python files individually, follow these steps. Note that each step must be run in a different terminal process, and the virtual environment should be activated using source .venv/bin/activate.
python run_host.py: Starts the host and listens for agent connections.chainlit run run_ui.py --port 8001: Starts the Chainlit app and UI agent and listens on UI topic to display messages. We're using port 8001 as the default port 8000 is used to run host (assuming using same machine to run all of the agents)python run_editor.py: Starts the python run_writer.py: Starts the python run_group_chat_manager.py: Run chainlit app which starts The general flow of this example is as follows:
User, sends a RequestToSpeak request to the writer_agent.writer_agent writes a short sentence into the group chat topic.editor_agent receives the message in the group chat topic and updates its memory.editor_agent, a RequestToSpeak message.editor_agent sends its feedback to the group chat topic.writer_agent receives the feedback and updates its memory.Here is an illustration of the system developed in this example:
graph TD;
subgraph Host
A1[GRPC Server]
wt[Writer Topic]
et[Editor Topic]
ut[UI Topic]
gct[Group Chat Topic]
end
all_agents[All Agents - Simplified Arrows!] --> A1
subgraph Distributed Writer Runtime
wt -.->|2 - Subscription| writer_agent
gct -.->|4 - Subscription| writer_agent
writer_agent -.->|3.1 - Publish: UI Message| ut
writer_agent -.->|3.2 - Publish: Group Chat Message| gct
end
subgraph Distributed Editor Runtime
et -.->|6 - Subscription| editor_agent
gct -.->|4 - Subscription| editor_agent
editor_agent -.->|7.1 - Publish: UI Message| ut
editor_agent -.->|7.2 - Publish: Group Chat Message| gct
end
subgraph Distributed Group Chat Manager Runtime
gct -.->|4 - Subscription| group_chat_manager
group_chat_manager -.->|1 - Request To Speak| wt
group_chat_manager -.->|5 - Request To Speak| et
group_chat_manager -.->|\* - Publish Some of to UI Message| ut
end
subgraph Distributed UI Runtime
ut -.->|\* - Subscription| ui_agent
end
style wt fill:#beb2c3,color:#000
style et fill:#beb2c3,color:#000
style gct fill:#beb2c3,color:#000
style ut fill:#beb2c3,color:#000
style writer_agent fill:#b7c4d7,color:#000
style editor_agent fill:#b7c4d7,color:#000
style group_chat_manager fill:#b7c4d7,color:#000
style ui_agent fill:#b7c4d7,color:#000
This is a mirror of AutoGen from GitHub. AutoGen is a framework that enables the development of LLM applications using multiple agents that can converse with each other to solve tasks.
Python SVG Jupyter Notebook C# TSX other