RealtimeAgent using websockets
notebooks/agentchat_realtime_webrtc/static
and
notebooks/agentchat_realtime_webrtc/templates
folders are available in
the correct relative paths.
ag2
:llm_config
and realtime_llm_config
LLMConfig.from_json
method loads a list of configurations from an environment variable or a
json file.
PORT
variable to 5050
, which will be
used for the server.FastAPI
instance named
app
, which serves as the main application.GET
endpoint at the root URL
(/
). When accessed, it returns a JSON response with the message
"WebRTC AG2 Server is running!"
.start-chat
endpointnotebook_path
as the current
working directory using os.getcwd()
.static
directory (inside
agentchat_realtime_webrtc
) to serve JavaScript, CSS, and other
static assets under the /static
path.templates
directory within agentchat_realtime_webrtc
./start-chat/
Endpoint: Define a GET
route that
serves the chat.html
template. Pass the client’s request
and the
port
variable to the template for rendering a dynamic page for the
audio chat interface./session
WebSocket
route to handle audio streaming.RealtimeAgent
with the
following:
Weather Bot
.realtime_llm_config
for language
model settings.get_weather
to
the agent, allowing it to respond with basic weather information
based on the provided location
.realtime_agent
to handle interactions
in real time.