Your name instead of 'user' and 'assistant'

Hello, can I use names other than ‘user’ and ‘assistant’?

Initialize the list of messages, starting with a user message

messages = [
{“role”: “system”, “content”: “You are the user”},
{“role”: “John”, “content”: “What’s the weather like in Paris today?”},
{“role”: “TV Host”, “content”: “The weather in Paris today will be clear, with a temperature of around 20 degrees Celsius.”},
{“role”: “John”, “content”: “What’s your name?”},
]

Or is it best to stick with ‘user’ and ‘assistant’ by default? How can I specify the username and assistant’s name? Please provide an example.

You can certainly try it! However, the model has been trained to respond to user, system and assistant. Your experience may vary depending on how you make use of this and it may in fact cause API error if it is reliant upon specific role types for some functionality.

The API requires in the role only the following: system, assitant or user.

You can pass the name of the user in a system message, but the role of the user should always be user.

The API schema of the chat completion endpoints validates on the role value of a messages dictionary being one of [system, user, assistant, function].

You can inject information into the system message content, but you can also use the “name” key alongside the “role” key within a message to specify a name using English alphabet or numbers (no spaces. The AI can recognize its own name and also that of a user.

1 Like