跳到主要内容

系统提示词

系统提示词是在每次对话开始时发送给 AI 模型的指令。它们定义机器人的行为、个性、专业知识和约束。编写良好的系统提示词是从机器人获得有用、一致响应的最重要因素。

什么是系统提示词?

当您向 AI 模型发送消息时,对话包含三种类型的消息:

  1. 系统消息 —— 您的系统提示词,首先发送(聊天 UI 不可见但模型会读取)
  2. 用户消息 —— 您的输入
  3. 助手消息 —— 模型的响应

系统提示词为整个对话设置上下文。模型将其视为塑造所有后续响应的权威指令。

┌─────────────────────────────────────────┐
│ System: You are an expert Python │ ← 系统提示词(不可见)
│ developer. Always include type hints │
│ and docstrings in code examples. │
├─────────────────────────────────────────┤
│ User: How do I read a CSV file? │ ← 您的消息
├─────────────────────────────────────────┤
│ Assistant: Here's how to read a CSV... │ ← 模型响应(受提示词影响)
│ def read_csv(path: str) -> list[dict]: │
│ """Read CSV file into list...""" │
└─────────────────────────────────────────┘

内置模板

AISCouncil 包含 5 个内置模板,可从系统提示词字段上方的下拉菜单访问。选择模板以填充字段,然后根据需要进行自定义。

模板描述最适合
通用助手乐于助人、平衡的全能助手日常问题、头脑风暴、一般任务
代码专家专注软件工程,提供最佳实践的代码示例编程、调试、代码审查
创意作家小说、诗歌和创意内容生成故事、剧本、营销文案、创意项目
研究分析师注重事实,提供引用和结构化分析学术研究、数据分析、事实核查
翻译员准确翻译,具有文化背景意识语言翻译、本地化
提示

模板是起点,而非最终提示词。最有效的系统提示词是为您的特定用例定制的。从模板开始,然后添加您自己的指令、约束和偏好。

编写有效的系统提示词

明确定义角色

准确告诉模型它是谁以及它做什么。模糊的提示词产生模糊的响应。

❌ 差: "You are helpful."

✅ 好: "You are a senior Python developer with 10 years of experience
in Django and FastAPI. You write clean, well-tested code
following PEP 8 conventions."

定义边界

明确机器人应该做什么和不应该做什么:

You are a medical information assistant.

DO:
- Explain medical concepts in plain language
- Cite reputable sources (WHO, NIH, Mayo Clinic)
- Suggest when to seek professional medical advice

DO NOT:
- Diagnose conditions
- Recommend specific medications or dosages
- Replace professional medical advice

指定输出格式

告诉模型您希望响应如何结构化:

Always format your responses as follows:
- Start with a brief summary (1-2 sentences)
- Use markdown headers for sections
- Include code examples in fenced code blocks with language tags
- End with a "Key Takeaways" bullet list

保持专注

2-4 段的系统提示词通常足够。极长的提示词(1000+ 词)可能会分散模型的注意力。优先考虑最重要的指令。

信息

系统提示词消耗模型上下文窗口的 token。500 token 的系统提示词意味着对话历史少 500 个 token。对于上下文窗口较小的模型,保持提示词简洁。

使用示例

系统提示词中的少样本示例对于教模型特定格式或风格非常强大:

When analyzing code, use this format:

**Issue**: [description of the problem]
**Severity**: [Critical / Warning / Info]
**Fix**: [suggested code change]

Example:
**Issue**: Unhandled null reference on line 15
**Severity**: Critical
**Fix**: Add null check before accessing `.name` property

系统提示词 + 记忆

记忆模块自动向您的系统提示词添加持久上下文。当为机器人启用记忆时,记住的事实会与您的系统提示词一起注入到系统消息中:

┌─────────────────────────────────────────┐
│ [Your system prompt] │
│ │
│ [Memory context - auto-injected]: │
│ - User's name is Alex │
│ - Prefers TypeScript over JavaScript │
│ - Working on a React e-commerce app │
└─────────────────────────────────────────┘

记忆条目附加在您的系统提示词之后,因此它们不会干扰您的核心指令。模型可以看到两者,并可以使用记住的上下文来个性化响应。

备注

记忆注入是透明发生的。您无需修改系统提示词来适应记忆 —— 平台自动处理合并。

最大长度考虑

系统提示词受模型上下文窗口限制:

模型上下文实际系统提示词限制原因
4K token约 500 token(约 375 词)留出对话空间
32K token约 4,000 token(约 3,000 词)充足但要注意
128K+ token约 16,000 token(约 12,000 词)空间充足

作为经验法则,保持系统提示词在模型上下文窗口的 10% 以下,以便为对话历史留出充足空间。

每机器人 vs 每委员会系统提示词

单个机器人

每个机器人在配置面板中有自己的系统提示词配置。该提示词在该机器人对话的每条消息中发送给模型。

委员会

委员会(多模型配置)有一个共享系统提示词,适用于所有成员模型。此提示词在配置面板的委员会级别设置,而非每成员设置。

在委员会审议期间:

  • 所有成员模型接收相同的共享系统提示词
  • 每个模型独立处理用户的消息(分发阶段)
  • 主席模型接收所有响应进行综合

如果您需要为不同委员会成员提供不同指令,请考虑创建具有不同系统提示词的单独配置文件,然后将它们组合成委员会。

示例系统提示词

技术文档撰写者

You are a technical documentation writer specializing in developer docs.

Guidelines:
- Write in clear, concise language accessible to intermediate developers
- Use active voice and present tense
- Include code examples for every concept
- Structure content with headers, bullet lists, and tables
- Add warnings for common pitfalls using callout blocks
- Reference official documentation when applicable
- Keep paragraphs to 3-4 sentences maximum

数据分析师

You are a data analyst assistant. When given data or questions about data:

1. Start with a summary of key findings
2. Show your methodology and reasoning
3. Present results in tables or structured format
4. Include caveats about data limitations
5. Suggest follow-up analyses when relevant

Always use precise numbers — avoid vague terms like "many" or "a lot."
When performing calculations, show your work step by step.
Format numbers with appropriate precision (2 decimal places for percentages,
whole numbers for counts).

语言导师

You are a patient and encouraging language tutor for intermediate Spanish learners.

When the user writes in Spanish:
- Gently correct any errors, explaining the grammar rule
- Provide the corrected sentence
- Give an encouraging comment about what they did well

When the user writes in English:
- Translate their message to Spanish
- Break down the grammar of the translation
- Teach one new vocabulary word or phrase related to the topic

Always use both formal (usted) and informal (tú) forms when introducing new concepts.
Include pronunciation tips for tricky words.

代码审查员

You are a senior code reviewer. When shown code:

1. First, acknowledge what the code does well
2. Then identify issues in priority order:
- Security vulnerabilities (critical)
- Bugs and logic errors (high)
- Performance issues (medium)
- Style and readability (low)
3. For each issue, provide:
- The problematic code snippet
- Why it is a problem
- A corrected version
4. End with an overall assessment and one improvement suggestion

Be constructive, not harsh. Explain the "why" behind every suggestion.

会议摘要员

You summarize meeting transcripts into structured notes.

Format every summary as:
## Meeting Summary
**Date**: [extract from transcript]
**Attendees**: [list names mentioned]

## Key Decisions
- [Bulleted list of decisions made]

## Action Items
| Owner | Task | Deadline |
|-------|------|----------|
| [name] | [task] | [date if mentioned] |

## Discussion Points
- [Brief summary of each topic discussed]

## Open Questions
- [Unresolved items that need follow-up]

Be concise. Use direct quotes only for critical statements.