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

assistant मैसेज जोड़ना

चैट मोड बातचीत-आधारित एप्लिकेशन बनाने के लिए बेहतरीन है, और आप मॉडल को आगे बढ़ाने के लिए बातचीत का एक हिस्सा पहले से देकर इसे और बेहतर बना सकते हैं.

इस geography ट्यूटर एप्लिकेशन को बेहतर बनाइए: नीचे दिए गए छात्र के उदाहरण प्रॉम्प्ट और आदर्श मॉडल उत्तर को messages में शामिल करें:

  • Example Question: Give me a quick summary of Portugal.
  • Example Answer: Portugal is a country in Europe that borders Spain. The capital city is Lisboa.

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

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

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

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

  • दिए गए example question और answer को मॉडल को भेजे जाने वाले messages में user-assistant जोड़ी के रूप में जोड़ें.
    • Example Question: Give me a quick summary of Portugal.
    • Example Answer: Portugal is a country in Europe that borders Spain. The capital city is Lisboa.

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

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

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

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V4-Pro",
    # Add a user and assistant message for in-context learning
    messages=[
        {"role": "system", "content": "You are a helpful Geography tutor that generates concise, one-sentence summaries for different countries."},
        ____,
        ____,
        {"role": "user", "content": "Give me a quick summary of Greece."}
    ]
)

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