Die Assistant-Rolle nutzen

Arbeiten mit DeepSeek in Python

James Chapman

AI Curriculum Lead, DataCamp

Single-Turn-Aufgaben

response = client.chat.completions.create(
  model="deepseek-ai/DeepSeek-V4.1-Flash",
  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: steuert das Verhalten des Assistants
  • User: instruiert den Assistant
  • Assistant: Antwort auf die User-Anweisung
Arbeiten mit DeepSeek in Python

Beispiele geben

 

  • Modell in die richtige Richtung lenken
  • Assistant-Nachrichten sind eine strukturiertere Form von Shot-Prompting
  • Beispiel: Python-Programmierungs-Tutor
    • Beispiel-Fragen und -Antworten von Usern

Eine Data-Science-Eule.

Arbeiten mit DeepSeek in Python

Beispiele geben

response = client.chat.completions.create(
  model="deepseek-ai/DeepSeek-V4.1-Flash",
  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?"}] )
Arbeiten mit DeepSeek in Python

Die Antwort

print(response.choices[0].message.content)
Mutable objects can be changed after creation (like lists), while immutable objects cannot
(like tuples or strings).
  • Experimentiere mit der Anzahl der Beispiele
Arbeiten mit DeepSeek in Python

System vs. Assistant vs. User

System → wichtig für Vorlagen-Formatierung

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

Assistant → Beispielunterhaltungen

User → Kontext für die neue Eingabe (oft Single-Turn)

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

Job Title: Data Engineer
...
Arbeiten mit DeepSeek in Python

Lass uns üben!

Arbeiten mit DeepSeek in Python

Preparing Video For Download...