Utilizing the assistant role

Working with DeepSeek in Python

James Chapman

Curriculum Manager, DataCamp

Single-turn tasks

response = client.chat.completions.create(
  model="deepseek-ai/DeepSeek-V3",
  messages=[{"role": "system",
             "content": "You are a Python programming tutor who responds using concise,
                         one-sentence explanations."},
            {"role": "user",
             "content": "What is the difference between mutable and immutable objects?"}]
)
  • System: controls assistant's behavior
  • User: instruct the assistant
  • Assistant: response to user instruction
Working with DeepSeek in Python

Providing examples

 

  • Steer model in the right direction
  • Providing assistant messages is a more structured form of shot-prompting
  • Example: Python Programming Tutor
    • Example user questions and answers

A data science owl.

Working with DeepSeek in Python

Providing examples

response = client.chat.completions.create(
  model="deepseek-ai/DeepSeek-V3",
  messages=[{"role": "system",
             "content": "You are a Python programming tutor who responds using concise,
                         one-sentence explanations."},

{"role": "user", "content": "How do you define a Python list?"},
{"role": "assistant", "content": "Lists are defined by enclosing a comma-separated sequence of objects inside square brackets [ ]."},
{"role": "user", "content": "What is the difference between mutable and immutable objects?"}] )
Working with DeepSeek in Python

The response

print(response.choices[0].message.content)
Mutable objects can be changed after creation (like lists), while immutable objects cannot
(like tuples or strings).
  • Experiment with the number of examples
Working with DeepSeek in Python

System vs. assistant vs. user

System → important template formatting

Output the information in this format:
name | age | occupation

Assistant → example conversations

User → context required for the new input (often single-turn)

Create a job advert for an AI Engineer. Use this job advert as a template:

Job Title: Data Engineer
...
Working with DeepSeek in Python

Let's practice!

Working with DeepSeek in Python

Preparing Video For Download...