IOStream
OAI_CONFIG_LIST
file based on the provided OAI_CONFIG_LIST_sample
:
api_key
to your OpenAI API key.
pip
:
main.py
file:
main.py
IOWebsockets.run_server_in_thread
utility is used to run a WebSocket server. The on_connect
function handles new client connections and initializes the chatbot.
on_connect
: Handles client connections and manages the interaction between the ConversableAgent
and the client.weather_forecast
function provides a mock weather report and is linked to the agent for handling weather-related queries.SimpleHTTPRequestHandler
is used to serve HTML files. A custom handler class overrides the behavior for the root path to serve chat.html
.
MyRequestHandler
class ensures that the default page served is chat.html
.website_files/templates
directory.8080
, while the HTTP server listens on port 8001
.chat.html
ws://localhost:8080
.#messages
list.