Skip to main content
System prompts define the AI’s personality, behavior, and constraints. They are processed before the user’s prompt and help keep responses consistent. Set the system prompt on RALLMGenerationOptions, not as a history entry, so trimming the conversation cannot drop it.

Basic usage

RALLMGenerationOptions is a generated protobuf message with no memberwise initializer. Start from .defaults() and assign the fields you need.

How system prompts work

Commons renders {systemPrompt, history, prompt} through the model’s chat template:

Examples

Customer Support Bot

Code Assistant

Creative Writer

JSON Output

Language Tutor

Best Practices

Be Specific

Set Boundaries

Control Output Format

Maintain Persona

Reusable System Prompts

Create a library of system prompts for different use cases:

Tips

Long system prompts consume context window tokens. Be specific but brief.
Small changes in wording can significantly affect output. Test different phrasings.
Use temperature: 0.3-0.5 when you need the model to strictly follow format instructions.
Use stopSequences to prevent the model from generating beyond your desired format.

generate()

Learn more about generation options →