File size: 2,020 Bytes
0128def
6b02296
e3d7fcc
0128def
 
 
 
0517ff7
0128def
 
3ce50c4
84bb707
 
 
 
 
6b02296
0128def
 
6b02296
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
---

title: First Agent Template
emoji: 
colorFrom: pink
colorTo: yellow
sdk: gradio
sdk_version: 6.5.1
app_file: app.py
pinned: false
tags:
  - smolagents
  - agent
  - smolagent
  - tool
  - agent-course

---

# First Agent (smolagents)

A modular educational AI agent built with **smolagents** and **Gradio**, following the Hugging Face Agents Course.

The agent can:

* Generate images
* Perform web search
* Visit web pages
* Get current time by timezone
* Check disk usage

Runs locally and on **Hugging Face Spaces**.

---

## Project Structure

```
.
├── app.py
├── prompts.yaml
├── src/first_agent/
│   ├── ui.py
│   ├── agent_factory.py
│   └── settings.py
├── tools/
│   ├── final_answer.py
│   ├── web_search.py
│   ├── visit_webpage.py
│   └── disk_free.py
```

* `app.py` – entry point
* `agent_factory.py` – builds model + agent + tools
* `ui.py` – Gradio interface
* `tools/` – custom tools
* `prompts.yaml` – agent prompt templates

---

## Model

```
Qwen/Qwen2.5-Coder-32B-Instruct
```

Accessed via Hugging Face serverless inference (`HfApiModel`).

---

## Local Setup

### 1. Create virtual environment

```bash
python -m venv .venv
source .venv/bin/activate
```

### 2. Install dependencies

```bash
pip install -r requirements.txt
```

### 3. Set HF token

Create `.env`:

```
HF_TOKEN=hf_xxxxxxxxxxxxxxxxx
```

Get token from:
https://huggingface.co/settings/tokens
Scope: **Read**

### 4. Run

```bash
python app.py
```

---

## Hugging Face Spaces

Add your token in:

**Settings → Secrets → HF_TOKEN**

No need for `share=True` on Spaces.

---

## Runtime Behavior

* `outputs/` directory is created at startup
* Old files are cleaned
* Directory is ignored via `.gitignore`
* Works both locally and inside HF container

---

## Status

Educational project with modular architecture and clean separation of:

* UI
* Agent
* Tools
* Configuration

---

## License

MIT (or specify if different).