IniziaInizia 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.

Questo esercizio fa parte del corso

AI Agents with Hugging Face smolagents

Visualizza il corso

Istruzioni dell'esercizio

  • 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.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# 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)
Modifica ed esegui il codice