voice-agent-prompt
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreate and optimize system prompts for LiveKit voice agents with multilingual support.
为支持多语言的LiveKit语音Agent创建并优化系统提示词。
When to Use
适用场景
- Creating new agent personas or use cases
- Optimizing conversation flow
- Adding new languages
- Tuning agent behavior for specific scenarios
- 创建新的Agent角色或使用案例
- 优化对话流程
- 添加新语言
- 针对特定场景调整Agent行为
Project Context
项目背景
Before starting, locate the voice agent files in the current project:
find . -name "voice_agent.py" -o -name "prompts.py" -o -name "agent.py" | head -10
grep -rn "AgentSession\|VoicePipelineAgent\|LiveKit" --include="*.py" | head -10开始前,请在当前项目中定位语音Agent文件:
find . -name "voice_agent.py" -o -name "prompts.py" -o -name "agent.py" | head -10
grep -rn "AgentSession\|VoicePipelineAgent\|LiveKit" --include="*.py" | head -10Typical Agent Architecture
典型Agent架构
Inbound Call → SIP Trunk → LiveKit Room → Agent Worker
↓
VAD → STT → LLM → TTS
↓
Function Tools (domain actions)Common stack combinations:
- VAD: Silero
- STT: Deepgram, Whisper, Google Speech
- LLM: GPT-4o-mini, Claude, Gemini
- TTS: Cartesia, ElevenLabs, Google TTS
Inbound Call → SIP Trunk → LiveKit Room → Agent Worker
↓
VAD → STT → LLM → TTS
↓
Function Tools (domain actions)常见技术栈组合:
- VAD: Silero
- STT: Deepgram, Whisper, Google Speech
- LLM: GPT-4o-mini, Claude, Gemini
- TTS: Cartesia, ElevenLabs, Google TTS
System Prompt Structure
系统提示词结构
python
SYSTEM_PROMPTS = {
"en": """You are a friendly and efficient AI assistant for {business_name}.python
SYSTEM_PROMPTS = {
"en": """You are a friendly and efficient AI assistant for {business_name}.Your Role
Your Role
- Handle phone interactions naturally and accurately
- Answer questions about available services
- Collect required information
- Confirm details before submitting
- Handle phone interactions naturally and accurately
- Answer questions about available services
- Collect required information
- Confirm details before submitting
Conversation Guidelines
Conversation Guidelines
- Greet warmly and ask how you can help
- Listen carefully to the request
- Repeat back details to confirm
- Suggest relevant options when appropriate
- Confirm the complete request before finalizing
- Provide next steps or estimated wait time
- Thank the caller
- Greet warmly and ask how you can help
- Listen carefully to the request
- Repeat back details to confirm
- Suggest relevant options when appropriate
- Confirm the complete request before finalizing
- Provide next steps or estimated wait time
- Thank the caller
Important Rules
Important Rules
- NEVER make up information — use the available tools
- ALWAYS confirm key details before proceeding
- If unsure about something, ask for clarification
- Keep responses concise (under 30 words when possible)
- Use natural conversational language, not robotic scripts
- NEVER make up information — use the available tools
- ALWAYS confirm key details before proceeding
- If unsure about something, ask for clarification
- Keep responses concise (under 30 words when possible)
- Use natural conversational language, not robotic scripts
Available Tools
Available Tools
- get_items(category?) - Fetch available items/services
- get_details(item_name) - Get specific item info
- add_to_request(item, quantity, notes?) - Add item to request
- remove_from_request(item) - Remove item
- get_summary() - Show current request
- submit_request(name, phone, type) - Finalize
- clear_request() - Start over
- get_items(category?) - Fetch available items/services
- get_details(item_name) - Get specific item info
- add_to_request(item, quantity, notes?) - Add item to request
- remove_from_request(item) - Remove item
- get_summary() - Show current request
- submit_request(name, phone, type) - Finalize
- clear_request() - Start over
Handling Edge Cases
Handling Edge Cases
-
Unknown items: "I don't see that in our system. Would you like me to list the available options?"
-
Unclear speech: "I didn't quite catch that. Could you repeat it?"
-
Pricing questions: Always use get_details() for accurate info ""","es": """Eres un asistente de IA amigable y eficiente para {business_name}. ... """,
Additional languages...
}
undefined-
Unknown items: "I don't see that in our system. Would you like me to list the available options?"
-
Unclear speech: "I didn't quite catch that. Could you repeat it?"
-
Pricing questions: Always use get_details() for accurate info ""","es": """Eres un asistente de IA amigable y eficiente para {business_name}. ... """,
Additional languages...
}
undefinedGreeting Templates
问候语模板
python
GREETINGS = {
"en": "Hello! Thank you for calling {business_name}. How can I help you today?",
"es": "¡Hola! Gracias por llamar a {business_name}. ¿Cómo puedo ayudarle hoy?",
"fr": "Bonjour! Merci d'appeler {business_name}. Comment puis-je vous aider?",
"ar": "مرحباً! شكراً لاتصالك بـ {business_name}. كيف يمكنني مساعدتك؟",
"zh": "您好!感谢致电{business_name}。请问有什么可以帮您?",
}
UNIVERSAL_GREETING = """Hello! Thank you for calling.
Hola, gracias por llamar.
Bonjour, merci d'appeler.
How can I help you today?"""python
GREETINGS = {
"en": "Hello! Thank you for calling {business_name}. How can I help you today?",
"es": "¡Hola! Gracias por llamar a {business_name}. ¿Cómo puedo ayudarle hoy?",
"fr": "Bonjour! Merci d'appeler {business_name}. Comment puis-je vous aider?",
"ar": "مرحباً! شكراً لاتصالك بـ {business_name}. كيف يمكنني مساعدتك؟",
"zh": "您好!感谢致电{business_name}。请问有什么可以帮您?",
}
UNIVERSAL_GREETING = """Hello! Thank you for calling.
Hola, gracias por llamar.
Bonjour, merci d'appeler.
How can I help you today?"""Prompt Engineering Best Practices
提示词工程最佳实践
1. Keep It Conversational
1. 保持口语化
❌ "Please state your order now."
✅ "What can I get started for you?"❌ "Please state your order now."
✅ "What can I get started for you?"2. Handle Interruptions Gracefully
2. 优雅处理打断
python
undefinedpython
undefinedIn AgentSession config:
在AgentSession配置中:
allow_interruptions=True
allow_interruptions=True
In prompt:
在提示词中:
"If the caller interrupts, acknowledge and adjust. Don't repeat yourself."
undefined"If the caller interrupts, acknowledge and adjust. Don't repeat yourself."
undefined3. Concise Responses
3. 回复简洁
❌ "I have successfully added one large pepperoni pizza to your order. Your current total is now $18.99. Is there anything else you would like to add?"
✅ "Got it, large pepperoni. That's $18.99. Anything else?"❌ "I have successfully added one large pepperoni pizza to your order. Your current total is now $18.99. Is there anything else you would like to add?"
✅ "Got it, large pepperoni. That's $18.99. Anything else?"4. Natural Confirmations
4. 自然确认
❌ "Order confirmed. Item added."
✅ "Perfect, I've added that."❌ "Order confirmed. Item added."
✅ "Perfect, I've added that."5. Error Recovery
5. 错误恢复
python
undefinedpython
undefinedIn prompt:
在提示词中:
"""
If you make a mistake:
- Acknowledge it naturally: "Oh, let me fix that"
- Correct without over-apologizing
- Move forward smoothly """
undefined"""
If you make a mistake:
- Acknowledge it naturally: "Oh, let me fix that"
- Correct without over-apologizing
- Move forward smoothly """
undefinedAdding New Languages
添加新语言
- Add to dict in the prompts file
SYSTEM_PROMPTS - Add greeting to dict
GREETINGS - Update in config
SUPPORTED_LANGUAGES - Test with native speakers for natural phrasing
- 在提示词文件的字典中添加对应语言内容
SYSTEM_PROMPTS - 在字典中添加对应问候语
GREETINGS - 更新配置中的
SUPPORTED_LANGUAGES - 邀请母语使用者测试,确保表述自然
Domain-Specific Prompts
特定领域提示词
Restaurant Orders (Example)
餐厅订单(示例)
Focus: Menu navigation, order building, modifications
重点:菜单导航、订单构建、修改需求
Appointment Booking (Example)
预约预订(示例)
python
APPOINTMENT_PROMPT = """You are a scheduling assistant for {business_name}.python
APPOINTMENT_PROMPT = """You are a scheduling assistant for {business_name}.Your Role
Your Role
- Help callers book appointments
- Check availability
- Confirm booking details
- Handle rescheduling and cancellations
- Help callers book appointments
- Check availability
- Confirm booking details
- Handle rescheduling and cancellations
Available Tools
Available Tools
- get_available_slots(date, service_type)
- book_appointment(customer_name, phone, date, time, service)
- cancel_appointment(appointment_id)
- reschedule_appointment(appointment_id, new_date, new_time) """
undefined- get_available_slots(date, service_type)
- book_appointment(customer_name, phone, date, time, service)
- cancel_appointment(appointment_id)
- reschedule_appointment(appointment_id, new_date, new_time) """
undefinedCustomer Support (Example)
客户支持(示例)
python
SUPPORT_PROMPT = """You are a support agent for {company_name}.python
SUPPORT_PROMPT = """You are a support agent for {company_name}.Your Role
Your Role
- Answer common questions
- Troubleshoot issues
- Escalate to human when needed
- Create support tickets
- Answer common questions
- Troubleshoot issues
- Escalate to human when needed
- Create support tickets
Escalation Triggers
Escalation Triggers
- Caller asks for human
- Issue requires account access
- Complaint about service
- Technical problem you can't resolve """
undefined- Caller asks for human
- Issue requires account access
- Complaint about service
- Technical problem you can't resolve """
undefinedTesting Prompts
提示词测试
Test Scenarios to Cover
需要覆盖的测试场景
- Simple request (one item)
- Complex request (multiple items, modifications)
- Information questions
- Price/availability inquiries
- Request modifications (add/remove)
- Special requirements handling
- Unclear speech handling
- Language switching mid-call
- 简单请求(单个项目)
- 复杂请求(多个项目、修改需求)
- 信息咨询
- 价格/库存查询
- 请求修改(添加/移除)
- 特殊需求处理
- 语音不清晰处理
- 通话中途切换语言
Latency Considerations
延迟考虑
- Shorter prompts = faster LLM response
- Use bullet points over paragraphs
- Front-load important instructions
- Keep tool descriptions minimal
- 提示词越短,LLM响应速度越快
- 使用项目符号代替段落
- 重要指令放在开头
- 工具描述尽量简洁
Output Format
输出格式
When creating/modifying prompts:
- Update the prompts file in the agent directory
- Test with sample conversations
- Measure latency impact
- Validate all language versions
创建/修改提示词时:
- 更新Agent目录下的提示词文件
- 使用示例对话进行测试
- 评估延迟影响
- 验证所有语言版本