One Prompt, Many Tools
You've already created two tools for AgentsCafé:
generate_order_id
: produces a timestamped ID likeT5_Latte_20250812_0915
lookup_orders
: readsorders.csv
and returns a list of drinks for that table
Now let's create an agent that uses those two tools. So, for any table, the agent can fetch its orders and assign a unique ID to each drink.
Note: The model, tools and necessary imports have already been defined for you. A sample orders.csv
is uploaded as well.
This exercise is part of the course
AI Agents with Hugging Face smolagents
Exercise instructions
- Create a coding agent using your previously defined
lookup_orders
andgenerate_order_id
tools. - Add
pandas
to the list of authorized imports to ensure the agent can read the CSV. - Use the agent's
.run()
method to process atask
that fetches orders for a table and assigns IDs.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create a code agent with the lookup_orders and generate_order_id tools
agent = CodeAgent(
tools=[____, ____],
model=model,
# Authorize pandas import
additional_authorized_imports=['____']
)
task = (
"For table 5, list their current drink orders and generate a unique order ID for each one."
)
# Run the agent passing the task
result = ____
print(result)