0
0
Prompt Engineering / GenAIml~10 mins

Message roles (system, user, assistant) in Prompt Engineering / GenAI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the system message role in a chat API call.

Prompt Engineering / GenAI
messages = [{"role": "[1]", "content": "You are a helpful assistant."}]
Drag options to blanks, or click blank then click option'
Asystem
Buser
Cassistant
Dbot
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'user' instead of 'system' for the initial message.
2fill in blank
medium

Complete the code to add a user message role with a question.

Prompt Engineering / GenAI
messages.append({"role": "[1]", "content": "What is AI?"})
Drag options to blanks, or click blank then click option'
Aassistant
Bsystem
Cuser
Dclient
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'assistant' instead of 'user' for user input.
3fill in blank
hard

Fix the error in the code to correctly add an assistant reply role.

Prompt Engineering / GenAI
messages.append({"role": "[1]", "content": "AI stands for Artificial Intelligence."})
Drag options to blanks, or click blank then click option'
Auser
Bsystem
Cbot
Dassistant
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'user' or 'system' instead of 'assistant' for replies.
4fill in blank
hard

Fill both blanks to create a conversation with system and user roles.

Prompt Engineering / GenAI
messages = [[1]{"role": "system", "content": "You are a friendly bot."}, [2]{"role": "user", "content": "Hello!"}]
Drag options to blanks, or click blank then click option'
A{
B[
C]
D}
Attempts:
3 left
💡 Hint
Common Mistakes
Using curly braces for the list instead of square brackets.
5fill in blank
hard

Fill all three blanks to add system, user, and assistant messages correctly.

Prompt Engineering / GenAI
messages = [[1]{"role": "system", "content": "You are helpful."}, [2]{"role": "user", "content": "What is ML?"}, [3]{"role": "assistant", "content": "ML means Machine Learning."}]
Drag options to blanks, or click blank then click option'
A{
B[
C]
D}
Attempts:
3 left
💡 Hint
Common Mistakes
Using curly braces for the list or missing brackets.