Tạo văn bản

Làm việc với DeepSeek bằng Python

James Chapman

Curriculum Manager, DataCamp

  • Văn bản có khả năng cao nhất để hoàn thành đoạn hội thoại
response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V3",

messages=[{"role": "user", "content": "Hi! I'm James and I'm a Curriculum Manager at DataCamp."}]
) print(response.choices[0].message.content)
Hi James! It's great to meet you. As a **Curriculum Manager at DataCamp**, you must
play a key role in shaping the learning experience for data science and analytics
students. How can I assist you today?
  • Phản hồi là không xác định (ngẫu nhiên theo bản chất)
Làm việc với DeepSeek bằng Python

Một chatbot hỗ trợ khách hàng nhận hai yêu cầu tương tự về ngữ nghĩa.

1 Tạo bằng GPT-4o
Làm việc với DeepSeek bằng Python

Kiểm soát độ ngẫu nhiên của phản hồi

  • temperature: điều khiển tính quyết định từ 0 (rất quyết định) đến 2 (rất ngẫu nhiên)
response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V3",
    messages=[{"role": "user",
             "content": "Hi! I'm James and I'm a Curriculum Manager at DataCamp."}],

temperature=2
) print(response.choices[0].message.content)
Hi James! Welcome to DataCamp — it's great to connect with someone who works on
shaping learning experiences for data skills. What does your role typically involve
as a Curriculum Manager at **DataCamp?** Perhaps one-on95 kWielpulses.Z.blog.from...
Làm việc với DeepSeek bằng Python

Tạo văn bản: tiếp thị

prompt = "Generate a powerful tagline for a new electric vehicle 
that highlights innovation and sustainability."
response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V3",
    messages=[{"role": "user", "content": prompt}]
)

print(response.choices[0].message.content)
**"Drive the Future - Zero Emissions, Infinite Innovation."**  
This tagline captures the essence of cutting-edge technology and eco-conscious...
Làm việc với DeepSeek bằng Python

Làm sạch phản hồi

prompt = "Generate a powerful tagline for a new electric vehicle 
that highlights innovation and sustainability. Return only the tagline
without formatting."

# Create a request to the chat model
# ...
"Drive the Future - Clean, Smart, Electric."
Làm việc với DeepSeek bằng Python

Tạo văn bản: mô tả sản phẩm

prompt = """Write a compelling e-commmerce product description for the UltraFit
Smartwatch in paragraph form. Highlight its key features:

10-day battery life, 24/7 heart rate and sleep tracking, built-in GPS, water
resistance up to 50 meters, and lightweight design.

Use a persuasive and engaging tone to appeal to fitness enthusiasts and busy
professionals.
"""

response = client.chat.completions.create( model="deepseek-ai/DeepSeek-V3", messages=[{"role": "user", "content": prompt}])
Làm việc với DeepSeek bằng Python

Tạo văn bản: mô tả sản phẩm

print(response.choices[0].message.content)
"The UltraFit Smartwatch is your all-in-one health and fitness companion. 
Stay on top of your wellness with 24/7 heart rate and sleep tracking, 
while the built-in GPS keeps you on course during runs. 
With a 10-day battery life, you can track your progress without constant recharging. 
Designed for both workouts and daily wear, its  lightweight build and 50-meter
water resistance make it the perfect smartwatch for an active lifestyle."
  • Lặp lại! Thêm chi tiết vào prompt và chạy lại yêu cầu
  • Video tiếp theo → cung cấp ví dụ cho mô hình
Làm việc với DeepSeek bằng Python

Ayo berlatih!

Làm việc với DeepSeek bằng Python

Preparing Video For Download...