Multi-Agent Communication with Human, WebSocket, and Agent Channels
This example demonstrates real-time event-driven communication between humans, WebSocket gateways, and agents.
Key features:
- Real-Time Communication between users and agents using WebSocket.
- Coordinator Agent which routes events.
- Multi-Agent Setup with specialized agents.
Here is a simplified architecture overview:
- WebsocketGateway Agent: Bridges human interfaces (e.g., web UI) and the agent ecosystem via WebSocket.
- Coordinator Agent: Routes messages and orchestrates the workflow.
- Agent 1: Order Agent, handling order lifecycle events.
- Agent 2: Email Agent, managing notifications and email communication.
The code for the example can be found here.
Prerequisites
- Python 3.10+
- Docker and Docker Compose
Setup Instructions
Clone the EggAI repository:
Move into the examples/websocket_gateway
folder:
Create and activate a virtual environment:
Install the required dependencies:
Start Redpanda using Docker Compose:
Run the Example
Expected output:
Connection id: {"connection_id":"15b3a00b-41c0-467c-b411-8557dff2fab7"}
Message id: b6ad3608-2ce2-4c53-a123-45e9eec797cf
[ORDER AGENT]: order_requested event received. Emitting order_created event.
[EMAIL AGENT]: order_created event received. Sending email to customer.
[EMAIL AGENT]: order_created event received. Sending notification event.
[ORDER AGENT]: order_created event received.
Reply: {"id":"b6ad3608-2ce2-4c53-a123-45e9eec797cf","type":"notification","payload":{"message":"Order created, you will receive an email soon."}}
Agent is running. Press Ctrl+C to stop.
[WEBSOCKET GATEWAY]: WebSocket connection 15b3a00b-41c0-467c-b411-8557dff2fab7 closed.
What happens:
- A request (e.g.,
order_requested
for aLaptop
) is sent via the Human Channel or WebsocketGateway Agent. - The Coordinator Agent broadcasts the request to the Agent Channel.
- The Order Agent processes the request and emits an
order_created
event. - The Email Agent sends a notification and emits a
notification
event. - The WebsocketGateway Agent streams
notification
events back to the frontend.
Clean Up
Stop and clean up the Docker containers:
Next Steps
Ready to explore further? Check out:
- Advanced Examples: Discover more complex use cases in the examples folder.
- Contribution Guidelines: Get involved and help improve EggAI!
- GitHub Issues: Submit a bug or feature request.
- Documentation: Refer to the official docs for deeper insights.