|

System Prompt, User Prompt, and Assistant Prompt

[Gemini]

Understanding AI Prompt Roles: System, User, and Assistant

To create effective and reusable AI prompts, it is essential to understand the three primary “roles” in a Chat Completion API. Think of it as a script for a play where each participant has a specific job.


1. System Prompt (The Architect)

The System Prompt sets the stage. It defines the AI’s persona, boundaries, behavioral rules, and the “tone” of the conversation. It is the foundational layer that the AI refers to throughout the entire session.

  • Goal: Establish “who” the AI is and “how” it must behave.
  • Usage: Define constraints, output formats, and personality.
  • Your Example: The instructions you provided (“You are a data processorโ€ฆ”) are a classic System Prompt.

2. User Prompt (The Client)

The User Prompt is the specific request or input from the human. It provides the “what”โ€”the actual task or question that needs to be addressed right now.

  • Goal: Provide the data, question, or instruction for the current turn.
  • Usage: Ask questions or provide the raw text/data to be processed.

3. Assistant Prompt (The Example)

The Assistant Prompt represents the AI’s previous responses. In “few-shot prompting,” you can manually write Assistant prompts to show the AI exactly how you want it to respond.

  • Goal: Provide “gold standard” examples of the desired output.
  • Usage: Pattern matching. By showing a mock Assistant response, the AI learns the expected style better than through instructions alone.

Comparison Table

RoleResponsibilityAnalogy
SystemRules, Tone, ConstraintsThe Employee Handbook
UserTask, Data, QueryThe Customer’s Order
AssistantPrevious Answers, ExamplesThe Sample Product

How to Use Them (Technical Implementation)

When using these in a reusable format (like JSON for an API), it looks like this:

[
  {
    "role": "system",
    "content": "You are a data processor. Output ONLY markdown code blocks. Language: English."
  },
  {
    "role": "user",
    "content": "Process this: Name: John, Age: 30"
  },
  {
    "role": "assistant",
    "content": "json\n{\n \"name\": \"John\",\n \"age\": 30\n}\n```"
  },
  {
    "role": "user",
    "content": "Process this: Name: Sarah, Age: 25"
  }
]
Our Score
Click to rate this post!
[Total: 0 Average: 0]
Visited 8 times, 1 visit(s) today

Leave a Comment

Your email address will not be published. Required fields are marked *