ComenzarEmpieza gratis

Coding with reasoning models

Time for you to have a go at coding with DeepSeek's R1 model! As you may know, one important part of developing reliable code is to include tests, which validate that intermediate processes are running correctly before returning a final output. Well-written tests make debugging much easier!

Your colleague has handed-over a Python script they were working on, which you notice doesn't contain any tests. As you aren't familiar with the libraries or syntax used in the script, you'll use a reasoning model to add appropriate testing to the script in the form of assert statements. If you'd like to read more about assert statements, check out this DataCamp tutorial.

import numpy as np
a = np.arange(5)
b = a.reshape(-1, 1)
c = np.ones((5, 3))
d = np.hstack((b, c))
col_means = d.mean(axis=0)

Este ejercicio forma parte del curso

Working with DeepSeek in Python

Ver curso

Instrucciones del ejercicio

  • Copy the code provided into the delimited prompt that has been started for you.
  • Send prompt to the deepseek-ai/DeepSeek-R1 model.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

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

# Copy the code into the prompt
prompt = """[Task: Write Python assert statements for the following code.]
Code:
____
"""

# Send the prompt to R1
response = client.chat.completions.create(model="deepseek-ai/DeepSeek-R1", messages=[{"role": "user", "content": ____}], max_tokens=400)
print(response.choices[0].message.content)
Editar y ejecutar código