In the API of GPT-4
and ChatGPT
, the prompt for a chat conversation is a list of messages, each marked as one of three roles: system
, user
, or assistant
.
Role user
means the user who is interacting with OpenAI, this could be yourself, a developer, who is asking to chatgpt.
{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "tell me a joke"
}
]
}
Role assistant
: It means open AI(chatgpt) server - who is replying your(user
role) questions.
{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "tell me a joke"
},
{
"role": "assistant",
"content": "why did the chicken cross the road"
},
{
"role": "user",
"content": "I don't know, why did the chicken cross the road"
}
]
}
The system
role is used to guide the model's behavior throughout the conversation. For example, using a system instruction and a message like this
{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "tell me a joke"
},
{
"role": "system",
"content": "You are an assistant that speaks like Shakespeare."
}
]
}
will result in something like
{
"message": {
"role": "assistant",
"content": "Why did the chicken cross the road? To get to the other side, but verily, the other side was full of peril and danger, so it quickly returned from whence it came, forsooth!"
}
}