CommencerCommencer gratuitement

Text summarization

One really common use case for DeepSeek models is summarizing text. This has a ton of applications in business settings, including summarizing reports into concise one-pagers or a handful of bullet points, or extracting the next steps and timelines for different stakeholders.

In this exercise, you'll summarize a passage of text on financial investment (finance_text) into two concise bullet points using DeepSeek's chat model.

Cet exercice fait partie du cours

Working with DeepSeek in Python

Afficher le cours

Instructions

  • Use an f-string to insert finance_text into prompt.
  • Create a request, sending the prompt provided; use a maximum of 400 tokens.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

client = OpenAI(api_key="", base_url="https://api.together.xyz/v1")

# Use an f-string to format the prompt
prompt = f"""Summarize the following text into two concise bullet points:
{____}"""

# Create a request to the chat model
response = client.chat.completions.create(
  model="deepseek-ai/DeepSeek-V3",
  messages=[{"role": "user", "content": ____}],
  ____
)

print(response.choices[0].message.content)
Modifier et exécuter le code