I'm currently using the `livekit-examples/agent-st...
# ask-ai
b
I'm currently using the
livekit-examples/agent-starter-react
template to build with a Node.js Agent (powered by Azure OpenAI
gpt-realtime
). I'm trying to build a feature that a user can type in some information, and these information will be injected into the system prompt of the agent, however so far I still cannot make it work. Is there anyone have built this before based on the
agent-starter-react
teamplate?
t
Thanks for reaching out, Minh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I’m happy to help you dynamically modify the system prompt in the
livekit-examples/agent-starter-react
template using a Node.js Agent and Azure OpenAI
gpt-realtime
. You can achieve this smoothly by using the
updateInstructions
method of the
RealtimeSession
class. This lets you update the instructions sent to the model while your session is still running. Here’s a simple guide to get you started: • First, initialize your agent with a
RealtimeModel
instance using
withAzure
, where you set the initial instructions. • Next, access the
RealtimeSession
instance through the LLM in your agent session. • Then, use the
updateInstructions
method to change the system prompt dynamically. For example:
Copy code
await session.updateInstructions("You are now a technical support agent.");
This approach updates the instructions without needing to restart the session, so everything stays smooth and seamless. Please feel free to reach out if you’d like any more help or clarification while implementing this—I’m here for you! Sources: Azure OpenAI Realtime API and LiveKit | LiveKit Docs | plugins/openai/CHANGELOG.md
b
How can I send those information from the frontend (in
agent-starter-react
, thats the thing
t
I'd love to understand a bit more about how you're currently managing communication between the frontend and backend in your
agent-starter-react
setup. Are you using a WebSocket, REST API, or maybe something else to send data to your Node.js backend? Knowing this will really help me guide you better on how to send dynamic system prompt updates from the frontend. I'm here to help every step of the way!