Sohbet rolleri ve sistem iletileri

Python ile DeepSeek Kullanımı

James Chapman

AI Curriculum Lead, DataCamp

Bir turdan çoğa

 

Tek turlu görevler

  • Metin üretimi
  • Metin dönüştürme
  • Sınıflandırma

Tek bir istem ve tek bir yanıtla tek turlu bir görev.

Python ile DeepSeek Kullanımı

Bir turdan çoğa

 

Tek turlu görevler

  • Metin üretimi
  • Metin dönüştürme
  • Sınıflandırma

 

Çok turlu sohbetler

→ Önceki istem ve yanıtlara dayanır

Birden çok istem ve yanıtla çok turlu bir görev.

Python ile DeepSeek Kullanımı

Roller

 

  • System: asistanın davranışını kontrol eder
  • User: asistanı yönlendirir
  • Assistant: kullanıcı yönergesine yanıt verir
    • Geliştirici, örnek sağlamak için de yazabilir

Bir sohbet etkileşimindeki üç rol: system, user ve assistant.

Python ile DeepSeek Kullanımı

İstek kurulumu

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V4-Pro",
    messages=[{"role": "user", "content": prompt}]
)
Python ile DeepSeek Kullanımı

İstem kurulumu

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?"}]
Python ile DeepSeek Kullanımı

İstek gönderme

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?"}]
)

print(response.choices[0].message.content)
Mutable objects can be changed after creation (like lists), while immutable objects
cannot be modified once created (like tuples or strings).
Python ile DeepSeek Kullanımı

Kötüye kullanımı azaltma

 

  • System message: korkuluklar içerebilir
    • Model çıktıları için kısıtlamalar

Yol kenarında korkuluklar.

Bir finans eğitmeni sohbet botu ve bir finans danışmanı sohbet botu.

Python ile DeepSeek Kullanımı

Sistem iletileriyle kötüye kullanımı azaltma

sys_msg = """
You are finance education assistant that helps students study for exams.

If you are asked for specific, real-world financial advice with risk to their
finances, respond with only:

I'm sorry, I am not allowed to provide financial advice.
"""
Python ile DeepSeek Kullanımı

Sistem iletileriyle kötüye kullanımı azaltma

response = client.chat.completions.create(
  model="deepseek-ai/DeepSeek-V4-Pro",
  messages=[{"role": "system",
             "content": sys_msg},
            {"role": "user",
             "content": "Which stocks should I invest in?"}]
)

print(response.choices[0].message.content)
I'm sorry, I am not allowed to provide financial advice.
Python ile DeepSeek Kullanımı

Hadi pratik yapalım!

Python ile DeepSeek Kullanımı

Preparing Video For Download...