Role management in the Chat Completions API

There are only three types of roles available: system, user, and assistant.
However, you can include different names within the same role.

For example, you can include conversation histories of userA and userB.

completion = client.chat.completions.create(
  model="gpt-4o",
  messages=[
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "name": "userA","content": "Hello!"},
    {"role": "user", "name": "userB","content": "Hi there!"}
  ]
)

print(completion.choices[0].message)

In the same way, is it possible to specify event as the value for the name key.

3 Likes