Get startedGet started for free

Check, Please! Giving Agents Access to Data

At AgentsCafé, all drink orders are saved in a file called orders.csv, which includes the columns: table_id, drink_name, and size.

Instead of manually scrolling through the file every time a customer asks for their bill, you’ll build a tool that looks up all current orders for a specific table.

Note: tool and pandas have been imported for you.

This exercise is part of the course

AI Agents with Hugging Face smolagents

View Course

Exercise instructions

  • Use table_id as the function parameter so the agent knows which table's orders to retrieve.
  • Read the orders.csv file, which contains all drink orders.
  • Return the list of drink orders for the table.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Create a tool that receives the table_id as input
@tool
def lookup_orders(____: str) -> list[str]:
    """
    Retrieves the current drink orders for a café table.

    Args:
        table_id (str): The table's identifier (e.g., "T5").

    Returns:
        list[str]: A list of drink orders, each formatted like "Latte (Large)".
    """
    
    # Read the orders.csv file
    df = pd.read_csv('____')
    orders = df[df['table_id'] == table_id].apply(lambda row: f"{row['drink_name']} ({row['size']})", axis=1).tolist()
    
    # Return the table orders
    return ____
Edit and Run Code