Find and replace
Find-and-replace टूल दशकों से मौजूद हैं, लेकिन ये अक्सर केवल बिल्कुल मिलते-जुलते शब्दों या वाक्यांशों की पहचान और उन्हें बदलने तक सीमित रहते हैं। आपको कारों पर चर्चा करता हुआ एक टेक्स्ट ब्लॉक दिया गया है, और आप एक chat completion मॉडल का उपयोग करके उस टेक्स्ट को इस तरह अपडेट करेंगे कि अब वही बात planes के बारे में हो, और टेक्स्ट को उपयुक्त रूप से बदला जाए।
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में DeepSeek के साथ काम करना
अभ्यास निर्देश
promptकोdeepseek-ai/DeepSeek-V4.1-Flashपर भेजने के लिए एक रिक्वेस्ट बनाएँ, जो cars पर आधारित टेक्स्ट पैसेज को planes में बदल दे; अधिकतम100tokens का उपयोग करें.- API से मिला टेक्स्ट response निकालें और प्रिंट करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
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.1-Flash",
messages=[{"role": "user", "____": ____}],
____
)
# Extract and print the response text
print(response.choices[0].____.____)