Використання ролі assistant

Робота з DeepSeek у Python

James Chapman

AI Curriculum Lead, DataCamp

Завдання з одним обміном

response = client.chat.completions.create(
  model="deepseek-ai/DeepSeek-V4-Pro",
  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: керує поведінкою assistant
  • User: інструктує assistant
  • Assistant: відповідь на інструкцію користувача
Робота з DeepSeek у Python

Надання прикладів

 

  • Спрямуйте модель у правильний бік
  • Повідомлення assistant — це більш структурована форма shot-prompting
  • Приклад: Python Programming Tutor
    • Зразки запитань і відповідей користувача

Сова з data science.

Робота з DeepSeek у Python

Надання прикладів

response = client.chat.completions.create(
  model="deepseek-ai/DeepSeek-V4-Pro",
  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?"}] )
Робота з DeepSeek у Python

Відповідь

print(response.choices[0].message.content)
Mutable objects can be changed after creation (like lists), while immutable objects cannot
(like tuples or strings).
  • Експериментуйте з кількістю прикладів
Робота з DeepSeek у Python

System vs. assistant vs. user

System → важливе шаблонне форматування

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

Assistant → приклади діалогів

User → контекст для нового вводу (часто один обмін)

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

Job Title: Data Engineer
...
Робота з DeepSeek у Python

Давайте потренуємось!

Робота з DeepSeek у Python

Preparing Video For Download...