AI Agents with Hugging Face smolagents
Adel Nehme
VP of AI Curriculum, DataCamp






Chatbots:
Agents:
Agents follow a cycle:


All from a single prompt!

Supports two types of agents:
ToolCallingAgent: Uses structured function callsCodeAgent: Writes and runs Python code
Action 1: {"tool": "search_company", "company": "Competitor A"}
Action 2: {"tool": "get_pricing", "company": "Competitor A", "plan": "Basic"}
Action 3: {"tool": "get_pricing", "company": "Competitor A", "plan": "Pro"}
Action 4: {"tool": "search_company", "company": "Competitor B"}
Action 5: {"tool": "get_pricing", "company": "Competitor B", "plan": "Basic"}
competitors = ["Competitor A", "Competitor B", "Competitor C"]
pricing_data = {}
for company in competitors:
    company_info = search_company(company)
    plans = extract_pricing_plans(company_info)
    pricing_data[company] = plans
most_affordable_option = min(pricing_data, 
                      key=lambda x: pricing_data[x]['basic_plan'])
Research shows ~20% higher success rate than function-calling methods.

AI Agents with Hugging Face smolagents