ComenzarEmpieza gratis

Game Time: Run the Full Agent

Your basketball coaching agent is almost ready to hit the court. You've written a callback function to show the step number and token usage.

Now it's time to assemble everything: you'll configure a CodeAgent that uses that callback.

You already have access to:

  • A basketball_tool that enables the agent to search scouting reports
  • A model variable with your language model
  • A callback function: action_callback

Your goal is to finish wiring up the agent.

Este ejercicio forma parte del curso

AI Agents with Hugging Face smolagents

Ver curso

Instrucciones del ejercicio

  • Import the ActionStep class so it can be used to register the action callback.
  • Register the action_callback function for the ActionStep class so the agent shows its actions while executing.

Ejercicio interactivo práctico

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

# Import ActionStep to register a callback for it
from smolagents import ____

coach_agent = CodeAgent(
    tools=[basketball_tool],
    model=model,
    verbosity_level=0,
    # Register a callback that runs when an ActionStep is triggered
    step_callbacks={ActionStep: ____}
)

# Run a question through the agent
result = coach_agent.run("What defensive strategy should we use to stop their point guard who averages 25 points per game?")
print(result)
Editar y ejecutar código