Python ile DeepSeek Kullanımı
James Chapman
Curriculum Manager, DataCamp
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...
$$
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.
"""
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.

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?
...
"""
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ü.
max_tokens = 5response = 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 = 30response = 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.**
$$
$$

API kullanım maliyeti, platforma, modele ve token sayısına bağlıdır 💰
max_tokens artarsa maliyet artar 📈

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
)
# 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_tokensoutput_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ı