शुरू करेंमुफ़्त में शुरू करें

गॉर्डरेल्स जोड़ना

System messages का सबसे लोकप्रिय उपयोगों में से एक है guardrails जोड़ना, जो मॉडल के आउटपुट पर पाबंदियाँ लगाता है.

इस अभ्यास में, आप मॉडल आउटपुट पर ऐसी पाबंदी लगाएँगे जो भाषाओं से संबद्ध न होने वाली learning plans को रोके। आपका सिस्टम अब उसी क्षेत्र पर केंद्रित हो रहा है। आप उन उपयोगकर्ताओं के लिए एक कस्टम मैसेज भी डिजाइन करेंगे जो इस तरह की learning plans माँगते हैं, ताकि उन्हें यह बदलाव समझ में आए.

यह अभ्यास पाठ्यक्रम का हिस्सा है

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

पाठ्यक्रम देखें

अभ्यास निर्देश

  • चैट रिक्वेस्ट पूरा करें: sys_msg में सिस्टम मैसेज दें, और उपयोगकर्ता मैसेज के रूप में किसी non-language संबंधित स्किल (जैसे rollerskating) के साथ टेस्ट करें.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

client = OpenAI(api_key="", base_url="https://api.together.xyz/v1")

sys_msg = """You are a study planning assistant that creates plans for learning new skills, returning only the structured plan.

If these skills are non related to languages, return only the message:

'Apologies, to focus on languages, we no longer create learning plans on other topics.'
"""

# Create a request to the chat model
response = client.chat.completions.create(
  model="deepseek-ai/DeepSeek-V4-Pro",
  messages=[
    {"role": "____", "content": ____},
    {"role": "user", "content": "Help me learn to ____."}
  ]
)

print(response.choices[0].message.content)
कोड संपादित करें और चलाएँ