I am working with the OpenAI real-time API and using the OpenAI library. Despite updating the instructions, the AI is not asking questions according to the provided instructions. Can anyone help me resolve this issue?
const initializeClient = async () => {
client = new RealtimeClient({
apiKey: API_KEY,
dangerouslyAllowAPIKeyInBrowser: true,
});
try {
await client.connect();
client.updateSession({
voice: "alloy",
instructions:"Hello you are math teacher",
turn_detection: {
type: "server_vad",
silence_duration_ms: 1000,
},
input_audio_transcription: { model: "whisper-1" },
});
console.log("client", client);
client.on("conversation.interrupted", stopAudioPlayback);
client.on("conversation.updated", ({ delta }) => {
if (delta?.audio) {
audioQueue.push(delta.audio);
if (!isAudioPlaying && isAudioContextInitialized) {
playNextAudio();
}
}
const items = client.conversation.getItems();
conversationHistory.value = items
.filter((item) => item.content[0]?.transcript)
.map((item) => ({
role: item.role,
message: item.content[0].transcript,
}));
});
} catch (error) {
console.error(“Failed to initialize client:”, error);
}
};