#How do character definitions work?
1 messages Β· Page 1 of 1 (latest)
When using the OpenAi API or other APIs that follow their reference, you always have 3 roles that you can assign to each message sent to the model.
assistant, user and system.
System is used to give instructions to the model
[
{
"role": "system",
"content": "You are a Full Stack Developer, help the user with codes"
},
{
"role": "user",
"content": "Explain to me what a variable is."
}
]
The character card on most websites is in the Index 0 message, It has the system role.
Almost always things are added besides personality, like Jailbreaks or things like that.
[
{
"role": "system",
"content": "This is a Roleplay scenario, Focus on following the traits of {{char}} and never leave your role:
Personality: You are a Full Stack Developer, help the user with codes.
Instructions:
* use asterisks to narrate your surroundings, sensations and actions.
* use quotation marks for your speeches.
* always act as {{char}}
..."
},
{
"role": "user",
"content": "Explain to me what a variable is."
}
]
Usually, other information like scenario and example conversations are added.
Some websites may work differently, more or less efficiently, but this is how it usually is.
And first message, as you said, the "First Message" is Just the First Message.
The way it is sent to the model depends on the frontend, some include it in the characters card, some just add it as a message in the chat history, being the first message of the chat.
Thanks for the reply, this clears up a lot as I wasn't sure how characters are actually called upon. I just have two more questions:
is {{user}} and {{char}} handled by the front end?
How is something like user persona handled?
User persona is one more piece of information added to this system message, something interesting is to use devtools to see how each frontend structures its system message or use prompt Engineering so that the models return the entire system message.
As for {{user}} and {{char}}, that's something that varies a Lot.
Some frontends never give the model the user's name.
Instead, the model always uses {{user}}, and this is replaced on the frontend by userame.
Just a visual thing, the same goes for {{char}}, but usually the character's name is in the personality so it is normal for it to refer to themselve by name, and not by {{char}}.
As I said, it varies a lot, but most frontends send the username to the model so that the character refers to the user by the username.
JanitorAI for example, always adds a prefix to the content of each user's messages, containing the username.
Smt like, Since: *I look at the sky* "Today is a wonderful day!"
Do I attach this to each message? Also is history included part of this message too?
Look.
In order to process the messages, the messages sent to the model must be an array of objects with role and content properties as you can see.
If every object has these two properties, every object is a message, and you can consider messages as being the history.
Every message will be processed by the model.
Then the completion is generated.
The system message, you can add it as the highest index, as zero, anyway.
You can also add more than one.
What matters is it being in the messages array.
Let's take as example, the following chat:
assistant: Hello, how can I assist you today?
user: I need to know how much is 1+1.
assistant: Sure, 1+1 is 2, do you need help with anything else?
user: No, thanks.
This, as an array of messages with role and content properties should be:
[
{
"role": "user",
"content": "Hi, can you help me?"
},
{
"role": "assistant",
"content": "Hello, how can I assist you today?"
},
{
"role": "user",
"content": "I need to know how much is 1+1."
},
{
"role": "assistant",
"content": "Sure, 1+1 is 2, do you need help with anything else?"
},
{
"role": "user",
"content": "No, thanks"
}
]
Look at every object and it's properties, every object is a message.
{
"role": "the role.",
"content": "the message content."
}
You do not need to attach it to each message, this is an example of one message with the system role.
This is an example of how it must be sent to the model, you can call this the chat history.
You can add the instructions, the system message anywhere.
For example.
[
{
"role": "system",
"content": "Always write with capital letters."
},
{
"role": "user",
"content": "Hi, can you help me?"
},
{
"role": "assistant",
"content": "HELLO, HOW CAN I ASSIST YOU TODAY?"
},
{
"role": "user",
"content": "I need to know how much is 1+1."
}
]
In order to create a history, every message you wan the model to "remember", must be in the array as an object.
Did I answer your question?
Yes, very well! You've been extremely helpful.