Dogłębna analiza i generowanie kodu

Praca z DeepSeek w Pythonie

James Chapman

AI Curriculum Lead, DataCamp

Przypomnienie...

print(response.choices[0].message.content)
Step 1 - ...
Step 2 - ...
Final Answer: ...
  • Rozumowanie jest domyślnie włączone → steruj nim przez reasoning_effort="high" lub "max"
  • temperature nie ma wpływu na rozumowanie
Praca z DeepSeek w Pythonie

1. Postaw na prostotę

  • Zwięzłe prompty

What are the differences between lists and tuples in Python?

In Python, there are different data structures. Lists are...

  • Podawanie przykładów (np. few-shot) może obniżyć jakość odpowiedzi

Who developed the Python programming language?

Example 1:
Q: Who developed the R programming language?
A: Ross Ihaka and Robert Gentleman
Praca z DeepSeek w Pythonie

2. Zachęcaj do rozumowania

 

"... Take your time and think through each step."

 

Większe zużycie tokenów

Dłuższy czas odpowiedzi

Praca z DeepSeek w Pythonie

3. Unikaj prostych zadań!

 

Tryb czatu

Model czatu bez trudu wykonuje proste zadanie.

 

Tryb rozumowania

Model rozumowania z trudem radzi sobie z prostymi zadaniami.

Praca z DeepSeek w Pythonie

3. Unikaj prostych zadań!

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V4-Pro",
    messages=[{"role": "user", "content": "Return the result of 1+1."}]
)
print(response.choices[0].message.content)
Let's count step by step.
- Start with 1.
- Add another 1.
- 1 + 1 = 2.

**Final Answer: 2**
  • Przy prostych obliczeniach ustrukturyzowane rozumowanie to zbędny narzut
  • Kosztuje więcej tokenów i wydłuża czas odpowiedzi w porównaniu ze zwykłym modelem czatu
Praca z DeepSeek w Pythonie

Przykład: debugowanie kodu

Człowiek debugujący kod.

Przepływ pracy modelu rozumowania.

Praca z DeepSeek w Pythonie

Przykład: debugowanie kodu

Model rozumowania poprawiający kod na podstawie błędu.

Praca z DeepSeek w Pythonie

Przykład: debugowanie kodu

prompt = """
[Task: Fix the following code.]

Code:
def count_to_ten(start):
    while start < 10:
        print(start)
    return "Done"

count_to_ten(1)
"""
Praca z DeepSeek w Pythonie
print(response.choices[0].message.content)
Let me walk through the function step by step.

The function uses a while loop: while start < 10. Then it prints start. But wait, inside the loop,
there's no increment for the start variable — that's the issue.

The fix is to add an increment to start inside the loop. Like start += 1.

Here is the corrected code:

def count_to_ten(start):
    while start < 10:
        print(start)
        start += 1
    return "Done"

count_to_ten(1)
Praca z DeepSeek w Pythonie

Czas na praktykę!

Praca z DeepSeek w Pythonie

Preparing Video For Download...