Aan de slagGa gratis aan de slag

Utilizing systems messages

Chat models support three different chat message roles:

  • System: controls assistant's behavior
  • User: instruct the assistant
  • Assistant: response to user instruction

In this exercise, you'll begin to design an AI system for helping people learn new skills, using a system message to set an appropriate model behavior.

Deze oefening maakt deel uit van de cursus

Working with DeepSeek in Python

Cursus bekijken

Oefeninstructies

  • Create a request using both system and user messages to create a study plan to learn to speak Dutch.
  • Extract and print the assistant's text response.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

client = OpenAI(api_key="", base_url="https://api.together.xyz/v1")

# Create a request to the chat model
response = client.chat.completions.create(
  model="deepseek-ai/DeepSeek-V3",
  max_tokens=150,
  messages=[
    {"role": ____,
     "content": "You are a study planning assistant that creates plans for learning new skills. Only return the structured plan."},
    {"____": "____",
     "____": "I want to learn to speak Dutch."}
  ]
)

# Extract the assistant's text response
print(response.choices[0].____.____)
Code bewerken en uitvoeren