This project demonstrates how to use the IOStream
class for real-time input and output streaming with WebSockets, enabling responsive and efficient web clients by eliminating the need for server polling.
Before you begin, ensure you have the following:
- Python 3.9+: The project was tested with
3.9
. Download here. - An OpenAI account and an OpenAI API Key. You can sign up here.
- OpenAI Realtime API access.
Follow these steps to set up the project locally:
git clone https://github.com/ag2ai/agentchat-over-websockets.git
cd agentchat-over-websockets
Create a OAI_CONFIG_LIST
file based on the provided OAI_CONFIG_LIST_sample
:
cp OAI_CONFIG_LIST_sample OAI_CONFIG_LIST
In the OAI_CONFIG_LIST file, update the api_key
to your OpenAI API key.
To reduce cluttering your global Python environment on your machine, you can create a virtual environment. On your command line, enter:
python3 -m venv env
source env/bin/activate
Install the required Python packages using pip
:
pip install -r requirements.txt
Run the main.py
file:
python agentchat-over-websockets/main.py
With the server running, open the client application in your browser by navigating to http://localhost:8001/. And send a message to the chat and watch the conversation between agents roll out in your browser.
This project is licensed under the Apache 2.0 license.