Metni özetleme ve düzenleme

Python ile DeepSeek Kullanımı

James Chapman

Curriculum Manager, DataCamp

Özet...

  • Soru-Cevap
response = client.chat.completions.create(
  model="deepseek-ai/DeepSeek-V3",
  messages=[{"role": "user", "content": "How many days are in October?"}]
)

print(response.choices[0].message.content)
Ekim ayında **31 gün** vardır.  

Gregoryen takvimde 31 gün çeken yedi aydan biridir...
Python ile DeepSeek Kullanımı

Metin düzenleme

  • Örnek: ad, zamir ve unvanı güncelleme

$$

prompt = """
Update name to Maarten, pronouns to he/him, and job title to Senior Content Developer
in the following text:

Joanne is a Content Developer at DataCamp. Her favorite programming language is R,
which she uses for her statistical analyses.
"""
Python ile DeepSeek Kullanımı

Metin düzenleme

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V3",

messages=[{"role": "user", "content": prompt}]
) print(response.choices[0].message.content)
İstenen değişikliklerle güncellenen metin:

Maarten, DataCamp'te Kıdemli İçerik Geliştiricidir. En sevdiği programlama dili R'dir
ve bunu istatistiksel analizlerinde kullanır.

Başka bir ayarlama isterseniz bildiriniz.
Python ile DeepSeek Kullanımı

Metin özetleme

  • Örnek: müşteri sohbet dökümlerinin özeti

Müşteri destek ekibi

text = """
Customer: Hi, I'm trying to log into 
my account, but it keeps saying 
my password is incorrect. I'm sure 
I'm entering the right one.  

Support: I'm sorry to hear that! 
Have you tried resetting your password?  
...
"""
Python ile DeepSeek Kullanımı

Metin özetleme

prompt = f"""Summarize the customer support chat 
             in three concise key points: {text}"""


response = client.chat.completions.create( model="deepseek-ai/DeepSeek-V3", messages=[{"role": "user", "content": prompt}] ) print(response.choices[0].message.content)
1. **Oturum Açma Sorunu**: Müşteri, parola sorunu ve eksik sıfırlama bağlantısı nedeniyle oturum açamadı.  
2. **Parola Sıfırlama Önerisi**: Destek, gönderildiğini doğruladıktan sonra sıfırlama e-postasını yeniden gönderdi.  
3. **Hızlı Çözüm**: Müşteri, Google ile oturum açarak sorunu çözdü.
Python ile DeepSeek Kullanımı

Yanıt uzunluğunu kontrol etme

  • max_tokens = 5
response = client.chat.completions.create(
  model="deepseek-ai/DeepSeek-V3",
  messages=[{"role":"user",
      "content":"Write a haiku about AI."}],
  max_tokens=5
)

**Sessiz devreler mırıldanır
  • max_tokens = 30
response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V3",
    messages=[{"role":"user",
      "content":"Write a haiku about AI."}],
    max_tokens=30
)

**Sessiz devreler mırıldanır,**  
**ışık ve mantık düşünceleri filizlenir—**  
**bizim ötemizde zihinler.**
Python ile DeepSeek Kullanımı

Tokenları anlama

$$

  • Tokenlar: Yapay zekânın metni anlamasına yardımcı olan metin birimleri

$$

"How can the OpenAI API deliver business value?" cümlesi; her bir token farklı renkle vurgulanmış.

1 https://lunary.ai/deepseek-tokenizer
Python ile DeepSeek Kullanımı

Maliyeti hesaplama

 

  • API kullanım maliyeti, platforma, modele ve token sayısına bağlıdır 💰

    • Modeller, maliyet/token üzerinden fiyatlandırılır
    • Girdi ve çıktı tokenlarının maliyeti farklı olabilir
  • max_tokens artarsa maliyet artar 📈

Screenshot 2025-03-05 at 11.46.54.png

Python ile DeepSeek Kullanımı

Maliyeti hesaplama

prompt = f"""Summarize the customer support chat 
             in three concise key points: {text}"""

max_tokens = 500

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V3",
    messages=[{"role": "user", "content": prompt}], 
    max_tokens=max_tokens
)
Python ile DeepSeek Kullanımı

Maliyeti hesaplama

# Define price per token
input_token_price = 1.25 / 1_000_000
output_token_price = 1.25 / 1_000_000

# Extract token usage input_tokens = response.usage.prompt_tokens
output_tokens = max_tokens
# Calculate cost cost = (input_tokens * input_token_price + output_tokens * output_token_price) print(f"Estimated cost: ${cost}")
Tahmini maliyet: $0.00848
Python ile DeepSeek Kullanımı

Hadi pratik yapalım!

Python ile DeepSeek Kullanımı

Preparing Video For Download...