Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UNIT] Final review of Unit 2.1 on smolagents - release 25/2/25 #216

Merged
merged 55 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
019dedf
Added Telemetry section to CodeAgents
sergiopaniego Feb 19, 2025
707b648
Updated vision agents example
sergiopaniego Feb 19, 2025
2b6453e
Improved vision+browser agent example
sergiopaniego Feb 20, 2025
bc01c88
Merge branch 'unit_2_1_smolagents' of https://github.com/huggingface/…
sergiopaniego Feb 21, 2025
64d235f
change a bold
burtenshaw Feb 21, 2025
7608d06
Merge branch 'main' into unit_2_1_smolagents
burtenshaw Feb 21, 2025
59ba0dc
restore table of contents
burtenshaw Feb 21, 2025
3b6e5fa
security suggestion
burtenshaw Feb 21, 2025
54a2613
improve introduction
burtenshaw Feb 21, 2025
74d6327
bolding in unit introduction
burtenshaw Feb 21, 2025
62927f4
bolding in multiagents
burtenshaw Feb 21, 2025
7e10c33
Added vision+browser agent video and final description
sergiopaniego Feb 21, 2025
f01b137
Merge branch 'unit_2_1_smolagents' of https://github.com/huggingface/…
sergiopaniego Feb 21, 2025
9e5aeff
Updated multiagent system notebook based on Aymeric ipynb
sergiopaniego Feb 21, 2025
713c804
Renamed notebooks and added Agent image
sergiopaniego Feb 21, 2025
a8e69eb
Added links to notebooks
sergiopaniego Feb 21, 2025
85c9360
Updated toctree
sergiopaniego Feb 21, 2025
b2c4fd4
Updated notebooks based on feedback
sergiopaniego Feb 21, 2025
b71072d
Update units/en/unit2/introduction.mdx
simoninithomas Feb 22, 2025
c0fb25c
Update units/en/_toctree.yml
simoninithomas Feb 22, 2025
2f2ef18
Update units/en/_toctree.yml
simoninithomas Feb 22, 2025
16d36df
Update units/en/unit2/smolagents/introduction.mdx
simoninithomas Feb 22, 2025
9d4eeab
Update units/en/unit2/smolagents/introduction.mdx
simoninithomas Feb 24, 2025
58af6f0
Update units/en/unit2/smolagents/code_agents.mdx
simoninithomas Feb 24, 2025
aaa9d88
Update units/en/unit2/smolagents/tools.mdx
simoninithomas Feb 24, 2025
f3ac071
use warning type tip instead of emoji
burtenshaw Feb 24, 2025
bea42fc
Merge pull request #217 from sergiopaniego/unit-2-1-final-additions
burtenshaw Feb 24, 2025
5cc6141
Updated video and image links to HF Org
sergiopaniego Feb 24, 2025
838df38
Updated links to notebooks
sergiopaniego Feb 24, 2025
cdbfd05
SmolAgents -> smolagents
sergiopaniego Feb 24, 2025
b6664e2
Updated tool and Tool using <code> instead of quotes
sergiopaniego Feb 24, 2025
104c6b5
Updated multiagent section adding outputs and updated notebook
sergiopaniego Feb 24, 2025
77b7fd8
Updated phrasingç
sergiopaniego Feb 24, 2025
65cfdd5
Merge pull request #231 from sergiopaniego/add-notebooks-media-smolag…
burtenshaw Feb 24, 2025
838f266
Apply suggestions from code review
burtenshaw Feb 25, 2025
2aa6a7a
make improvements in code_agents
burtenshaw Feb 25, 2025
772483b
Apply suggestions from code review
burtenshaw Feb 25, 2025
a3544a5
Added output map to notebook
sergiopaniego Feb 25, 2025
1b23d4b
Merge pull request #234 from sergiopaniego/add-output-map
burtenshaw Feb 25, 2025
c04ff37
Apply suggestions from code review
burtenshaw Feb 25, 2025
4fdd2d4
Update units/en/unit2/smolagents/code_agents.mdx
burtenshaw Feb 25, 2025
550aac6
Update units/en/unit2/smolagents/multi_agent_systems.mdx
burtenshaw Feb 25, 2025
d76d796
Update units/en/unit2/smolagents/multi_agent_systems.mdx
burtenshaw Feb 25, 2025
37c678f
Update units/en/unit2/smolagents/multi_agent_systems.mdx
burtenshaw Feb 25, 2025
8e93760
Update units/en/unit2/smolagents/multi_agent_systems.mdx
burtenshaw Feb 25, 2025
334f87e
Update units/en/unit2/smolagents/multi_agent_systems.mdx
burtenshaw Feb 25, 2025
0a74c9d
respond to suggestions
burtenshaw Feb 25, 2025
a1312ed
add like CTA
Jofthomas Feb 25, 2025
bae3ba0
remove capital letter
Jofthomas Feb 25, 2025
b1fb9a9
add link
Jofthomas Feb 25, 2025
24f5461
redundant with phrase on top
Jofthomas Feb 25, 2025
ca8d7dd
Merge pull request #235 from huggingface/unit2.1_smolagents_Joffrey-r…
burtenshaw Feb 25, 2025
273d4e7
fix casing on smolagents
burtenshaw Feb 25, 2025
0a072cb
final improvements in code agents
burtenshaw Feb 25, 2025
804ffd6
fixes in conclusion
burtenshaw Feb 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7,082 changes: 7,082 additions & 0 deletions notebooks/unit2/smolagents/multiagent_notebook.ipynb

Large diffs are not rendered by default.

1,357 changes: 1,357 additions & 0 deletions notebooks/unit2/smolagents/smolagents_code_agents.ipynb

Large diffs are not rendered by default.

2,830 changes: 2,830 additions & 0 deletions notebooks/unit2/smolagents/smolagents_retrieval_agents.ipynb

Large diffs are not rendered by default.

558 changes: 558 additions & 0 deletions notebooks/unit2/smolagents/smolagents_tool_calling_agents.ipynb

Large diffs are not rendered by default.

2,263 changes: 2,263 additions & 0 deletions notebooks/unit2/smolagents/smolagents_tools.ipynb

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions units/en/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,38 @@
title: Unit 1 Final Quiz
- local: unit1/conclusion
title: Conclusion
- title: Unit 2. Frameworks for AI Agents
sections:
- local: unit2/introduction
title: Frameworks for AI Agents
- title: Unit 2.1 The smolagents framework
sections:
- local: unit2/smolagents/introduction
title: Frameworks for AI Agents
- local: unit2/smolagents/introduction
title: Introduction to smolagents
- local: unit2/smolagents/why_use_smolagents
title: Why use smolagents?
- local: unit2/smolagents/quiz1
title: Quick Quiz 1
- local: unit2/smolagents/code_agents
title: Building Agents That Use Code
- local: unit2/smolagents/tool_calling_agents
title: Integrating Agents With Tools
- local: unit2/smolagents/tools
title: Tools
- local: unit2/smolagents/retrieval_agents
title: Retrieval Agents
- local: unit2/smolagents/quiz2
title: Quick Quiz 2
- local: unit2/smolagents/multi_agent_systems
title: Multi-Agent Systems
- local: unit2/smolagents/vision_agents
title: Vision and Browser agents
- local: unit2/smolagents/final_quiz
title: Final Quiz
- local: unit2/smolagents/conclusion
title: Conclusion
- title: Bonus Unit 1. Fine-tuning an LLM for Function-calling
sections:
- local: bonus-unit1/introduction
Expand Down
Empty file removed units/en/unit2/README.md
Empty file.
34 changes: 34 additions & 0 deletions units/en/unit2/introduction.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Introduction to Agentic Frameworks

Welcome to this second unit, where **we'll explore different agentic frameworks** that can be used to build powerful agentic applications.

We will study:

- In Unit 2.1: [Smolagents](https://huggingface.co/docs/smolagents/en/index)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- In Unit 2.1: [Smolagents](https://huggingface.co/docs/smolagents/en/index)
- In Unit 2.1: [smolagents](https://huggingface.co/docs/smolagents/en/index)

- In Unit 2.2: [LlamaIndex](https://www.llamaindex.ai/)
- In Unit 2.3: [LangGraph](https://www.langchain.com/langgraph)

Let's dive in! 🕵

## When to Use an Agentic Framework

An agentic framework is **not always needed when building an application around LLMs**. They provide flexibility in the workflow to efficiently solve a specific task, but they're not always necessary.

Sometimes, **predefined workflows are sufficient** to fulfill user requests, and there is no real need for an agentic framework. If the approach to build an agent is simple, like a chain of prompts, using plain code may be enough. The advantage is that the developer will have **full control and understanding of their system without abstractions**.

However, when the workflow becomes more complex, such as letting an LLM call functions or using multiple agents, these abstractions start to become helpful.

Considering these ideas, we can already identify the need for some features:

* An *LLM engine* that powers the system.
* A *list of tools* the agent can access.
* A *parser* for extracting tool calls from the LLM output.
* A *system prompt* synced with the parser.
* A *memory system*.
* *Error logging and retry mechanisms* to control LLM mistakes.

## Agentic Frameworks Units

| Framework | Description | Unit Author |
|------------|----------------|----------------|
| [smolagents](./smolagents/introduction) | Agents framework developed by Hugging Face. | Sergio Paniego - [HF](https://huggingface.co/sergiopaniego) - [X](https://x.com/sergiopaniego) - [Linkedin](https://www.linkedin.com/in/sergio-paniego-blanco) |
Binary file added units/en/unit2/output_map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
312 changes: 312 additions & 0 deletions units/en/unit2/smolagents/code_agents.mdx

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions units/en/unit2/smolagents/conclusion.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Conclusion

Congratulations on finishing the `smolagents` module of this second Unit 🥳

You’ve just mastered the fundamentals of `smolagents` and you’ve build your own Agent! Now that you have skills in `smolagents`, you can now start to create Agents that will solve tasks you're interested about.

In the next module of unit, you're going to learn **how to build Agents with LlamaIndex**.

Finally, we would love **to hear what you think of the course and how we can improve it**. If you have some feedback then, please 👉 [fill this form](https://docs.google.com/forms/d/e/1FAIpQLSe9VaONn0eglax0uTwi29rIn4tM7H2sYmmybmG5jJNlE5v0xA/viewform?usp=dialog)

### Keep Learning, stay awesome 🤗
25 changes: 25 additions & 0 deletions units/en/unit2/smolagents/final_quiz.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Exam Time!

Well done on working through the material on `smolagents`! You've already achieved a lot. Now, it's time to put your knowledge to the test with a quiz. 🧠

## Instructions

- The quiz consists of code questions.
- You will be given instructions to complete the code snippets.
- Read the instructions carefully and complete the code snippets accordingly.
- For each question, you will be given the result and some feedback.

🧘 **This quiz is ungraded and uncertified**. It's about you understanding the `smolagents` library and knowing whether you should spend more time on the written material. In the coming units you'll put this knowledge to the test in use cases and projects.

Let's get started!

## Quiz 🚀

<iframe
src="https://agents-course-unit2-smolagents-quiz.hf.space"
frameborder="0"
width="850"
height="450"
></iframe>

You can also access the quiz 👉 [here](https://huggingface.co/spaces/agents-course/unit2_smolagents_quiz)
66 changes: 66 additions & 0 deletions units/en/unit2/smolagents/introduction.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Introduction to `smolagents`

![smolagents license to call](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/smolagents/license_to_call.png)

Welcome to this module, where you'll learn **how to build effective agents** using the [`smolagents`](https://github.com/huggingface/smolagents) library, which provides a lightweight framework for creating capable AI agents.

## Module Overview

This module provides a comprehensive overview of key concepts and practical strategies for building intelligent agents using `smolagents`.

With so many open-source frameworks available, it's essential to understand the components and capabilities that make `smolagents` a useful option or to determine when another solution might be a better fit.

We'll explore critical agent types, including code agents designed for software development tasks, tool calling agents for creating modular, function-driven workflows and retrieval agents that access and synthesize information.

Additionally, we'll cover the orchestration of multiple agents and the integration of vision capabilities and web browsing to unlock new possibilities for dynamic and context-aware applications.

In this unit, Alfred, the agent from Unit 1, makes his return. This time, he’s using the `smolagents` framework for his internal workings. Together, we’ll explore the key concepts behind this framework as Alfred tackles various tasks. Alfred is organizing a party at the Wayne Manor while the Wayne family 🦇 is away, and he has plenty to do. Join us as we showcase his journey and how he handles these tasks with `smolagents`!

<Tip>

From this unit, you will learn to build AI agents with the `smolagents` library. Your agents will be able to search for data, execute code, and interact with web pages. You will also learn how to combine multiple agents to create more powerful systems.

</Tip>

![Alfred the agent](https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/this-is-alfred.jpg)

## Contents

During this unit on `smolagents`, we going to cover:

### 1️⃣ [Why Use smolagents](./why_use_smolagents)

`smolagents` is one of the many open-source agent frameworks available for application development. Alternative options include `LlamaIndex` and `LangGraph`, which are also covered in other modules in this course. This library offers several key features that might make it a great fit for specific use cases, but we should always consider all options when selecting a framework. This module explores the advantages and drawbacks of using `smolagents`, helping you make an informed decision based on your project's requirements.

### 2️⃣ [CodeAgents](./code_agents)

`CodeAgents` are the primary type of agent in `smolagents`. Instead of generating JSON or text, these agents produce Python code to perform actions. This module explores their purpose, functionality, and how they work, along with hands-on examples to showcase their capabilities.

### 3️⃣ [ToolCallingAgents](./tool_calling_agents)

`ToolCallingAgents` are the second type of agent supported by `smolagents. Unlike `CodeAgents`, which generate Python code, these agents rely on JSON/text blobs that the system must parse and interpret to execute actions. This module covers their functionality, their key differences from `CodeAgents`, and it provides a coding example to illustrate their usage.

### 4️⃣ [Tools](./tools)

Tools are functions that an LLM can use within an agentic system, acting as essential building blocks for agent behavior. This module covers how to create tools, their structure, and different implementation methods using the `Tool` class or the `@tool` decorator. You'll also learn about the default toolbox, how to share tools with the community, and how to load community-contributed tools for use in your agents.

### 5️⃣ [Retrieval Agents](./retrieval_agents)

Retrieval agents combine models with knowledge bases, allowing them to search, synthesize, and retrieve information from multiple sources. They leverage vector stores for efficient retrieval and implement **Retrieval-Augmented Generation (RAG)** patterns. These agents are particularly useful for integrating web search with custom knowledge bases while maintaining conversation context through memory systems. This module explores implementation strategies, including fallback mechanisms for robust information retrieval.

### 6️⃣ [Multi-Agent Systems](./multi_agent_systems)

Orchestrating multiple agents effectively is crucial for building powerful, multi-agent systems. By combining agents with different capabilities—such as a web search agent with a code execution agent—you can create more sophisticated solutions. This module focuses on designing, implementing, and managing multi-agent systems to maximize efficiency and reliability.

### 7️⃣ [Vision and Browser agents](./vision_agents)

Vision agents extend traditional agent capabilities by incorporating **Vision-Language Models (VLMs)**, enabling them to process and interpret visual information. This module explores how to design and integrate VLM-powered agents, unlocking advanced functionalities like image-based reasoning, visual data analysis, and multimodal interactions. We will also use vision agents to build a browser agent that can browse the web and extract information from it.

## Resources

- [smolagents Documentation](https://huggingface.co/docs/smolagents) - Official docs for the smolagents library
- [Building Effective Agents](https://www.anthropic.com/research/building-effective-agents) - Research paper on agent architectures
- [Agent Guidelines](https://huggingface.co/docs/smolagents/tutorials/building_good_agents) - Best practices for building reliable agents
- [LangGraph Agents](https://langchain-ai.github.io/langgraph/) - Additional examples of agent implementations
- [Function Calling Guide](https://platform.openai.com/docs/guides/function-calling) - Understanding function calling in LLMs
- [RAG Best Practices](https://www.pinecone.io/learn/retrieval-augmented-generation/) - Guide to implementing effective RAG
Loading