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

Find and replace

Find-and-replace टूल दशकों से मौजूद हैं, लेकिन ये अक्सर केवल बिल्कुल मिलते हुए शब्दों या वाक्यांशों को पहचानने और बदलने तक सीमित रहते हैं. आपको कारों पर चर्चा करता एक टेक्स्ट ब्लॉक दिया गया है, और आप एक चैट कम्प्लीशन मॉडल का उपयोग करके उसी टेक्स्ट को इस तरह अपडेट करेंगे कि वह अब प्लेन्स पर बात करे, और जहाँ ज़रूरी हो वहाँ टेक्स्ट को सही तरह से बदले.

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

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

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

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

  • prompt को deepseek-ai/DeepSeek-V4-Pro पर भेजने के लिए एक रिक्वेस्ट बनाइए, जो कारों वाले टेक्स्ट पैसेज को प्लेन्स में बदल दे; अधिकतम 100 टोकन का उपयोग करें.
  • API से टेक्स्ट रेस्पॉन्स एक्सट्रैक्ट कीजिए और प्रिंट कीजिए.

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

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

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

prompt="""Replace car with plane and adjust phrase:
A car is a vehicle that is typically powered by an internal combustion engine or an electric motor. It has four wheels, and is designed to carry passengers and/or cargo on roads or highways. Cars have become a ubiquitous part of modern society, and are used for a wide variety of purposes, such as commuting, travel, and transportation of goods. Cars are often associated with freedom, independence, and mobility."""

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

# Extract and print the response text
print(response.choices[0].____.____)
कोड संपादित करें और चलाएँ