0
0
Prompt Engineering / GenAIml~10 mins

ReAct pattern in Prompt Engineering / GenAI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize the ReAct agent with the correct reasoning step.

Prompt Engineering / GenAI
agent = ReActAgent(reasoning_steps=[1])
Drag options to blanks, or click blank then click option'
A1
B3
C0
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Setting reasoning_steps to 0 disables reasoning.
Using too many steps initially can complicate the agent's behavior.
2fill in blank
medium

Complete the code to add an observation after the agent takes an action.

Prompt Engineering / GenAI
agent.observe(action_output=[1])
Drag options to blanks, or click blank then click option'
Aobservation
Baction_result
Caction_output
Dresponse
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name that is not defined or unrelated.
Confusing 'observation' with the variable holding the action output.
3fill in blank
hard

Fix the error in the code to correctly perform the agent's think-act cycle.

Prompt Engineering / GenAI
thought = agent.think(input_text)
action = agent.act([1])
Drag options to blanks, or click blank then click option'
Aagent
Binput_text
Caction
Dthought
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the original input instead of the thought.
Passing the action variable before it is defined.
4fill in blank
hard

Fill both blanks to create a loop that runs the ReAct agent for 3 cycles.

Prompt Engineering / GenAI
for _ in range([1]):
    thought = agent.think(input_text)
    action = agent.act(thought)
    agent.observe([2])
Drag options to blanks, or click blank then click option'
A3
Baction
Cthought
Dinput_text
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'thought' instead of 'action' for observation.
Setting the loop count incorrectly.
5fill in blank
hard

Fill all three blanks to define a function that runs the ReAct agent for a given number of steps and returns the final thought.

Prompt Engineering / GenAI
def run_react_agent(agent, input_text, steps):
    for _ in range([1]):
        thought = agent.think(input_text)
        action = agent.act([2])
        agent.observe([3])
    return thought
Drag options to blanks, or click blank then click option'
Asteps
Bthought
Caction
Dinput_text
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'input_text' instead of 'thought' for the act method.
Observing 'thought' instead of 'action'.