DEV Community

Cover image for Day 4: ReAct - Reasoning + Acting upon(Prompting Technique)
Suraj Bera
Suraj Bera

Posted on

Day 4: ReAct - Reasoning + Acting upon(Prompting Technique)

Big picture of ReAct:

AI doesn't just answer immediately, it goes through stages.
think -> plan -> action -> observe -> output(total 5 steps)

ReAct = Forcing the AI to show its work step by step before arriving at a conclusion, just like how a student arrives to the solution of a math problem step by step.

Here is the simplest mental model for ReAct:

        ┌──────────────────────────────┐
        │    YOU send a question       │
        └──────────────┬───────────────┘
                       ▼
        ┌──────────────────────────────┐
        │  AI replies with JSON like   │
        │  { "step": "...", ... }      │
        └──────────────┬───────────────┘
                       ▼
        ┌──────────────────────────────┐
        │ Python looks at "step" and:  │
        │  • plan  → loop again        │
        │  • action → run a tool       |
        │  • output → print & STOP     │
        └──────────────────────────────┘
Enter fullscreen mode Exit fullscreen mode

Comparing Chain of Thought(another prompting technique) vs ReAct:
CoT - In this technique, the LLM is instructed to generate its intermediate reasoning steps as part of the output, instead of jumping straight to the final answer.
ReAct - CoT only thinks, ReAct thinks and does stuffs.

Here is the code

Links to Day 3 and Day 2

Top comments (0)