본문으로 건너뛰기

voice.add명령()

그만큼addInstructions()이 방법은 실시간 상호 작용 중에 Model의 동작을 안내하는 지침을 음성 제공자에게 제공합니다. 이는 대화 전체에서 컨텍스트를 유지하는 실시간 음성 제공자에게 특히 유용합니다.

사용예
사용예에 대한 직접 링크

import { OpenAIRealtimeVoice } from '@mastra/voice-openai-realtime'
import { Agent } from '@mastra/core/agent'

// Initialize a real-time voice provider
const voice = new OpenAIRealtimeVoice({
realtimeConfig: {
model: 'gpt-5.1-realtime',
apiKey: process.env.OPENAI_API_KEY,
},
})

// Create an agent with the voice provider
const agent = new Agent({
id: 'customer-support-agent',
name: 'Customer Support Agent',
instructions: 'You are a helpful customer support agent for a software company.',
model: 'openai/gpt-5.6-sol',
voice,
})

// Add additional instructions to the voice provider
voice.addInstructions(`
When speaking to customers:
- Always introduce yourself as the customer support agent
- Speak clearly and concisely
- Ask clarifying questions when needed
- Summarize the conversation at the end
`)

// Connect to the real-time service
await voice.connect()

매개변수
매개변수에 대한 직접 링크


instructions:

string
음성 Model의 동작을 안내하는 지침

반환 값
반환 값에 대한 직접 링크

이 메서드는 값을 반환하지 않습니다.

메모
메모에 대한 직접 링크

  • 지침은 명확하고 구체적이며 음성 상호 작용과 관련이 있을 때 가장 효과적입니다.
  • 이 메서드는 주로 대화 컨텍스트를 유지하는 실시간 음성 Provider에 사용됩니다.
  • 지침을 지원하지 않는 음성 Provider에서 호출하면 경고를 기록하고 아무 작업도 수행하지 않습니다.
  • 이 메서드로 추가된 지침은 일반적으로 관련 Agent가 제공하는 지침과 결합됩니다.
  • 최상의 결과를 얻으려면 대화를 시작하기 전(connect()를 호출하기 전)에 지침을 추가하세요.
  • addInstructions()를 여러 번 호출하면 Provider 구현에 따라 기존 지침을 대체하거나 기존 지침에 추가할 수 있습니다.