I'm building a voice assistant app using open ai r...
# ask-ai
m
I'm building a voice assistant app using open ai realtime plugin. Is it possible to catch realtime events in my application like "response.text.done"?
g
Yes, you can catch realtime events such as "response.text.done" in your application when using the OpenAI Realtime plugin. The
ResponseTextDoneEvent
is part of the LiveKit Agents framework and can be used to detect when a text response is completed. This event includes properties like
content_index
,
event_id
,
output_index
,
response_id
, and
text
which can be useful for handling the completion of text responses in your application. Would you like more details on how to implement this in your application? Sources: - ResponseTextDoneEvent 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
m
@millions-hair-24956 Yes please, I need a nodejs sample.
@millions-hair-24956 Yes please, I need a nodejs sample.
g
To handle the
ResponseTextDoneEvent
in a Node.js application using the OpenAI Realtime plugin, you can set up an event listener for this specific event type. Here's a basic example of how you might implement this:
Copy code
const { RealtimeModel } = require('@livekit/agents-plugin-openai');

// Assuming you have already set up your RealtimeModel
const model = new RealtimeModel({
  instructions: "You are a helpful assistant.",
  modalities: ["text"],
  // other configurations
});

// Listen for the 'response.text.done' event
model.on('response.text.done', (event) => {
  console.log('Text response completed:', event.text);
  // You can handle the completed text response here
});

// Start your model or agent
model.start();
In this example, the
model.on('response.text.done', callback)
method is used to listen for the
ResponseTextDoneEvent
. When the event is triggered, the callback function logs the completed text response. You can replace the
console.log
with any other logic you need to handle the text response. Would you like more information on setting up the RealtimeModel or handling other events? Sources: - https://livekit-users.slack.com/archives/C07FY8WHGPM/p1731773981.585369 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
m
@millions-hair-24956 I get the following error: Property 'on' does not exist on type 'RealtimeModel'
g
I'm not able to find any data sources to answer your question. You might want to provide more details about the version of the LiveKit SDK you are using or any additional context about your setup. If this doesn't help, please reach out to the Livekit support team for further assistance. 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.