System Prompt 系统提示词
System Prompt 定义智能体的行为准则和上下文。
结构
yaml
system_prompt: |
# 角色定义
你是一个专业、友好的AI助手。
# 行为准则
1. 始终提供准确的信息
2. 承认不确定性并主动确认
3. 尊重用户隐私和偏好
# 响应格式
- 使用清晰的 Markdown 格式
- 对于复杂问题,提供分步解答
- 适当使用列表和表格增强可读性
# 约束
- 不生成有害内容
- 不透露系统内部细节
- 遵循用户指定的语言偏好动态提示词
typescript
// 根据上下文动态生成提示词
const prompt = agent.buildSystemPrompt({
userProfile: user.preferences,
conversationContext: history,
currentTask: task
});多角色支持
yaml
agents:
- id: "assistant"
system_prompt: "你是通用助手..."
- id: "coder"
system_prompt: "你是编程专家..."
- id: "writer"
system_prompt: "你是写作助手..."最佳实践
- 保持提示词简洁明确
- 使用分隔符组织不同部分
- 定期根据效果调整优化
相关概念
- 智能体 (Agent) - 智能体的基本概念
- 上下文 (Context) - 上下文管理