Bul ve değiştir
Bul-ve-değiştir araçları onlarca yıldır var, ancak genellikle yalnızca tam kelimeleri veya ifadeleri bulup değiştirmekle sınırlıdır. Sana arabaları tartışan bir metin bloğu verildi ve bu metni, bir sohbet tamamlama modelini kullanarak uçakları tartışacak şekilde uygun biçimde güncelleyeceksin.
Uyarı: Kısa sürede çok sayıda istek gönderir veya çok fazla token kullanırsan, hız sınırına takılıp openai.error.RateLimitError görebilirsin. Bu hatayı görürsen, lütfen kotanın sıfırlanması için bir dakika bekle; ardından yeniden istek göndermeye başlayabilmelisin.
Bu egzersiz
OpenAI API ile Çalışmak
kursunun bir parçasıdırEgzersiz talimatları
- Chat Completions uç noktasına bir istek oluştur; en fazla
100token kullan. - API'den gelen metin yanıtını çıkar ve yazdır.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
client = OpenAI(api_key="")
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 Completions endpoint
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "____": ____}],
____
)
# Extract and print the response text
print(response.choices[0].____.____)