DeepSeek ile çok turlu konuşmalar

Python ile DeepSeek Kullanımı

James Chapman

AI Curriculum Lead, DataCamp

Asistan mesajları

response = client.chat.completions.create(
  model="deepseek-ai/DeepSeek-V4-Pro",
  messages=[{"role": "system",
             "content": "You are a Python programming tutor who responds using concise,
                         one-sentence explanations."},

{"role": "user", "content": "How do you define a Python list?"},
{"role": "assistant", "content": "Lists are defined by enclosing a comma-separated sequence of objects inside square brackets [ ]."},
{"role": "user", "content": "What is the difference between mutable and immutable objects?"}] )
Python ile DeepSeek Kullanımı

Bir konuşma kurma

Asistana adımın James olduğunu söyleyen bir kullanıcı isteği gönderiliyor. Asistan "Hi James!" diye yanıt veriyor.

Python ile DeepSeek Kullanımı

Bir konuşma kurma

Asistanın "Hi James!" yanıtı, sözlüklerden oluşan messages listesine ekleniyor.

Python ile DeepSeek Kullanımı

Bir konuşma kurma

Asistanın "Hi James!" yanıtı, sözlüklerden oluşan messages listesine ekleniyor.

Python ile DeepSeek Kullanımı

Bir konuşma kurma

Kullanıcının "What is my name?" sorusu, sözlüklerden oluşan mesaj listesinin sonuna ekleniyor.

Python ile DeepSeek Kullanımı

Bir konuşma kurma

Asistan "Your name is James." diye yanıt veriyor.

Python ile DeepSeek Kullanımı
messages = [{"role": "system",
             "content": "You are a Python programming tutor who responds using concise,
                         one-sentence explanations."}]


user_qs = ["Why is Python so popular?", "Summarize this in one sentence."]
for q in user_qs:
print("User: ", q)
user_dict = {"role": "user", "content": q}
messages.append(user_dict)
response = client.chat.completions.create( model="deepseek-ai/DeepSeek-V4-Pro", messages=messages )
assistant_dict = {"role": "assistant", "content": response.choices[0].message.content} messages.append(assistant_dict)
print("Assistant: ", response.choices[0].message.content, "\n")
Python ile DeepSeek Kullanımı

Bir yapay zekâyla konuşma

User:  Why is Python so popular?
Assistant:  Python is popular because it's easy to learn, has a simple syntax, and
offers powerful libraries for various applications like web development, data
science, and automation. 

User:  Summarize this in one sentence.
Assistant:  Python's simplicity, versatility, and extensive libraries make it
widely popular.
Python ile DeepSeek Kullanımı

Hadi pratik yapalım!

Python ile DeepSeek Kullanımı

Preparing Video For Download...