चैट रोल्स और सिस्टम मैसेज

Python में DeepSeek के साथ काम करना

James Chapman

AI Curriculum Lead, DataCamp

एक टर्न से कई टर्न तक

 

सिंगल-टर्न टास्क

  • टेक्स्ट जनरेशन
  • टेक्स्ट ट्रांसफॉर्मेशन
  • क्लासिफिकेशन

एक सिंगल-टर्न टास्क: एक प्रॉम्प्ट और एक रिस्पॉन्स।

Python में DeepSeek के साथ काम करना

एक टर्न से कई टर्न तक

 

सिंगल-टर्न टास्क

  • टेक्स्ट जनरेशन
  • टेक्स्ट ट्रांसफॉर्मेशन
  • क्लासिफिकेशन

 

मल्टी-टर्न बातचीत

→ पिछले प्रॉम्प्ट और रिस्पॉन्स पर आगे बढ़ें

एक मल्टी-टर्न टास्क: कई प्रॉम्प्ट और रिस्पॉन्स।

Python में DeepSeek के साथ काम करना

रोल्स

 

  • System: असिस्टेंट के behavior को नियंत्रित करता है
  • User: असिस्टेंट को instruct करता है
  • Assistant: यूज़र निर्देश पर response देता है
    • डेवलपर उदाहरण देने के लिए लिख सकता है

चैट इंटरैक्शन के तीन रोल: सिस्टम, यूज़र, और असिस्टेंट।

Python में DeepSeek के साथ काम करना

रिक्वेस्ट सेटअप

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V4-Pro",
    messages=[{"role": "user", "content": prompt}]
)
Python में DeepSeek के साथ काम करना

प्रॉम्प्ट सेटअप

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 में DeepSeek के साथ काम करना

रिक्वेस्ट बनाना

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 में DeepSeek के साथ काम करना

दुरुपयोग कम करना

 

  • System message: guardrails शामिल कर सकता है
    • मॉडल आउटपुट पर प्रतिबंध

सड़क के किनारे लगे गार्डरेल।

एक फ़ाइनेंशियल ट्यूटर चैटबॉट और एक फ़ाइनेंशियल एडवाइज़र चैटबॉट।

Python में DeepSeek के साथ काम करना

सिस्टम मैसेज से दुरुपयोग कम करना

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 में DeepSeek के साथ काम करना

सिस्टम मैसेज से दुरुपयोग कम करना

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 में DeepSeek के साथ काम करना

अभ्यास करते हैं!

Python में DeepSeek के साथ काम करना

Preparing Video For Download...