unit_2_1_smolagents

#20
unit2/smolagents/code_agents.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
unit2/smolagents/multiagent_notebook.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
unit2/smolagents/retrieval_agents.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
unit2/smolagents/tool_calling_agents.ipynb ADDED
@@ -0,0 +1,596 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {
6
+ "id": "Pi9CF0391ARI"
7
+ },
8
+ "source": [
9
+ "# Integrating Agents With Tools\n",
10
+ "\n",
11
+ "This notebook is part of the [Hugging Face Agents Course](https://www.hf.co/learn/agents-course), a free Course from beginner to expert, where you learn to build Agents.\n",
12
+ "\n",
13
+ "![Agents course share](https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/communication/share.png)"
14
+ ]
15
+ },
16
+ {
17
+ "cell_type": "markdown",
18
+ "metadata": {
19
+ "id": "9gsYky7F1GzT"
20
+ },
21
+ "source": [
22
+ "## Let's install the dependencies and login to our HF account to access the Inference API\n",
23
+ "\n",
24
+ "If you haven't installed `smolagents` yet, you can do so by running the following command:"
25
+ ]
26
+ },
27
+ {
28
+ "cell_type": "code",
29
+ "execution_count": null,
30
+ "metadata": {
31
+ "id": "MoFopncp0pnJ"
32
+ },
33
+ "outputs": [],
34
+ "source": [
35
+ "!pip install smolagents -U"
36
+ ]
37
+ },
38
+ {
39
+ "cell_type": "markdown",
40
+ "source": [
41
+ "Let's also login to the Hugging Face Hub to have access to the Inference API."
42
+ ],
43
+ "metadata": {
44
+ "id": "cH-4W1GhYL4T"
45
+ }
46
+ },
47
+ {
48
+ "cell_type": "code",
49
+ "execution_count": null,
50
+ "metadata": {
51
+ "id": "TFTc-ry70y1f"
52
+ },
53
+ "outputs": [],
54
+ "source": [
55
+ "from huggingface_hub import notebook_login\n",
56
+ "\n",
57
+ "notebook_login()"
58
+ ]
59
+ },
60
+ {
61
+ "cell_type": "markdown",
62
+ "metadata": {
63
+ "id": "ekKxaZrd1HlB"
64
+ },
65
+ "source": [
66
+ "## Selecting a Playlist for the Party Using `smolagents` and a `ToolCallingAgent`\n",
67
+ "\n",
68
+ "Let's revisit the previous example where Alfred started party preparations, but this time we'll use a `ToolCallingAgent` to highlight the difference. We'll build an agent that can search the web using DuckDuckGo, just like in our Code Agent example. The only difference is the agent type - the framework handles everything else:"
69
+ ]
70
+ },
71
+ {
72
+ "cell_type": "code",
73
+ "execution_count": null,
74
+ "metadata": {
75
+ "colab": {
76
+ "base_uri": "https://localhost:8080/",
77
+ "height": 1000
78
+ },
79
+ "id": "6IInDOUN01sP",
80
+ "outputId": "e49f2360-d377-4ed8-b7ae-8da4a3e3757b"
81
+ },
82
+ "outputs": [
83
+ {
84
+ "data": {
85
+ "text/html": [
86
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d4b702; text-decoration-color: #d4b702\">╭──────────────────────────────────────────────────── </span><span style=\"color: #d4b702; text-decoration-color: #d4b702; font-weight: bold\">New run</span><span style=\"color: #d4b702; text-decoration-color: #d4b702\"> ────────────────────────────────────────────────────╮</span>\n",
87
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
88
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\">Search for the best music recommendations for a party at the Wayne's mansion.</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
89
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
90
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">╰─ HfApiModel - Qwen/Qwen2.5-Coder-32B-Instruct ──────────────────────────────────────────────────────────────────╯</span>\n",
91
+ "</pre>\n"
92
+ ],
93
+ "text/plain": [
94
+ "\u001b[38;2;212;183;2m╭─\u001b[0m\u001b[38;2;212;183;2m───────────────────────────────────────────────────\u001b[0m\u001b[38;2;212;183;2m \u001b[0m\u001b[1;38;2;212;183;2mNew run\u001b[0m\u001b[38;2;212;183;2m \u001b[0m\u001b[38;2;212;183;2m───────────────────────────────────────────────────\u001b[0m\u001b[38;2;212;183;2m─╮\u001b[0m\n",
95
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
96
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1mSearch for the best music recommendations for a party at the Wayne's mansion.\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
97
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
98
+ "\u001b[38;2;212;183;2m╰─\u001b[0m\u001b[38;2;212;183;2m HfApiModel - Qwen/Qwen2.5-Coder-32B-Instruct \u001b[0m\u001b[38;2;212;183;2m─────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;212;183;2m─╯\u001b[0m\n"
99
+ ]
100
+ },
101
+ "metadata": {},
102
+ "output_type": "display_data"
103
+ },
104
+ {
105
+ "data": {
106
+ "text/html": [
107
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d4b702; text-decoration-color: #d4b702\">━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ </span><span style=\"font-weight: bold\">Step </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span><span style=\"color: #d4b702; text-decoration-color: #d4b702\"> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━</span>\n",
108
+ "</pre>\n"
109
+ ],
110
+ "text/plain": [
111
+ "\u001b[38;2;212;183;2m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ \u001b[0m\u001b[1mStep \u001b[0m\u001b[1;36m1\u001b[0m\u001b[38;2;212;183;2m ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\n"
112
+ ]
113
+ },
114
+ "metadata": {},
115
+ "output_type": "display_data"
116
+ },
117
+ {
118
+ "name": "stderr",
119
+ "output_type": "stream",
120
+ "text": [
121
+ "/usr/local/lib/python3.11/dist-packages/huggingface_hub/utils/_auth.py:94: UserWarning: \n",
122
+ "The secret `HF_TOKEN` does not exist in your Colab secrets.\n",
123
+ "To authenticate with the Hugging Face Hub, create a token in your settings tab (https://huggingface.co/settings/tokens), set it as secret in your Google Colab and restart your session.\n",
124
+ "You will be able to reuse this secret in all of your notebooks.\n",
125
+ "Please note that authentication is recommended but still optional to access public models or datasets.\n",
126
+ " warnings.warn(\n"
127
+ ]
128
+ },
129
+ {
130
+ "data": {
131
+ "text/html": [
132
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮\n",
133
+ "│ Calling tool: 'web_search' with arguments: {'query': \"best music recommendations for a party at Wayne's │\n",
134
+ "│ mansion\"} │\n",
135
+ "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
136
+ "</pre>\n"
137
+ ],
138
+ "text/plain": [
139
+ "╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮\n",
140
+ "│ Calling tool: 'web_search' with arguments: {'query': \"best music recommendations for a party at Wayne's │\n",
141
+ "│ mansion\"} │\n",
142
+ "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n"
143
+ ]
144
+ },
145
+ "metadata": {},
146
+ "output_type": "display_data"
147
+ },
148
+ {
149
+ "data": {
150
+ "text/html": [
151
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Observations: ## Search Results\n",
152
+ "\n",
153
+ "|The <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">75</span> Best Party Songs That Will Get Everyone Dancing - \n",
154
+ "Gear4music<span style=\"font-weight: bold\">](</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://www.gear4music.com/blog/best-party-songs/)</span>\n",
155
+ "The best party songs <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span>. <span style=\"color: #008000; text-decoration-color: #008000\">\"September\"</span> - Earth, Wind &amp; Fire <span style=\"font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1978</span><span style=\"font-weight: bold\">)</span> Quite possibly the best party song. An infectious \n",
156
+ "mix of funk and soul, <span style=\"color: #008000; text-decoration-color: #008000\">\"September\"</span> is celebrated for its upbeat melody and <span style=\"color: #008000; text-decoration-color: #008000\">\"ba-dee-ya\"</span> chorus, making it a timeless \n",
157
+ "dance favorite.\n",
158
+ "\n",
159
+ "|Wedding Party Entrance Songs to Get the Party Started - The Mansion \n",
160
+ "<span style=\"color: #808000; text-decoration-color: #808000\">...</span><span style=\"font-weight: bold\">](</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://mansiononmainstreet.com/wedding-party-entrance-songs-to-get-the-party-started/)</span>\n",
161
+ "Best Wedding Party Entrance Songs. No matter what vibe you're going for, there are some wedding party entrance \n",
162
+ "songs that are guaranteed to be a hit with people. From the latest music from Justin Timberlake to oldies but \n",
163
+ "goodies, most of your guests will be familiar with the popular wedding party entrance songs listed below.\n",
164
+ "\n",
165
+ "|<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">50</span> Songs on Every Event Planner's Playlist - \n",
166
+ "Eventbrite<span style=\"font-weight: bold\">](</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://www.eventbrite.com/blog/event-planning-playlist-ds00/)</span>\n",
167
+ "Music sets the mood and provides the soundtrack <span style=\"font-weight: bold\">(</span>literally<span style=\"font-weight: bold\">)</span> for a memorable and exciting time. While the right \n",
168
+ "songs can enhance the experience, the wrong event music can throw off the vibe. For example, fast-paced songs \n",
169
+ "probably aren't the best fit for a formal gala. And smooth jazz is likely to lull your guests at a motivational \n",
170
+ "conference.\n",
171
+ "\n",
172
+ "|<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">200</span> Classic House Party Songs Everyone Knows | The Best <span style=\"color: #808000; text-decoration-color: #808000\">...</span> - \n",
173
+ "iSpyTunes<span style=\"font-weight: bold\">](</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://www.ispytunes.com/post/house-party-songs)</span>\n",
174
+ "\" Branded merchandise adds flair to any occasion, just like the perfect playlist. <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">200</span> classic house party songs \n",
175
+ "everyone knows set the mood, bringing energy to every celebration. The best popular party hits keep guests dancing,\n",
176
+ "creating unforgettable moments. From throwback anthems to modern beats, a great selection ensures nonstop fun.\n",
177
+ "\n",
178
+ "|The Best Songs For Parties - The Ambient Mixer \n",
179
+ "Blog<span style=\"font-weight: bold\">](</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://blog.ambient-mixer.com/usage/parties-2/the-best-songs-for-parties/)</span>\n",
180
+ "The <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">100</span> best party songs ever made. Top <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">100</span> Best Party Songs Of All Time. Of course, these are just <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span> of the many \n",
181
+ "available playlists to choose from. However, these two contain some of the most popular ones most people usually \n",
182
+ "end up using. If these are not the type of songs you or your guests might enjoy then simply follow the steps in the\n",
183
+ "<span style=\"color: #808000; text-decoration-color: #808000\">...</span>\n",
184
+ "\n",
185
+ "|Passaic County Parks &amp; Recreation: Music at the \n",
186
+ "Mansion<span style=\"font-weight: bold\">](</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://passaiccountynj.myrec.com/info/activities/program_details.aspx?ProgramID=29909)</span>\n",
187
+ "Thursdays from <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">7</span> to <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">9</span> PM the finest local bands will be playing music while In the Drink restaurant sells food and \n",
188
+ "drinks on site. September 3rd: Norton Smull Band; Parking is limited at the Dey Mansion <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">209</span> Totowa Rd. Wayne, NJ. \n",
189
+ "Overflow parking will be at the Preakness Valley Golf Course. You may drop off your guests at the Mansion first.\n",
190
+ "\n",
191
+ "|Grand Entrance Songs | SOUNDfonix<span style=\"font-weight: bold\">](</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://soundfonixent.com/resources/reception-song-ideas/grand-entrance-songs/)</span>\n",
192
+ "The entrance song sets the tone for the rest of the dance and the evening. Choose your entrance song wisely.\n",
193
+ "\n",
194
+ "|Party Music Guide: Ultimate Tips for the Perfect \n",
195
+ "Playlist<span style=\"font-weight: bold\">](</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://thebackstage-deezer.com/music/perfect-party-music-playlist/)</span>\n",
196
+ "Check out the best party playlists and top party songs to ensure your next party is packed! The most popular party \n",
197
+ "songs are here, just hit play. <span style=\"color: #808000; text-decoration-color: #808000\">...</span> to decor. But, most of all, you need to have fantastic music. We recommend you \n",
198
+ "get at least three hours' worth of party music queued and ready — that's about <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">75</span> songs. Lucky for you, we've <span style=\"color: #808000; text-decoration-color: #808000\">...</span>\n",
199
+ "\n",
200
+ "|The Top <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">100</span> Best Party Songs of All Time - \n",
201
+ "LiveAbout<span style=\"font-weight: bold\">](</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://www.liveabout.com/top-best-party-songs-of-all-time-3248355)</span>\n",
202
+ "<span style=\"color: #008000; text-decoration-color: #008000\">\"Macarena\"</span> then spent <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">14</span> weeks at No. <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span> on the U.S. pop singles chart. For more than a year this was one of the \n",
203
+ "most popular special event songs in the United States. It still works well as a charming party song encouraging \n",
204
+ "everyone to join in on the simple dance.\n",
205
+ "\n",
206
+ "|<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">70</span> Best Piano Bar Songs You Should Request<span style=\"font-weight: bold\">](</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://www.pianoarea.com/best-piano-bar-songs/)</span>\n",
207
+ "Best Piano Bar Songs You Should Request <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span>. <span style=\"color: #008000; text-decoration-color: #008000\">\"Piano Man\"</span> by Billy Joel. One of the top recommendations for piano bar \n",
208
+ "songs is <span style=\"color: #008000; text-decoration-color: #008000\">\"Piano Man\"</span> by Billy Joel.. This iconic track was released by Columbia Records in <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1973</span>.. As part of the \n",
209
+ "album titled <span style=\"color: #008000; text-decoration-color: #008000\">'Piano Man,'</span> it's one of Billy Joel's most recognizable works.. The song spins a captivating narrative\n",
210
+ "and showcases Joe's compelling <span style=\"color: #808000; text-decoration-color: #808000\">...</span>\n",
211
+ "</pre>\n"
212
+ ],
213
+ "text/plain": [
214
+ "Observations: ## Search Results\n",
215
+ "\n",
216
+ "|The \u001b[1;36m75\u001b[0m Best Party Songs That Will Get Everyone Dancing - \n",
217
+ "Gear4music\u001b[1m]\u001b[0m\u001b[1m(\u001b[0m\u001b[4;94mhttps://www.gear4music.com/blog/best-party-songs/\u001b[0m\u001b[4;94m)\u001b[0m\n",
218
+ "The best party songs \u001b[1;36m1\u001b[0m. \u001b[32m\"September\"\u001b[0m - Earth, Wind & Fire \u001b[1m(\u001b[0m\u001b[1;36m1978\u001b[0m\u001b[1m)\u001b[0m Quite possibly the best party song. An infectious \n",
219
+ "mix of funk and soul, \u001b[32m\"September\"\u001b[0m is celebrated for its upbeat melody and \u001b[32m\"ba-dee-ya\"\u001b[0m chorus, making it a timeless \n",
220
+ "dance favorite.\n",
221
+ "\n",
222
+ "|Wedding Party Entrance Songs to Get the Party Started - The Mansion \n",
223
+ "\u001b[33m...\u001b[0m\u001b[1m]\u001b[0m\u001b[1m(\u001b[0m\u001b[4;94mhttps://mansiononmainstreet.com/wedding-party-entrance-songs-to-get-the-party-started/\u001b[0m\u001b[4;94m)\u001b[0m\n",
224
+ "Best Wedding Party Entrance Songs. No matter what vibe you're going for, there are some wedding party entrance \n",
225
+ "songs that are guaranteed to be a hit with people. From the latest music from Justin Timberlake to oldies but \n",
226
+ "goodies, most of your guests will be familiar with the popular wedding party entrance songs listed below.\n",
227
+ "\n",
228
+ "|\u001b[1;36m50\u001b[0m Songs on Every Event Planner's Playlist - \n",
229
+ "Eventbrite\u001b[1m]\u001b[0m\u001b[1m(\u001b[0m\u001b[4;94mhttps://www.eventbrite.com/blog/event-planning-playlist-ds00/\u001b[0m\u001b[4;94m)\u001b[0m\n",
230
+ "Music sets the mood and provides the soundtrack \u001b[1m(\u001b[0mliterally\u001b[1m)\u001b[0m for a memorable and exciting time. While the right \n",
231
+ "songs can enhance the experience, the wrong event music can throw off the vibe. For example, fast-paced songs \n",
232
+ "probably aren't the best fit for a formal gala. And smooth jazz is likely to lull your guests at a motivational \n",
233
+ "conference.\n",
234
+ "\n",
235
+ "|\u001b[1;36m200\u001b[0m Classic House Party Songs Everyone Knows | The Best \u001b[33m...\u001b[0m - \n",
236
+ "iSpyTunes\u001b[1m]\u001b[0m\u001b[1m(\u001b[0m\u001b[4;94mhttps://www.ispytunes.com/post/house-party-songs\u001b[0m\u001b[4;94m)\u001b[0m\n",
237
+ "\" Branded merchandise adds flair to any occasion, just like the perfect playlist. \u001b[1;36m200\u001b[0m classic house party songs \n",
238
+ "everyone knows set the mood, bringing energy to every celebration. The best popular party hits keep guests dancing,\n",
239
+ "creating unforgettable moments. From throwback anthems to modern beats, a great selection ensures nonstop fun.\n",
240
+ "\n",
241
+ "|The Best Songs For Parties - The Ambient Mixer \n",
242
+ "Blog\u001b[1m]\u001b[0m\u001b[1m(\u001b[0m\u001b[4;94mhttps://blog.ambient-mixer.com/usage/parties-2/the-best-songs-for-parties/\u001b[0m\u001b[4;94m)\u001b[0m\n",
243
+ "The \u001b[1;36m100\u001b[0m best party songs ever made. Top \u001b[1;36m100\u001b[0m Best Party Songs Of All Time. Of course, these are just \u001b[1;36m2\u001b[0m of the many \n",
244
+ "available playlists to choose from. However, these two contain some of the most popular ones most people usually \n",
245
+ "end up using. If these are not the type of songs you or your guests might enjoy then simply follow the steps in the\n",
246
+ "\u001b[33m...\u001b[0m\n",
247
+ "\n",
248
+ "|Passaic County Parks & Recreation: Music at the \n",
249
+ "Mansion\u001b[1m]\u001b[0m\u001b[1m(\u001b[0m\u001b[4;94mhttps://passaiccountynj.myrec.com/info/activities/program_details.aspx?\u001b[0m\u001b[4;94mProgramID\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94m29909\u001b[0m\u001b[4;94m)\u001b[0m\n",
250
+ "Thursdays from \u001b[1;36m7\u001b[0m to \u001b[1;36m9\u001b[0m PM the finest local bands will be playing music while In the Drink restaurant sells food and \n",
251
+ "drinks on site. September 3rd: Norton Smull Band; Parking is limited at the Dey Mansion \u001b[1;36m209\u001b[0m Totowa Rd. Wayne, NJ. \n",
252
+ "Overflow parking will be at the Preakness Valley Golf Course. You may drop off your guests at the Mansion first.\n",
253
+ "\n",
254
+ "|Grand Entrance Songs | SOUNDfonix\u001b[1m]\u001b[0m\u001b[1m(\u001b[0m\u001b[4;94mhttps://soundfonixent.com/resources/reception-song-ideas/grand-entrance-songs/\u001b[0m\u001b[4;94m)\u001b[0m\n",
255
+ "The entrance song sets the tone for the rest of the dance and the evening. Choose your entrance song wisely.\n",
256
+ "\n",
257
+ "|Party Music Guide: Ultimate Tips for the Perfect \n",
258
+ "Playlist\u001b[1m]\u001b[0m\u001b[1m(\u001b[0m\u001b[4;94mhttps://thebackstage-deezer.com/music/perfect-party-music-playlist/\u001b[0m\u001b[4;94m)\u001b[0m\n",
259
+ "Check out the best party playlists and top party songs to ensure your next party is packed! The most popular party \n",
260
+ "songs are here, just hit play. \u001b[33m...\u001b[0m to decor. But, most of all, you need to have fantastic music. We recommend you \n",
261
+ "get at least three hours' worth of party music queued and ready — that's about \u001b[1;36m75\u001b[0m songs. Lucky for you, we've \u001b[33m...\u001b[0m\n",
262
+ "\n",
263
+ "|The Top \u001b[1;36m100\u001b[0m Best Party Songs of All Time - \n",
264
+ "LiveAbout\u001b[1m]\u001b[0m\u001b[1m(\u001b[0m\u001b[4;94mhttps://www.liveabout.com/top-best-party-songs-of-all-time-3248355\u001b[0m\u001b[4;94m)\u001b[0m\n",
265
+ "\u001b[32m\"Macarena\"\u001b[0m then spent \u001b[1;36m14\u001b[0m weeks at No. \u001b[1;36m1\u001b[0m on the U.S. pop singles chart. For more than a year this was one of the \n",
266
+ "most popular special event songs in the United States. It still works well as a charming party song encouraging \n",
267
+ "everyone to join in on the simple dance.\n",
268
+ "\n",
269
+ "|\u001b[1;36m70\u001b[0m Best Piano Bar Songs You Should Request\u001b[1m]\u001b[0m\u001b[1m(\u001b[0m\u001b[4;94mhttps://www.pianoarea.com/best-piano-bar-songs/\u001b[0m\u001b[4;94m)\u001b[0m\n",
270
+ "Best Piano Bar Songs You Should Request \u001b[1;36m1\u001b[0m. \u001b[32m\"Piano Man\"\u001b[0m by Billy Joel. One of the top recommendations for piano bar \n",
271
+ "songs is \u001b[32m\"Piano Man\"\u001b[0m by Billy Joel.. This iconic track was released by Columbia Records in \u001b[1;36m1973\u001b[0m.. As part of the \n",
272
+ "album titled \u001b[32m'Piano Man,'\u001b[0m it's one of Billy Joel's most recognizable works.. The song spins a captivating narrative\n",
273
+ "and showcases Joe's compelling \u001b[33m...\u001b[0m\n"
274
+ ]
275
+ },
276
+ "metadata": {},
277
+ "output_type": "display_data"
278
+ },
279
+ {
280
+ "data": {
281
+ "text/html": [
282
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">[Step 0: Duration 4.70 seconds| Input tokens: 1,174 | Output tokens: 26]</span>\n",
283
+ "</pre>\n"
284
+ ],
285
+ "text/plain": [
286
+ "\u001b[2m[Step 0: Duration 4.70 seconds| Input tokens: 1,174 | Output tokens: 26]\u001b[0m\n"
287
+ ]
288
+ },
289
+ "metadata": {},
290
+ "output_type": "display_data"
291
+ },
292
+ {
293
+ "data": {
294
+ "text/html": [
295
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d4b702; text-decoration-color: #d4b702\">━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ </span><span style=\"font-weight: bold\">Step </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span><span style=\"color: #d4b702; text-decoration-color: #d4b702\"> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━</span>\n",
296
+ "</pre>\n"
297
+ ],
298
+ "text/plain": [
299
+ "\u001b[38;2;212;183;2m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ \u001b[0m\u001b[1mStep \u001b[0m\u001b[1;36m2\u001b[0m\u001b[38;2;212;183;2m ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\n"
300
+ ]
301
+ },
302
+ "metadata": {},
303
+ "output_type": "display_data"
304
+ },
305
+ {
306
+ "data": {
307
+ "text/html": [
308
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮\n",
309
+ "│ Calling tool: 'web_search' with arguments: {'query': 'best party songs for a mansion late-night event'} │\n",
310
+ "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
311
+ "</pre>\n"
312
+ ],
313
+ "text/plain": [
314
+ "╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮\n",
315
+ "│ Calling tool: 'web_search' with arguments: {'query': 'best party songs for a mansion late-night event'} │\n",
316
+ "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n"
317
+ ]
318
+ },
319
+ "metadata": {},
320
+ "output_type": "display_data"
321
+ },
322
+ {
323
+ "data": {
324
+ "text/html": [
325
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Observations: ## Search Results\n",
326
+ "\n",
327
+ "|The <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">75</span> Best Party Songs That Will Get Everyone Dancing - \n",
328
+ "Gear4music<span style=\"font-weight: bold\">](</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://www.gear4music.com/blog/best-party-songs/)</span>\n",
329
+ "The best party songs <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span>. <span style=\"color: #008000; text-decoration-color: #008000\">\"September\"</span> - Earth, Wind &amp; Fire <span style=\"font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1978</span><span style=\"font-weight: bold\">)</span> Quite possibly the best party song. An infectious \n",
330
+ "mix of funk and soul, <span style=\"color: #008000; text-decoration-color: #008000\">\"September\"</span> is celebrated for its upbeat melody and <span style=\"color: #008000; text-decoration-color: #008000\">\"ba-dee-ya\"</span> chorus, making it a timeless \n",
331
+ "dance favorite.\n",
332
+ "\n",
333
+ "|<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">45</span> Songs That Get Your Event Guests on the Dance Floor Every \n",
334
+ "Time<span style=\"font-weight: bold\">](</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://hub.theeventplannerexpo.com/entertainment/35-songs-that-get-your-event-guests-on-the-dance-floor-ever</span>\n",
335
+ "<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">y-time)</span>\n",
336
+ "You'll know your client's event best, including music genre preferences and styles. But these songs are wildly \n",
337
+ "popular among many generations and are always great to have on standby should your dance guests need a boost. Party\n",
338
+ "Songs <span style=\"color: #008000; text-decoration-color: #008000\">\"Flowers\"</span> by Miley Cyrus <span style=\"font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2023</span><span style=\"font-weight: bold\">)</span> <span style=\"color: #008000; text-decoration-color: #008000\">\"TQG\"</span> by KAROL G &amp; Shakira <span style=\"font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2023</span><span style=\"font-weight: bold\">)</span> <span style=\"color: #008000; text-decoration-color: #008000\">\"TRUSTFALL\"</span> by P!nk <span style=\"font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2023</span><span style=\"font-weight: bold\">)</span>\n",
339
+ "\n",
340
+ "|Top <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">200</span> Most Requested Songs - DJ Event Planner<span style=\"font-weight: bold\">](</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://djeventplanner.com/mostrequested.htm)</span>\n",
341
+ "Based on over <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span> million requests using the DJ Event Planner song request system, this is a list of the most \n",
342
+ "requested songs of the past year. <span style=\"color: #808000; text-decoration-color: #808000\">...</span> December <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1963</span> <span style=\"font-weight: bold\">(</span>Oh, What A Night<span style=\"font-weight: bold\">)</span> <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">24</span>: Commodores: Brick House: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">25</span>: Earth, Wind\n",
343
+ "and Fire: Boogie Wonderland: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">26</span>: Elton John: Your Song: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span>: Stevie Wonder: Isn't She Lovely: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">28</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span> Grove St. \n",
344
+ "Party: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">30</span> <span style=\"color: #808000; text-decoration-color: #808000\">...</span>\n",
345
+ "\n",
346
+ "|<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">50</span> Songs on Every Event Planner's Playlist - \n",
347
+ "Eventbrite<span style=\"font-weight: bold\">](</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://www.eventbrite.com/blog/event-planning-playlist-ds00/)</span>\n",
348
+ "For example, fast-paced songs probably aren't the best fit for a formal gala. And smooth jazz is likely to lull \n",
349
+ "your guests at a motivational conference. That's why it's crucial to think about the tone you want to set and \n",
350
+ "choose a playlist that embodies it. We've compiled a list of possible tunes to help you pick the best event songs.\n",
351
+ "\n",
352
+ "|The Best Party Songs of All Time <span style=\"font-weight: bold\">(</span>Our Playlists<span style=\"font-weight: bold\">)](</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://www.ispytunes.com/post/best-party-songs)</span>\n",
353
+ "Discover the best party songs to make your event unforgettable! Our playlists feature the top party songs, from \n",
354
+ "timeless classics to the latest hits. <span style=\"color: #808000; text-decoration-color: #808000\">...</span> Last Friday Night by Katy Perry. Sweet Child O' Mine by Guns N' Roses. I \n",
355
+ "Gotta Feeling by the Black Eyed Peas. <span style=\"color: #808000; text-decoration-color: #808000\">...</span> <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">200</span> Classic House Party Songs Everyone Knows | The Best Popular Party \n",
356
+ "Songs <span style=\"color: #808000; text-decoration-color: #808000\">...</span>\n",
357
+ "\n",
358
+ "|<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">15</span> Best Party Songs of All Time - Singersroom.com<span style=\"font-weight: bold\">](</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://singersroom.com/w75/best-party-songs-of-all-time/)</span>\n",
359
+ "Whether it's a wild club night, a backyard BBQ, or a house party with friends, the best party songs bring people \n",
360
+ "together, get them moving, and keep the good vibes flowing all night long.\n",
361
+ "\n",
362
+ "|Best Songs To Party: DJ's Ultimate Party Songs Playlist - \n",
363
+ "Top40Weekly.com<span style=\"font-weight: bold\">](</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://top40weekly.com/best-songs-to-party/)</span>\n",
364
+ "<span style=\"color: #008000; text-decoration-color: #008000\">\"Jump Around\"</span> by House of Pain is a classic party anthem that has stood the test of time, remaining a staple at \n",
365
+ "parties and sporting events for over two decades. The song's energetic rap verses, pulsating rhythm, and catchy \n",
366
+ "chorus create an atmosphere of pure excitement and exhilaration that never fails to ignite the dance floor.\n",
367
+ "\n",
368
+ "|<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">50</span>+ Best Songs For Your Next Party in <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2025</span> - Aleka's \n",
369
+ "Get-Together<span style=\"font-weight: bold\">](</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://alekasgettogether.com/top-songs-for-any-party/)</span>\n",
370
+ "A perfect, high-energy track to keep the party vibe strong all night. Last Friday Night <span style=\"font-weight: bold\">(</span>T.G.I.F.<span style=\"font-weight: bold\">)</span> - Katy Perry \n",
371
+ "This upbeat pop anthem is a must-play to keep the energy light and fun. Bleeding Love - Leona Lewis A heartfelt \n",
372
+ "ballad that balances out the upbeat tracks with an emotional sing-along. Crank That <span style=\"font-weight: bold\">(</span>Soulja Boy<span style=\"font-weight: bold\">)</span> - Soulja Boy Tell \n",
373
+ "'Em\n",
374
+ "\n",
375
+ "|<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span> Most Influential Songs About Parties &amp; Celebrations <span style=\"font-weight: bold\">(</span>Must Hear<span style=\"font-weight: bold\">)](</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://www.pdmusic.org/songs-about-parties/)</span>\n",
376
+ "Contents. <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span> <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27</span> Most Famous Songs About Parties, Partying &amp; Drinking With Friend <span style=\"font-weight: bold\">(</span>Ultimate Playlist<span style=\"font-weight: bold\">)</span>; <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span> #<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span> <span style=\"color: #008000; text-decoration-color: #008000\">\"Party in</span>\n",
377
+ "<span style=\"color: #008000; text-decoration-color: #008000\">the U.S.A.\"</span> by Miley Cyrus; <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">3</span> #<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span> <span style=\"color: #008000; text-decoration-color: #008000\">\"I Gotta Feeling\"</span> by The Black Eyed Peas; <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">4</span> #<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">3</span> <span style=\"color: #008000; text-decoration-color: #008000\">\"Party Rock Anthem\"</span> by LMFAO; <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span> #<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">4</span> \n",
378
+ "<span style=\"color: #008000; text-decoration-color: #008000\">\"Last Friday Night (T.G.I.F.)\"</span> by Katy Perry; <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">6</span> #<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span> <span style=\"color: #008000; text-decoration-color: #008000\">\"Dancing Queen\"</span> by ABBA; <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">7</span> #<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">6</span> <span style=\"color: #008000; text-decoration-color: #008000\">\"Turn Down for What\"</span> by DJ Snake &amp;\n",
379
+ "Lil Jon\n",
380
+ "\n",
381
+ "|<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">40</span> Best Party Songs | Songs To Dance To, Ranked By Our Editors - Time \n",
382
+ "Out<span style=\"font-weight: bold\">](</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://www.timeout.com/music/best-party-songs)</span>\n",
383
+ "The best is when you go for the extended version, and find yourself in the midst of the intro for about <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">11</span> minutes.\n",
384
+ "But whichever version you go for, this is the party song, in every way. She <span style=\"color: #808000; text-decoration-color: #808000\">...</span>\n",
385
+ "</pre>\n"
386
+ ],
387
+ "text/plain": [
388
+ "Observations: ## Search Results\n",
389
+ "\n",
390
+ "|The \u001b[1;36m75\u001b[0m Best Party Songs That Will Get Everyone Dancing - \n",
391
+ "Gear4music\u001b[1m]\u001b[0m\u001b[1m(\u001b[0m\u001b[4;94mhttps://www.gear4music.com/blog/best-party-songs/\u001b[0m\u001b[4;94m)\u001b[0m\n",
392
+ "The best party songs \u001b[1;36m1\u001b[0m. \u001b[32m\"September\"\u001b[0m - Earth, Wind & Fire \u001b[1m(\u001b[0m\u001b[1;36m1978\u001b[0m\u001b[1m)\u001b[0m Quite possibly the best party song. An infectious \n",
393
+ "mix of funk and soul, \u001b[32m\"September\"\u001b[0m is celebrated for its upbeat melody and \u001b[32m\"ba-dee-ya\"\u001b[0m chorus, making it a timeless \n",
394
+ "dance favorite.\n",
395
+ "\n",
396
+ "|\u001b[1;36m45\u001b[0m Songs That Get Your Event Guests on the Dance Floor Every \n",
397
+ "Time\u001b[1m]\u001b[0m\u001b[1m(\u001b[0m\u001b[4;94mhttps://hub.theeventplannerexpo.com/entertainment/35-songs-that-get-your-event-guests-on-the-dance-floor-ever\u001b[0m\n",
398
+ "\u001b[4;94my-time\u001b[0m\u001b[4;94m)\u001b[0m\n",
399
+ "You'll know your client's event best, including music genre preferences and styles. But these songs are wildly \n",
400
+ "popular among many generations and are always great to have on standby should your dance guests need a boost. Party\n",
401
+ "Songs \u001b[32m\"Flowers\"\u001b[0m by Miley Cyrus \u001b[1m(\u001b[0m\u001b[1;36m2023\u001b[0m\u001b[1m)\u001b[0m \u001b[32m\"TQG\"\u001b[0m by KAROL G & Shakira \u001b[1m(\u001b[0m\u001b[1;36m2023\u001b[0m\u001b[1m)\u001b[0m \u001b[32m\"TRUSTFALL\"\u001b[0m by P!nk \u001b[1m(\u001b[0m\u001b[1;36m2023\u001b[0m\u001b[1m)\u001b[0m\n",
402
+ "\n",
403
+ "|Top \u001b[1;36m200\u001b[0m Most Requested Songs - DJ Event Planner\u001b[1m]\u001b[0m\u001b[1m(\u001b[0m\u001b[4;94mhttps://djeventplanner.com/mostrequested.htm\u001b[0m\u001b[4;94m)\u001b[0m\n",
404
+ "Based on over \u001b[1;36m2\u001b[0m million requests using the DJ Event Planner song request system, this is a list of the most \n",
405
+ "requested songs of the past year. \u001b[33m...\u001b[0m December \u001b[1;36m1963\u001b[0m \u001b[1m(\u001b[0mOh, What A Night\u001b[1m)\u001b[0m \u001b[1;36m24\u001b[0m: Commodores: Brick House: \u001b[1;36m25\u001b[0m: Earth, Wind\n",
406
+ "and Fire: Boogie Wonderland: \u001b[1;36m26\u001b[0m: Elton John: Your Song: \u001b[1;36m27\u001b[0m: Stevie Wonder: Isn't She Lovely: \u001b[1;36m28\u001b[0m: \u001b[33m...\u001b[0m Grove St. \n",
407
+ "Party: \u001b[1;36m30\u001b[0m \u001b[33m...\u001b[0m\n",
408
+ "\n",
409
+ "|\u001b[1;36m50\u001b[0m Songs on Every Event Planner's Playlist - \n",
410
+ "Eventbrite\u001b[1m]\u001b[0m\u001b[1m(\u001b[0m\u001b[4;94mhttps://www.eventbrite.com/blog/event-planning-playlist-ds00/\u001b[0m\u001b[4;94m)\u001b[0m\n",
411
+ "For example, fast-paced songs probably aren't the best fit for a formal gala. And smooth jazz is likely to lull \n",
412
+ "your guests at a motivational conference. That's why it's crucial to think about the tone you want to set and \n",
413
+ "choose a playlist that embodies it. We've compiled a list of possible tunes to help you pick the best event songs.\n",
414
+ "\n",
415
+ "|The Best Party Songs of All Time \u001b[1m(\u001b[0mOur Playlists\u001b[1m)\u001b[0m\u001b[1m]\u001b[0m\u001b[1m(\u001b[0m\u001b[4;94mhttps://www.ispytunes.com/post/best-party-songs\u001b[0m\u001b[4;94m)\u001b[0m\n",
416
+ "Discover the best party songs to make your event unforgettable! Our playlists feature the top party songs, from \n",
417
+ "timeless classics to the latest hits. \u001b[33m...\u001b[0m Last Friday Night by Katy Perry. Sweet Child O' Mine by Guns N' Roses. I \n",
418
+ "Gotta Feeling by the Black Eyed Peas. \u001b[33m...\u001b[0m \u001b[1;36m200\u001b[0m Classic House Party Songs Everyone Knows | The Best Popular Party \n",
419
+ "Songs \u001b[33m...\u001b[0m\n",
420
+ "\n",
421
+ "|\u001b[1;36m15\u001b[0m Best Party Songs of All Time - Singersroom.com\u001b[1m]\u001b[0m\u001b[1m(\u001b[0m\u001b[4;94mhttps://singersroom.com/w75/best-party-songs-of-all-time/\u001b[0m\u001b[4;94m)\u001b[0m\n",
422
+ "Whether it's a wild club night, a backyard BBQ, or a house party with friends, the best party songs bring people \n",
423
+ "together, get them moving, and keep the good vibes flowing all night long.\n",
424
+ "\n",
425
+ "|Best Songs To Party: DJ's Ultimate Party Songs Playlist - \n",
426
+ "Top40Weekly.com\u001b[1m]\u001b[0m\u001b[1m(\u001b[0m\u001b[4;94mhttps://top40weekly.com/best-songs-to-party/\u001b[0m\u001b[4;94m)\u001b[0m\n",
427
+ "\u001b[32m\"Jump Around\"\u001b[0m by House of Pain is a classic party anthem that has stood the test of time, remaining a staple at \n",
428
+ "parties and sporting events for over two decades. The song's energetic rap verses, pulsating rhythm, and catchy \n",
429
+ "chorus create an atmosphere of pure excitement and exhilaration that never fails to ignite the dance floor.\n",
430
+ "\n",
431
+ "|\u001b[1;36m50\u001b[0m+ Best Songs For Your Next Party in \u001b[1;36m2025\u001b[0m - Aleka's \n",
432
+ "Get-Together\u001b[1m]\u001b[0m\u001b[1m(\u001b[0m\u001b[4;94mhttps://alekasgettogether.com/top-songs-for-any-party/\u001b[0m\u001b[4;94m)\u001b[0m\n",
433
+ "A perfect, high-energy track to keep the party vibe strong all night. Last Friday Night \u001b[1m(\u001b[0mT.G.I.F.\u001b[1m)\u001b[0m - Katy Perry \n",
434
+ "This upbeat pop anthem is a must-play to keep the energy light and fun. Bleeding Love - Leona Lewis A heartfelt \n",
435
+ "ballad that balances out the upbeat tracks with an emotional sing-along. Crank That \u001b[1m(\u001b[0mSoulja Boy\u001b[1m)\u001b[0m - Soulja Boy Tell \n",
436
+ "'Em\n",
437
+ "\n",
438
+ "|\u001b[1;36m27\u001b[0m Most Influential Songs About Parties & Celebrations \u001b[1m(\u001b[0mMust Hear\u001b[1m)\u001b[0m\u001b[1m]\u001b[0m\u001b[1m(\u001b[0m\u001b[4;94mhttps://www.pdmusic.org/songs-about-parties/\u001b[0m\u001b[4;94m)\u001b[0m\n",
439
+ "Contents. \u001b[1;36m1\u001b[0m \u001b[1;36m27\u001b[0m Most Famous Songs About Parties, Partying & Drinking With Friend \u001b[1m(\u001b[0mUltimate Playlist\u001b[1m)\u001b[0m; \u001b[1;36m2\u001b[0m #\u001b[1;36m1\u001b[0m \u001b[32m\"Party in\u001b[0m\n",
440
+ "\u001b[32mthe U.S.A.\"\u001b[0m by Miley Cyrus; \u001b[1;36m3\u001b[0m #\u001b[1;36m2\u001b[0m \u001b[32m\"I Gotta Feeling\"\u001b[0m by The Black Eyed Peas; \u001b[1;36m4\u001b[0m #\u001b[1;36m3\u001b[0m \u001b[32m\"Party Rock Anthem\"\u001b[0m by LMFAO; \u001b[1;36m5\u001b[0m #\u001b[1;36m4\u001b[0m \n",
441
+ "\u001b[32m\"Last Friday Night \u001b[0m\u001b[32m(\u001b[0m\u001b[32mT.G.I.F.\u001b[0m\u001b[32m)\u001b[0m\u001b[32m\"\u001b[0m by Katy Perry; \u001b[1;36m6\u001b[0m #\u001b[1;36m5\u001b[0m \u001b[32m\"Dancing Queen\"\u001b[0m by ABBA; \u001b[1;36m7\u001b[0m #\u001b[1;36m6\u001b[0m \u001b[32m\"Turn Down for What\"\u001b[0m by DJ Snake &\n",
442
+ "Lil Jon\n",
443
+ "\n",
444
+ "|\u001b[1;36m40\u001b[0m Best Party Songs | Songs To Dance To, Ranked By Our Editors - Time \n",
445
+ "Out\u001b[1m]\u001b[0m\u001b[1m(\u001b[0m\u001b[4;94mhttps://www.timeout.com/music/best-party-songs\u001b[0m\u001b[4;94m)\u001b[0m\n",
446
+ "The best is when you go for the extended version, and find yourself in the midst of the intro for about \u001b[1;36m11\u001b[0m minutes.\n",
447
+ "But whichever version you go for, this is the party song, in every way. She \u001b[33m...\u001b[0m\n"
448
+ ]
449
+ },
450
+ "metadata": {},
451
+ "output_type": "display_data"
452
+ },
453
+ {
454
+ "data": {
455
+ "text/html": [
456
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">[Step 1: Duration 6.66 seconds| Input tokens: 3,435 | Output tokens: 55]</span>\n",
457
+ "</pre>\n"
458
+ ],
459
+ "text/plain": [
460
+ "\u001b[2m[Step 1: Duration 6.66 seconds| Input tokens: 3,435 | Output tokens: 55]\u001b[0m\n"
461
+ ]
462
+ },
463
+ "metadata": {},
464
+ "output_type": "display_data"
465
+ },
466
+ {
467
+ "data": {
468
+ "text/html": [
469
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d4b702; text-decoration-color: #d4b702\">━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ </span><span style=\"font-weight: bold\">Step </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">3</span><span style=\"color: #d4b702; text-decoration-color: #d4b702\"> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━</span>\n",
470
+ "</pre>\n"
471
+ ],
472
+ "text/plain": [
473
+ "\u001b[38;2;212;183;2m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ \u001b[0m\u001b[1mStep \u001b[0m\u001b[1;36m3\u001b[0m\u001b[38;2;212;183;2m ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\n"
474
+ ]
475
+ },
476
+ "metadata": {},
477
+ "output_type": "display_data"
478
+ },
479
+ {
480
+ "data": {
481
+ "text/html": [
482
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮\n",
483
+ "│ Calling tool: 'final_answer' with arguments: {'answer': \"For a party at Wayne's mansion, consider playing a mix │\n",
484
+ "│ of classic party hits and modern anthems to cater to various age groups. A recommended playlist might include │\n",
485
+ "│ songs like 'September' by Earth, Wind &amp; Fire, 'I Gotta Feeling' by The Black Eyed Peas, 'Last Friday Night │\n",
486
+ "│ (T.G.I.F.)' by Katy Perry, 'Dancing Queen' by ABBA, 'Turn Down for What' by DJ Snake &amp; Lil Jon, and 'Crank That │\n",
487
+ "│ (Soulja Boy)' by Soulja Boy Tell 'Em. These songs are known to get everyone dancing and celebrating!\"} │\n",
488
+ "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
489
+ "</pre>\n"
490
+ ],
491
+ "text/plain": [
492
+ "╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮\n",
493
+ "│ Calling tool: 'final_answer' with arguments: {'answer': \"For a party at Wayne's mansion, consider playing a mix │\n",
494
+ "│ of classic party hits and modern anthems to cater to various age groups. A recommended playlist might include │\n",
495
+ "│ songs like 'September' by Earth, Wind & Fire, 'I Gotta Feeling' by The Black Eyed Peas, 'Last Friday Night │\n",
496
+ "│ (T.G.I.F.)' by Katy Perry, 'Dancing Queen' by ABBA, 'Turn Down for What' by DJ Snake & Lil Jon, and 'Crank That │\n",
497
+ "│ (Soulja Boy)' by Soulja Boy Tell 'Em. These songs are known to get everyone dancing and celebrating!\"} │\n",
498
+ "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n"
499
+ ]
500
+ },
501
+ "metadata": {},
502
+ "output_type": "display_data"
503
+ },
504
+ {
505
+ "data": {
506
+ "text/html": [
507
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d4b702; text-decoration-color: #d4b702; font-weight: bold\">Final answer: For a party at Wayne's mansion, consider playing a mix of classic party hits and modern anthems to </span>\n",
508
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702; font-weight: bold\">cater to various age groups. A recommended playlist might include songs like 'September' by Earth, Wind &amp; Fire, 'I </span>\n",
509
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702; font-weight: bold\">Gotta Feeling' by The Black Eyed Peas, 'Last Friday Night (T.G.I.F.)' by Katy Perry, 'Dancing Queen' by ABBA, 'Turn</span>\n",
510
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702; font-weight: bold\">Down for What' by DJ Snake &amp; Lil Jon, and 'Crank That (Soulja Boy)' by Soulja Boy Tell 'Em. These songs are known </span>\n",
511
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702; font-weight: bold\">to get everyone dancing and celebrating!</span>\n",
512
+ "</pre>\n"
513
+ ],
514
+ "text/plain": [
515
+ "\u001b[1;38;2;212;183;2mFinal answer: For a party at Wayne's mansion, consider playing a mix of classic party hits and modern anthems to \u001b[0m\n",
516
+ "\u001b[1;38;2;212;183;2mcater to various age groups. A recommended playlist might include songs like 'September' by Earth, Wind & Fire, 'I \u001b[0m\n",
517
+ "\u001b[1;38;2;212;183;2mGotta Feeling' by The Black Eyed Peas, 'Last Friday Night (T.G.I.F.)' by Katy Perry, 'Dancing Queen' by ABBA, 'Turn\u001b[0m\n",
518
+ "\u001b[1;38;2;212;183;2mDown for What' by DJ Snake & Lil Jon, and 'Crank That (Soulja Boy)' by Soulja Boy Tell 'Em. These songs are known \u001b[0m\n",
519
+ "\u001b[1;38;2;212;183;2mto get everyone dancing and celebrating!\u001b[0m\n"
520
+ ]
521
+ },
522
+ "metadata": {},
523
+ "output_type": "display_data"
524
+ },
525
+ {
526
+ "data": {
527
+ "text/html": [
528
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">[Step 2: Duration 10.69 seconds| Input tokens: 6,869 | Output tokens: 199]</span>\n",
529
+ "</pre>\n"
530
+ ],
531
+ "text/plain": [
532
+ "\u001b[2m[Step 2: Duration 10.69 seconds| Input tokens: 6,869 | Output tokens: 199]\u001b[0m\n"
533
+ ]
534
+ },
535
+ "metadata": {},
536
+ "output_type": "display_data"
537
+ },
538
+ {
539
+ "data": {
540
+ "application/vnd.google.colaboratory.intrinsic+json": {
541
+ "type": "string"
542
+ },
543
+ "text/plain": [
544
+ "\"For a party at Wayne's mansion, consider playing a mix of classic party hits and modern anthems to cater to various age groups. A recommended playlist might include songs like 'September' by Earth, Wind & Fire, 'I Gotta Feeling' by The Black Eyed Peas, 'Last Friday Night (T.G.I.F.)' by Katy Perry, 'Dancing Queen' by ABBA, 'Turn Down for What' by DJ Snake & Lil Jon, and 'Crank That (Soulja Boy)' by Soulja Boy Tell 'Em. These songs are known to get everyone dancing and celebrating!\""
545
+ ]
546
+ },
547
+ "execution_count": 3,
548
+ "metadata": {},
549
+ "output_type": "execute_result"
550
+ }
551
+ ],
552
+ "source": [
553
+ "from smolagents import ToolCallingAgent, DuckDuckGoSearchTool, HfApiModel\n",
554
+ "\n",
555
+ "agent = ToolCallingAgent(tools=[DuckDuckGoSearchTool()], model=HfApiModel())\n",
556
+ "\n",
557
+ "agent.run(\"Search for the best music recommendations for a party at the Wayne's mansion.\")"
558
+ ]
559
+ },
560
+ {
561
+ "cell_type": "markdown",
562
+ "source": [
563
+ "\n",
564
+ "When you examine the agent's trace, instead of seeing `Executing parsed code:`, you'll see something like:\n",
565
+ "\n",
566
+ "```text\n",
567
+ "╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮\n",
568
+ "│ Calling tool: 'web_search' with arguments: {'query': \"best music recommendations for a party at Wayne's │\n",
569
+ "│ mansion\"} │\n",
570
+ "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
571
+ "``` \n",
572
+ "\n",
573
+ "The agent generates a structured tool call that the system processes to produce the output, rather than directly executing code like a `CodeAgent`.\n",
574
+ "\n",
575
+ "Now that we understand both agent types, we can choose the right one for our needs. Let's continue exploring `smolagents` to make Alfred's party a success! 🎉"
576
+ ],
577
+ "metadata": {
578
+ "id": "Cl19VWGRYXrr"
579
+ }
580
+ }
581
+ ],
582
+ "metadata": {
583
+ "colab": {
584
+ "provenance": []
585
+ },
586
+ "kernelspec": {
587
+ "display_name": "Python 3",
588
+ "name": "python3"
589
+ },
590
+ "language_info": {
591
+ "name": "python"
592
+ }
593
+ },
594
+ "nbformat": 4,
595
+ "nbformat_minor": 0
596
+ }
unit2/smolagents/tools.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
unit2/smolagents/vision_agents.ipynb ADDED
@@ -0,0 +1,535 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {
6
+ "id": "O7wvDb5Xq0ZH"
7
+ },
8
+ "source": [
9
+ "# Vision Agents with smolagents\n",
10
+ "\n",
11
+ "\n",
12
+ "This notebook is part of the [Hugging Face Agents Course](https://www.hf.co/learn/agents-course), a free Course from beginner to expert, where you learn to build Agents.\n",
13
+ "\n",
14
+ "![Agents course share](https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/communication/share.png)"
15
+ ]
16
+ },
17
+ {
18
+ "cell_type": "markdown",
19
+ "metadata": {
20
+ "id": "fqKoOdz8q6fF"
21
+ },
22
+ "source": [
23
+ "## Let's install the dependencies and login to our HF account to access the Inference API\n",
24
+ "\n",
25
+ "If you haven't installed `smolagents` yet, you can do so by running the following command:"
26
+ ]
27
+ },
28
+ {
29
+ "cell_type": "code",
30
+ "execution_count": null,
31
+ "metadata": {
32
+ "id": "m_muGXjDRhTD"
33
+ },
34
+ "outputs": [],
35
+ "source": [
36
+ "!pip install smolagents"
37
+ ]
38
+ },
39
+ {
40
+ "cell_type": "markdown",
41
+ "source": [
42
+ "Let's also login to the Hugging Face Hub to have access to the Inference API."
43
+ ],
44
+ "metadata": {
45
+ "id": "WJGFjRbZbL50"
46
+ }
47
+ },
48
+ {
49
+ "cell_type": "code",
50
+ "execution_count": null,
51
+ "metadata": {
52
+ "id": "MnLNhxDzRiKh"
53
+ },
54
+ "outputs": [],
55
+ "source": [
56
+ "from huggingface_hub import notebook_login\n",
57
+ "\n",
58
+ "notebook_login()"
59
+ ]
60
+ },
61
+ {
62
+ "cell_type": "markdown",
63
+ "metadata": {
64
+ "id": "qOp72sO9q-TD"
65
+ },
66
+ "source": [
67
+ "## Providing Images at the Start of the Agent's Execution\n",
68
+ "\n",
69
+ "In this approach, images are passed to the agent at the start and stored as `task_images` alongside the task prompt. The agent then processes these images throughout its execution. \n",
70
+ "\n",
71
+ "Consider the case where Alfred wants to verify the identities of the superheroes attending the party. He already has a dataset of images from previous parties with the names of the guests. Given a new visitor's image, the agent can compare it with the existing dataset and make a decision about letting them in. \n",
72
+ "\n",
73
+ "In this case, a guest is trying to enter, and Alfred suspects that this visitor might be The Joker impersonating Wonder Woman. Alfred needs to verify their identity to prevent anyone unwanted from entering. \n",
74
+ "\n",
75
+ "Let’s build the example. First, the images are loaded. In this case, we use images from Wikipedia to keep the example minimal, but image the possible use-case!"
76
+ ]
77
+ },
78
+ {
79
+ "cell_type": "code",
80
+ "execution_count": null,
81
+ "metadata": {
82
+ "id": "BI9E3okPR5wc"
83
+ },
84
+ "outputs": [],
85
+ "source": [
86
+ "from PIL import Image\n",
87
+ "import requests\n",
88
+ "from io import BytesIO\n",
89
+ "\n",
90
+ "image_urls = [\n",
91
+ " \"https://upload.wikimedia.org/wikipedia/commons/e/e8/The_Joker_at_Wax_Museum_Plus.jpg\",\n",
92
+ " \"https://upload.wikimedia.org/wikipedia/en/9/98/Joker_%28DC_Comics_character%29.jpg\"\n",
93
+ "]\n",
94
+ "\n",
95
+ "images = []\n",
96
+ "for url in image_urls:\n",
97
+ " response = requests.get(url)\n",
98
+ " image = Image.open(BytesIO(response.content)).convert(\"RGB\")\n",
99
+ " images.append(image)"
100
+ ]
101
+ },
102
+ {
103
+ "cell_type": "markdown",
104
+ "source": [
105
+ "Now that we have the images, the agent will tell us wether the guests is actually a superhero (Wonder Woman) or a villian (The Joker)."
106
+ ],
107
+ "metadata": {
108
+ "id": "vUBQjETkbRU6"
109
+ }
110
+ },
111
+ {
112
+ "cell_type": "code",
113
+ "execution_count": null,
114
+ "metadata": {
115
+ "id": "6HroQ3eIT-3m"
116
+ },
117
+ "outputs": [],
118
+ "source": [
119
+ "from google.colab import userdata\n",
120
+ "import os\n",
121
+ "os.environ[\"OPENAI_API_KEY\"] = userdata.get('OPENAI_API_KEY')"
122
+ ]
123
+ },
124
+ {
125
+ "cell_type": "code",
126
+ "execution_count": null,
127
+ "metadata": {
128
+ "colab": {
129
+ "base_uri": "https://localhost:8080/",
130
+ "height": 1000
131
+ },
132
+ "id": "A8qra0deRkUY",
133
+ "outputId": "2867daa1-e84e-4d02-ef10-eeeaf3ea863d"
134
+ },
135
+ "outputs": [
136
+ {
137
+ "data": {
138
+ "text/html": [
139
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d4b702; text-decoration-color: #d4b702\">╭──────────────────────────────────────────────────── </span><span style=\"color: #d4b702; text-decoration-color: #d4b702; font-weight: bold\">New run</span><span style=\"color: #d4b702; text-decoration-color: #d4b702\"> ────────────────────────────────────────────────────╮</span>\n",
140
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
141
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\">Describe the costume and makeup that the comic character in these photos is wearing and return the description.</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
142
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\"> Tell me if the guest is The Joker or Wonder Woman.</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
143
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
144
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">╰─ OpenAIServerModel - gpt-4o ────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
145
+ "</pre>\n"
146
+ ],
147
+ "text/plain": [
148
+ "\u001b[38;2;212;183;2m╭─\u001b[0m\u001b[38;2;212;183;2m───────────────────────────────────────────────────\u001b[0m\u001b[38;2;212;183;2m \u001b[0m\u001b[1;38;2;212;183;2mNew run\u001b[0m\u001b[38;2;212;183;2m \u001b[0m\u001b[38;2;212;183;2m───────────────────────────────────────────────────\u001b[0m\u001b[38;2;212;183;2m─╮\u001b[0m\n",
149
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
150
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1mDescribe the costume and makeup that the comic character in these photos is wearing and return the description.\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
151
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1m Tell me if the guest is The Joker or Wonder Woman.\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
152
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
153
+ "\u001b[38;2;212;183;2m╰─\u001b[0m\u001b[38;2;212;183;2m OpenAIServerModel - gpt-4o \u001b[0m\u001b[38;2;212;183;2m───────────────────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;212;183;2m─╯\u001b[0m\n"
154
+ ]
155
+ },
156
+ "metadata": {},
157
+ "output_type": "display_data"
158
+ },
159
+ {
160
+ "data": {
161
+ "text/html": [
162
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d4b702; text-decoration-color: #d4b702\">━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ </span><span style=\"font-weight: bold\">Step </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span><span style=\"color: #d4b702; text-decoration-color: #d4b702\"> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━</span>\n",
163
+ "</pre>\n"
164
+ ],
165
+ "text/plain": [
166
+ "\u001b[38;2;212;183;2m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ \u001b[0m\u001b[1mStep \u001b[0m\u001b[1;36m1\u001b[0m\u001b[38;2;212;183;2m ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━��━━━━━━━━━━━━━━━━━━━\u001b[0m\n"
167
+ ]
168
+ },
169
+ "metadata": {},
170
+ "output_type": "display_data"
171
+ },
172
+ {
173
+ "data": {
174
+ "text/html": [
175
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold; font-style: italic\">Output message of the LLM:</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">────────────────────────────────────────────────────────────────────────────────────────</span>\n",
176
+ "<span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117\">I don't have the capability to identify or recognize people in images, but I can describe what I see.</span><span style=\"background-color: #0d1117\"> </span>\n",
177
+ "<span style=\"background-color: #0d1117\"> </span>\n",
178
+ "<span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117\">The character in the photos you provided is wearing:</span><span style=\"background-color: #0d1117\"> </span>\n",
179
+ "<span style=\"background-color: #0d1117\"> </span>\n",
180
+ "<span style=\"color: #ff7b72; text-decoration-color: #ff7b72; background-color: #0d1117\">1.</span><span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117\"> </span><span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117; font-weight: bold\">**Costume:**</span><span style=\"background-color: #0d1117\"> </span>\n",
181
+ "<span style=\"color: #6e7681; text-decoration-color: #6e7681; background-color: #0d1117\"> </span><span style=\"color: #ff7b72; text-decoration-color: #ff7b72; background-color: #0d1117\">-</span><span style=\"color: #6e7681; text-decoration-color: #6e7681; background-color: #0d1117\"> </span><span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117\">A purple suit with a large bow tie in one image.</span><span style=\"background-color: #0d1117\"> </span>\n",
182
+ "<span style=\"color: #6e7681; text-decoration-color: #6e7681; background-color: #0d1117\"> </span><span style=\"color: #ff7b72; text-decoration-color: #ff7b72; background-color: #0d1117\">-</span><span style=\"color: #6e7681; text-decoration-color: #6e7681; background-color: #0d1117\"> </span><span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117\">A white flower lapel and card in another image.</span><span style=\"background-color: #0d1117\"> </span>\n",
183
+ "<span style=\"color: #6e7681; text-decoration-color: #6e7681; background-color: #0d1117\"> </span><span style=\"color: #ff7b72; text-decoration-color: #ff7b72; background-color: #0d1117\">-</span><span style=\"color: #6e7681; text-decoration-color: #6e7681; background-color: #0d1117\"> </span><span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117\">The style is flamboyant and colorful, typical of a comic villain.</span><span style=\"background-color: #0d1117\"> </span>\n",
184
+ "<span style=\"background-color: #0d1117\"> </span>\n",
185
+ "<span style=\"color: #ff7b72; text-decoration-color: #ff7b72; background-color: #0d1117\">2.</span><span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117\"> </span><span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117; font-weight: bold\">**Makeup:**</span><span style=\"background-color: #0d1117\"> </span>\n",
186
+ "<span style=\"color: #6e7681; text-decoration-color: #6e7681; background-color: #0d1117\"> </span><span style=\"color: #ff7b72; text-decoration-color: #ff7b72; background-color: #0d1117\">-</span><span style=\"color: #6e7681; text-decoration-color: #6e7681; background-color: #0d1117\"> </span><span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117\">White face makeup covering the entire face.</span><span style=\"background-color: #0d1117\"> </span>\n",
187
+ "<span style=\"color: #6e7681; text-decoration-color: #6e7681; background-color: #0d1117\"> </span><span style=\"color: #ff7b72; text-decoration-color: #ff7b72; background-color: #0d1117\">-</span><span style=\"color: #6e7681; text-decoration-color: #6e7681; background-color: #0d1117\"> </span><span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117\">Red lips forming a wide, exaggerated smile.</span><span style=\"background-color: #0d1117\"> </span>\n",
188
+ "<span style=\"color: #6e7681; text-decoration-color: #6e7681; background-color: #0d1117\"> </span><span style=\"color: #ff7b72; text-decoration-color: #ff7b72; background-color: #0d1117\">-</span><span style=\"color: #6e7681; text-decoration-color: #6e7681; background-color: #0d1117\"> </span><span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117\">Dark makeup around the eyes.</span><span style=\"background-color: #0d1117\"> </span>\n",
189
+ "<span style=\"color: #6e7681; text-decoration-color: #6e7681; background-color: #0d1117\"> </span><span style=\"color: #ff7b72; text-decoration-color: #ff7b72; background-color: #0d1117\">-</span><span style=\"color: #6e7681; text-decoration-color: #6e7681; background-color: #0d1117\"> </span><span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117\">Green hair.</span><span style=\"background-color: #0d1117\"> </span>\n",
190
+ "<span style=\"background-color: #0d1117\"> </span>\n",
191
+ "<span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117\">From the description, this character resembles The Joker, a well-known comic book villain.</span><span style=\"background-color: #0d1117\"> </span>\n",
192
+ "</pre>\n"
193
+ ],
194
+ "text/plain": [
195
+ "\u001b[1;3mOutput message of the LLM:\u001b[0m \u001b[38;2;212;183;2m────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n",
196
+ "\u001b[38;2;230;237;243;48;2;13;17;23mI\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mdon't\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mhave\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mthe\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mcapability\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mto\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23midentify\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mor\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mrecognize\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mpeople\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23min\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mimages,\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mbut\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mI\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mcan\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mdescribe\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mwhat\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mI\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23msee.\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
197
+ "\u001b[48;2;13;17;23m \u001b[0m\n",
198
+ "\u001b[38;2;230;237;243;48;2;13;17;23mThe\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mcharacter\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23min\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mthe\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mphotos\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23myou\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mprovided\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mis\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mwearing:\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
199
+ "\u001b[48;2;13;17;23m \u001b[0m\n",
200
+ "\u001b[38;2;255;123;114;48;2;13;17;23m1.\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[1;38;2;230;237;243;48;2;13;17;23m**Costume:**\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
201
+ "\u001b[38;2;110;118;129;48;2;13;17;23m \u001b[0m\u001b[38;2;255;123;114;48;2;13;17;23m-\u001b[0m\u001b[38;2;110;118;129;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mA\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mpurple\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23msuit\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mwith\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23ma\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mlarge\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mbow\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mtie\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23min\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mone\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mimage.\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
202
+ "\u001b[38;2;110;118;129;48;2;13;17;23m \u001b[0m\u001b[38;2;255;123;114;48;2;13;17;23m-\u001b[0m\u001b[38;2;110;118;129;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mA\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mwhite\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mflower\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mlapel\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mand\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mcard\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23min\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23manother\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mimage.\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
203
+ "\u001b[38;2;110;118;129;48;2;13;17;23m \u001b[0m\u001b[38;2;255;123;114;48;2;13;17;23m-\u001b[0m\u001b[38;2;110;118;129;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mThe\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mstyle\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mis\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mflamboyant\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mand\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mcolorful,\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mtypical\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mof\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23ma\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mcomic\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mvillain.\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
204
+ "\u001b[48;2;13;17;23m \u001b[0m\n",
205
+ "\u001b[38;2;255;123;114;48;2;13;17;23m2.\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[1;38;2;230;237;243;48;2;13;17;23m**Makeup:**\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
206
+ "\u001b[38;2;110;118;129;48;2;13;17;23m \u001b[0m\u001b[38;2;255;123;114;48;2;13;17;23m-\u001b[0m\u001b[38;2;110;118;129;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mWhite\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mface\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mmakeup\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mcovering\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mthe\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mentire\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mface.\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
207
+ "\u001b[38;2;110;118;129;48;2;13;17;23m \u001b[0m\u001b[38;2;255;123;114;48;2;13;17;23m-\u001b[0m\u001b[38;2;110;118;129;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mRed\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mlips\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mforming\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23ma\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mwide,\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mexaggerated\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23msmile.\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
208
+ "\u001b[38;2;110;118;129;48;2;13;17;23m \u001b[0m\u001b[38;2;255;123;114;48;2;13;17;23m-\u001b[0m\u001b[38;2;110;118;129;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mDark\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mmakeup\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23maround\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mthe\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23meyes.\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
209
+ "\u001b[38;2;110;118;129;48;2;13;17;23m \u001b[0m\u001b[38;2;255;123;114;48;2;13;17;23m-\u001b[0m\u001b[38;2;110;118;129;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mGreen\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mhair.\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
210
+ "\u001b[48;2;13;17;23m \u001b[0m\n",
211
+ "\u001b[38;2;230;237;243;48;2;13;17;23mFrom\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mthe\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mdescription,\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mthis\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mcharacter\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mresembles\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mThe\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mJoker,\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23ma\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mwell-known\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mcomic\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mbook\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mvillain.\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n"
212
+ ]
213
+ },
214
+ "metadata": {},
215
+ "output_type": "display_data"
216
+ },
217
+ {
218
+ "data": {
219
+ "text/html": [
220
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">Error in code parsing:</span>\n",
221
+ "<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">Your code snippet is invalid, because the regex pattern ```(?:py|python)?\\n(.*?)\\n``` was not found in it.</span>\n",
222
+ "<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">Here is your code snippet:</span>\n",
223
+ "<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">I don't have the capability to identify or recognize people in images, but I can describe what I see.</span>\n",
224
+ "\n",
225
+ "<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">The character in the photos you provided is wearing:</span>\n",
226
+ "\n",
227
+ "<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">1</span><span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">. **Costume:**</span>\n",
228
+ "<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> - A purple suit with a large bow tie in one image.</span>\n",
229
+ "<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> - A white flower lapel and card in another image.</span>\n",
230
+ "<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> - The style is flamboyant and colorful, typical of a comic villain.</span>\n",
231
+ "\n",
232
+ "<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">2</span><span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">. **Makeup:**</span>\n",
233
+ "<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> - White face makeup covering the entire face.</span>\n",
234
+ "<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> - Red lips forming a wide, exaggerated smile.</span>\n",
235
+ "<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> - Dark makeup around the eyes.</span>\n",
236
+ "<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> - Green hair.</span>\n",
237
+ "\n",
238
+ "<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">From the description, this character resembles The Joker, a well-known comic book villain.</span>\n",
239
+ "<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">Make sure to include code with the correct pattern, for instance:</span>\n",
240
+ "<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">Thoughts: Your thoughts</span>\n",
241
+ "<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">Code:</span>\n",
242
+ "<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">```py</span>\n",
243
+ "<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"># Your python code here</span>\n",
244
+ "<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">```&lt;end_code&gt;</span>\n",
245
+ "<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">Make sure to provide correct code blobs.</span>\n",
246
+ "</pre>\n"
247
+ ],
248
+ "text/plain": [
249
+ "\u001b[1;31mError in code parsing:\u001b[0m\n",
250
+ "\u001b[1;31mYour code snippet is invalid, because the regex pattern ```\u001b[0m\u001b[1;31m(\u001b[0m\u001b[1;31m?:py|python\u001b[0m\u001b[1;31m)\u001b[0m\u001b[1;31m?\\\u001b[0m\u001b[1;31mn\u001b[0m\u001b[1;31m(\u001b[0m\u001b[1;31m.*?\u001b[0m\u001b[1;31m)\u001b[0m\u001b[1;31m\\n``` was not found in it.\u001b[0m\n",
251
+ "\u001b[1;31mHere is your code snippet:\u001b[0m\n",
252
+ "\u001b[1;31mI don't have the capability to identify or recognize people in images, but I can describe what I see.\u001b[0m\n",
253
+ "\n",
254
+ "\u001b[1;31mThe character in the photos you provided is wearing:\u001b[0m\n",
255
+ "\n",
256
+ "\u001b[1;31m1\u001b[0m\u001b[1;31m. **Costume:**\u001b[0m\n",
257
+ "\u001b[1;31m - A purple suit with a large bow tie in one image.\u001b[0m\n",
258
+ "\u001b[1;31m - A white flower lapel and card in another image.\u001b[0m\n",
259
+ "\u001b[1;31m - The style is flamboyant and colorful, typical of a comic villain.\u001b[0m\n",
260
+ "\n",
261
+ "\u001b[1;31m2\u001b[0m\u001b[1;31m. **Makeup:**\u001b[0m\n",
262
+ "\u001b[1;31m - White face makeup covering the entire face.\u001b[0m\n",
263
+ "\u001b[1;31m - Red lips forming a wide, exaggerated smile.\u001b[0m\n",
264
+ "\u001b[1;31m - Dark makeup around the eyes.\u001b[0m\n",
265
+ "\u001b[1;31m - Green hair.\u001b[0m\n",
266
+ "\n",
267
+ "\u001b[1;31mFrom the description, this character resembles The Joker, a well-known comic book villain.\u001b[0m\n",
268
+ "\u001b[1;31mMake sure to include code with the correct pattern, for instance:\u001b[0m\n",
269
+ "\u001b[1;31mThoughts: Your thoughts\u001b[0m\n",
270
+ "\u001b[1;31mCode:\u001b[0m\n",
271
+ "\u001b[1;31m```py\u001b[0m\n",
272
+ "\u001b[1;31m# Your python code here\u001b[0m\n",
273
+ "\u001b[1;31m```\u001b[0m\u001b[1;31m<\u001b[0m\u001b[1;31mend_code\u001b[0m\u001b[1;31m>\u001b[0m\n",
274
+ "\u001b[1;31mMake sure to provide correct code blobs.\u001b[0m\n"
275
+ ]
276
+ },
277
+ "metadata": {},
278
+ "output_type": "display_data"
279
+ },
280
+ {
281
+ "data": {
282
+ "text/html": [
283
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">[Step 0: Duration 4.30 seconds| Input tokens: 3,004 | Output tokens: 139]</span>\n",
284
+ "</pre>\n"
285
+ ],
286
+ "text/plain": [
287
+ "\u001b[2m[Step 0: Duration 4.30 seconds| Input tokens: 3,004 | Output tokens: 139]\u001b[0m\n"
288
+ ]
289
+ },
290
+ "metadata": {},
291
+ "output_type": "display_data"
292
+ },
293
+ {
294
+ "data": {
295
+ "text/html": [
296
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d4b702; text-decoration-color: #d4b702\">━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ </span><span style=\"font-weight: bold\">Step </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span><span style=\"color: #d4b702; text-decoration-color: #d4b702\"> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━</span>\n",
297
+ "</pre>\n"
298
+ ],
299
+ "text/plain": [
300
+ "\u001b[38;2;212;183;2m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ \u001b[0m\u001b[1mStep \u001b[0m\u001b[1;36m2\u001b[0m\u001b[38;2;212;183;2m ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\n"
301
+ ]
302
+ },
303
+ "metadata": {},
304
+ "output_type": "display_data"
305
+ },
306
+ {
307
+ "data": {
308
+ "text/html": [
309
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold; font-style: italic\">Output message of the LLM:</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">────────────────────────────────────────────────────────────────────────────────────────</span>\n",
310
+ "<span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117\">I'm unable to identify characters in images, but I can offer a description.</span><span style=\"background-color: #0d1117\"> </span>\n",
311
+ "<span style=\"background-color: #0d1117\"> </span>\n",
312
+ "<span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117\">Thought: From the images, I will describe the costume and makeup.</span><span style=\"background-color: #0d1117\"> </span>\n",
313
+ "<span style=\"background-color: #0d1117\"> </span>\n",
314
+ "<span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117\">Code:</span><span style=\"background-color: #0d1117\"> </span>\n",
315
+ "<span style=\"color: #a5d6ff; text-decoration-color: #a5d6ff; background-color: #0d1117\">```py</span><span style=\"background-color: #0d1117\"> </span>\n",
316
+ "<span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117\">description </span><span style=\"color: #ff7b72; text-decoration-color: #ff7b72; background-color: #0d1117; font-weight: bold\">=</span><span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117\"> </span><span style=\"color: #a5d6ff; text-decoration-color: #a5d6ff; background-color: #0d1117\">\"\"\"</span><span style=\"background-color: #0d1117\"> </span>\n",
317
+ "<span style=\"color: #a5d6ff; text-decoration-color: #a5d6ff; background-color: #0d1117\">1. Costume:</span><span style=\"background-color: #0d1117\"> </span>\n",
318
+ "<span style=\"color: #a5d6ff; text-decoration-color: #a5d6ff; background-color: #0d1117\"> - A purple suit with a yellow shirt and a large purple bow tie.</span><span style=\"background-color: #0d1117\"> </span>\n",
319
+ "<span style=\"color: #a5d6ff; text-decoration-color: #a5d6ff; background-color: #0d1117\"> - Features a white flower lapel and a playing card in the second image.</span><span style=\"background-color: #0d1117\"> </span>\n",
320
+ "<span style=\"color: #a5d6ff; text-decoration-color: #a5d6ff; background-color: #0d1117\"> - The style is flamboyant, consistent with a comic villain.</span><span style=\"background-color: #0d1117\"> </span>\n",
321
+ "<span style=\"background-color: #0d1117\"> </span>\n",
322
+ "<span style=\"color: #a5d6ff; text-decoration-color: #a5d6ff; background-color: #0d1117\">2. Makeup:</span><span style=\"background-color: #0d1117\"> </span>\n",
323
+ "<span style=\"color: #a5d6ff; text-decoration-color: #a5d6ff; background-color: #0d1117\"> - White face makeup covering the entire face.</span><span style=\"background-color: #0d1117\"> </span>\n",
324
+ "<span style=\"color: #a5d6ff; text-decoration-color: #a5d6ff; background-color: #0d1117\"> - Red lips forming a wide, exaggerated smile.</span><span style=\"background-color: #0d1117\"> </span>\n",
325
+ "<span style=\"color: #a5d6ff; text-decoration-color: #a5d6ff; background-color: #0d1117\"> - Blue eyeshadow with dark eye accents.</span><span style=\"background-color: #0d1117\"> </span>\n",
326
+ "<span style=\"color: #a5d6ff; text-decoration-color: #a5d6ff; background-color: #0d1117\"> - Slicked-back green hair.</span><span style=\"background-color: #0d1117\"> </span>\n",
327
+ "<span style=\"color: #a5d6ff; text-decoration-color: #a5d6ff; background-color: #0d1117\">\"\"\"</span><span style=\"background-color: #0d1117\"> </span>\n",
328
+ "<span style=\"background-color: #0d1117\"> </span>\n",
329
+ "<span style=\"color: #8b949e; text-decoration-color: #8b949e; background-color: #0d1117; font-style: italic\"># Based on the description, this character resembles The Joker.</span><span style=\"background-color: #0d1117\"> </span>\n",
330
+ "<span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117\">character </span><span style=\"color: #ff7b72; text-decoration-color: #ff7b72; background-color: #0d1117; font-weight: bold\">=</span><span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117\"> </span><span style=\"color: #a5d6ff; text-decoration-color: #a5d6ff; background-color: #0d1117\">\"The Joker\"</span><span style=\"background-color: #0d1117\"> </span>\n",
331
+ "<span style=\"background-color: #0d1117\"> </span>\n",
332
+ "<span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117\">final_answer({</span><span style=\"color: #a5d6ff; text-decoration-color: #a5d6ff; background-color: #0d1117\">\"description\"</span><span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117\">: description, </span><span style=\"color: #a5d6ff; text-decoration-color: #a5d6ff; background-color: #0d1117\">\"character\"</span><span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117\">: character})</span><span style=\"background-color: #0d1117\"> </span>\n",
333
+ "<span style=\"color: #a5d6ff; text-decoration-color: #a5d6ff; background-color: #0d1117\">```</span><span style=\"background-color: #0d1117\"> </span>\n",
334
+ "</pre>\n"
335
+ ],
336
+ "text/plain": [
337
+ "\u001b[1;3mOutput message of the LLM:\u001b[0m \u001b[38;2;212;183;2m────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n",
338
+ "\u001b[38;2;230;237;243;48;2;13;17;23mI'm\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23munable\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mto\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23midentify\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mcharacters\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23min\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mimages,\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mbut\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mI\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mcan\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23moffer\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23ma\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mdescription.\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
339
+ "\u001b[48;2;13;17;23m \u001b[0m\n",
340
+ "\u001b[38;2;230;237;243;48;2;13;17;23mThought:\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mFrom\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mthe\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mimages,\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mI\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mwill\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mdescribe\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mthe\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mcostume\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mand\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mmakeup.\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
341
+ "\u001b[48;2;13;17;23m \u001b[0m\n",
342
+ "\u001b[38;2;230;237;243;48;2;13;17;23mCode:\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
343
+ "\u001b[38;2;165;214;255;48;2;13;17;23m```\u001b[0m\u001b[38;2;165;214;255;48;2;13;17;23mpy\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
344
+ "\u001b[38;2;230;237;243;48;2;13;17;23mdescription\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[1;38;2;255;123;114;48;2;13;17;23m=\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;165;214;255;48;2;13;17;23m\"\"\"\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
345
+ "\u001b[38;2;165;214;255;48;2;13;17;23m1. Costume:\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
346
+ "\u001b[38;2;165;214;255;48;2;13;17;23m - A purple suit with a yellow shirt and a large purple bow tie.\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
347
+ "\u001b[38;2;165;214;255;48;2;13;17;23m - Features a white flower lapel and a playing card in the second image.\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
348
+ "\u001b[38;2;165;214;255;48;2;13;17;23m - The style is flamboyant, consistent with a comic villain.\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
349
+ "\u001b[48;2;13;17;23m \u001b[0m\n",
350
+ "\u001b[38;2;165;214;255;48;2;13;17;23m2. Makeup:\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
351
+ "\u001b[38;2;165;214;255;48;2;13;17;23m - White face makeup covering the entire face.\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
352
+ "\u001b[38;2;165;214;255;48;2;13;17;23m - Red lips forming a wide, exaggerated smile.\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
353
+ "\u001b[38;2;165;214;255;48;2;13;17;23m - Blue eyeshadow with dark eye accents.\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
354
+ "\u001b[38;2;165;214;255;48;2;13;17;23m - Slicked-back green hair.\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
355
+ "\u001b[38;2;165;214;255;48;2;13;17;23m\"\"\"\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
356
+ "\u001b[48;2;13;17;23m \u001b[0m\n",
357
+ "\u001b[3;38;2;139;148;158;48;2;13;17;23m# Based on the description, this character resembles The Joker.\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
358
+ "\u001b[38;2;230;237;243;48;2;13;17;23mcharacter\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[1;38;2;255;123;114;48;2;13;17;23m=\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;165;214;255;48;2;13;17;23m\"\u001b[0m\u001b[38;2;165;214;255;48;2;13;17;23mThe Joker\u001b[0m\u001b[38;2;165;214;255;48;2;13;17;23m\"\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
359
+ "\u001b[48;2;13;17;23m \u001b[0m\n",
360
+ "\u001b[38;2;230;237;243;48;2;13;17;23mfinal_answer\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m(\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m{\u001b[0m\u001b[38;2;165;214;255;48;2;13;17;23m\"\u001b[0m\u001b[38;2;165;214;255;48;2;13;17;23mdescription\u001b[0m\u001b[38;2;165;214;255;48;2;13;17;23m\"\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m:\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mdescription\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m,\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;165;214;255;48;2;13;17;23m\"\u001b[0m\u001b[38;2;165;214;255;48;2;13;17;23mcharacter\u001b[0m\u001b[38;2;165;214;255;48;2;13;17;23m\"\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m:\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mcharacter\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m}\u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23m)\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
361
+ "\u001b[38;2;165;214;255;48;2;13;17;23m```\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n"
362
+ ]
363
+ },
364
+ "metadata": {},
365
+ "output_type": "display_data"
366
+ },
367
+ {
368
+ "data": {
369
+ "text/html": [
370
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"> ─ <span style=\"font-weight: bold\">Executing parsed code:</span> ──────────────────────────────────────────────────────────────────────────────────────── \n",
371
+ " <span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">description </span><span style=\"color: #ff4689; text-decoration-color: #ff4689; background-color: #272822\">=</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> </span><span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\">\"\"\"</span><span style=\"background-color: #272822\"> </span> \n",
372
+ " <span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\">1. Costume:</span><span style=\"background-color: #272822\"> </span> \n",
373
+ " <span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\"> - A purple suit with a yellow shirt and a large purple bow tie.</span><span style=\"background-color: #272822\"> </span> \n",
374
+ " <span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\"> - Features a white flower lapel and a playing card in the second image.</span><span style=\"background-color: #272822\"> </span> \n",
375
+ " <span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\"> - The style is flamboyant, consistent with a comic villain.</span><span style=\"background-color: #272822\"> </span> \n",
376
+ " <span style=\"background-color: #272822\"> </span> \n",
377
+ " <span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\">2. Makeup:</span><span style=\"background-color: #272822\"> </span> \n",
378
+ " <span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\"> - White face makeup covering the entire face.</span><span style=\"background-color: #272822\"> </span> \n",
379
+ " <span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\"> - Red lips forming a wide, exaggerated smile.</span><span style=\"background-color: #272822\"> </span> \n",
380
+ " <span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\"> - Blue eyeshadow with dark eye accents.</span><span style=\"background-color: #272822\"> </span> \n",
381
+ " <span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\"> - Slicked-back green hair.</span><span style=\"background-color: #272822\"> </span> \n",
382
+ " <span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\">\"\"\"</span><span style=\"background-color: #272822\"> </span> \n",
383
+ " <span style=\"background-color: #272822\"> </span> \n",
384
+ " <span style=\"color: #959077; text-decoration-color: #959077; background-color: #272822\"># Based on the description, this character resembles The Joker.</span><span style=\"background-color: #272822\"> </span> \n",
385
+ " <span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">character </span><span style=\"color: #ff4689; text-decoration-color: #ff4689; background-color: #272822\">=</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> </span><span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\">\"The Joker\"</span><span style=\"background-color: #272822\"> </span> \n",
386
+ " <span style=\"background-color: #272822\"> </span> \n",
387
+ " <span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">final_answer({</span><span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\">\"description\"</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">: description, </span><span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\">\"character\"</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">: character})</span><span style=\"background-color: #272822\"> </span> \n",
388
+ " ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── \n",
389
+ "</pre>\n"
390
+ ],
391
+ "text/plain": [
392
+ " ─ \u001b[1mExecuting parsed code:\u001b[0m ──────────────────────────────────────────────────────────────────────────────────────── \n",
393
+ " \u001b[38;2;248;248;242;48;2;39;40;34mdescription\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;255;70;137;48;2;39;40;34m=\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34m\"\"\"\u001b[0m\u001b[48;2;39;40;34m \u001b[0m \n",
394
+ " \u001b[38;2;230;219;116;48;2;39;40;34m1. Costume:\u001b[0m\u001b[48;2;39;40;34m \u001b[0m \n",
395
+ " \u001b[38;2;230;219;116;48;2;39;40;34m - A purple suit with a yellow shirt and a large purple bow tie.\u001b[0m\u001b[48;2;39;40;34m \u001b[0m \n",
396
+ " \u001b[38;2;230;219;116;48;2;39;40;34m - Features a white flower lapel and a playing card in the second image.\u001b[0m\u001b[48;2;39;40;34m \u001b[0m \n",
397
+ " \u001b[38;2;230;219;116;48;2;39;40;34m - The style is flamboyant, consistent with a comic villain.\u001b[0m\u001b[48;2;39;40;34m \u001b[0m \n",
398
+ " \u001b[48;2;39;40;34m \u001b[0m \n",
399
+ " \u001b[38;2;230;219;116;48;2;39;40;34m2. Makeup:\u001b[0m\u001b[48;2;39;40;34m \u001b[0m \n",
400
+ " \u001b[38;2;230;219;116;48;2;39;40;34m - White face makeup covering the entire face.\u001b[0m\u001b[48;2;39;40;34m \u001b[0m \n",
401
+ " \u001b[38;2;230;219;116;48;2;39;40;34m - Red lips forming a wide, exaggerated smile.\u001b[0m\u001b[48;2;39;40;34m \u001b[0m \n",
402
+ " \u001b[38;2;230;219;116;48;2;39;40;34m - Blue eyeshadow with dark eye accents.\u001b[0m\u001b[48;2;39;40;34m \u001b[0m \n",
403
+ " \u001b[38;2;230;219;116;48;2;39;40;34m - Slicked-back green hair.\u001b[0m\u001b[48;2;39;40;34m \u001b[0m \n",
404
+ " \u001b[38;2;230;219;116;48;2;39;40;34m\"\"\"\u001b[0m\u001b[48;2;39;40;34m \u001b[0m \n",
405
+ " \u001b[48;2;39;40;34m \u001b[0m \n",
406
+ " \u001b[38;2;149;144;119;48;2;39;40;34m# Based on the description, this character resembles The Joker.\u001b[0m\u001b[48;2;39;40;34m \u001b[0m \n",
407
+ " \u001b[38;2;248;248;242;48;2;39;40;34mcharacter\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;255;70;137;48;2;39;40;34m=\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34m\"\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34mThe Joker\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34m\"\u001b[0m\u001b[48;2;39;40;34m \u001b[0m \n",
408
+ " \u001b[48;2;39;40;34m \u001b[0m \n",
409
+ " \u001b[38;2;248;248;242;48;2;39;40;34mfinal_answer\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m(\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m{\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34m\"\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34mdescription\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34m\"\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m:\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mdescription\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m,\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34m\"\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34mcharacter\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34m\"\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m:\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mcharacter\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m}\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m)\u001b[0m\u001b[48;2;39;40;34m \u001b[0m \n",
410
+ " ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── \n"
411
+ ]
412
+ },
413
+ "metadata": {},
414
+ "output_type": "display_data"
415
+ },
416
+ {
417
+ "data": {
418
+ "text/html": [
419
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d4b702; text-decoration-color: #d4b702; font-weight: bold\">Out - Final answer: {'description': '\\n1. Costume:\\n - A purple suit with a yellow shirt and a large purple bow </span>\n",
420
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702; font-weight: bold\">tie.\\n - Features a white flower lapel and a playing card in the second image.\\n - The style is flamboyant, </span>\n",
421
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702; font-weight: bold\">consistent with a comic villain.\\n\\n2. Makeup:\\n - White face makeup covering the entire face.\\n - Red lips </span>\n",
422
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702; font-weight: bold\">forming a wide, exaggerated smile.\\n - Blue eyeshadow with dark eye accents.\\n - Slicked-back green hair.\\n', </span>\n",
423
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702; font-weight: bold\">'character': 'The Joker'}</span>\n",
424
+ "</pre>\n"
425
+ ],
426
+ "text/plain": [
427
+ "\u001b[1;38;2;212;183;2mOut - Final answer: {'description': '\\n1. Costume:\\n - A purple suit with a yellow shirt and a large purple bow \u001b[0m\n",
428
+ "\u001b[1;38;2;212;183;2mtie.\\n - Features a white flower lapel and a playing card in the second image.\\n - The style is flamboyant, \u001b[0m\n",
429
+ "\u001b[1;38;2;212;183;2mconsistent with a comic villain.\\n\\n2. Makeup:\\n - White face makeup covering the entire face.\\n - Red lips \u001b[0m\n",
430
+ "\u001b[1;38;2;212;183;2mforming a wide, exaggerated smile.\\n - Blue eyeshadow with dark eye accents.\\n - Slicked-back green hair.\\n', \u001b[0m\n",
431
+ "\u001b[1;38;2;212;183;2m'character': 'The Joker'}\u001b[0m\n"
432
+ ]
433
+ },
434
+ "metadata": {},
435
+ "output_type": "display_data"
436
+ },
437
+ {
438
+ "data": {
439
+ "text/html": [
440
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">[Step 1: Duration 7.36 seconds| Input tokens: 7,431 | Output tokens: 302]</span>\n",
441
+ "</pre>\n"
442
+ ],
443
+ "text/plain": [
444
+ "\u001b[2m[Step 1: Duration 7.36 seconds| Input tokens: 7,431 | Output tokens: 302]\u001b[0m\n"
445
+ ]
446
+ },
447
+ "metadata": {},
448
+ "output_type": "display_data"
449
+ }
450
+ ],
451
+ "source": [
452
+ "from smolagents import CodeAgent, OpenAIServerModel\n",
453
+ "\n",
454
+ "model = OpenAIServerModel(model_id=\"gpt-4o\")\n",
455
+ "\n",
456
+ "# Instantiate the agent\n",
457
+ "agent = CodeAgent(\n",
458
+ " tools=[],\n",
459
+ " model=model,\n",
460
+ " max_steps=20,\n",
461
+ " verbosity_level=2\n",
462
+ ")\n",
463
+ "\n",
464
+ "response = agent.run(\n",
465
+ " \"\"\"\n",
466
+ " Describe the costume and makeup that the comic character in these photos is wearing and return the description.\n",
467
+ " Tell me if the guest is The Joker or Wonder Woman.\n",
468
+ " \"\"\",\n",
469
+ " images=images\n",
470
+ ")"
471
+ ]
472
+ },
473
+ {
474
+ "cell_type": "code",
475
+ "execution_count": null,
476
+ "metadata": {
477
+ "colab": {
478
+ "base_uri": "https://localhost:8080/"
479
+ },
480
+ "id": "uvKj37AmeIu0",
481
+ "outputId": "ed7984d4-f6a2-4062-9939-41cb2e97b3b2"
482
+ },
483
+ "outputs": [
484
+ {
485
+ "data": {
486
+ "text/plain": [
487
+ "{'description': '\\n1. Costume:\\n - A purple suit with a yellow shirt and a large purple bow tie.\\n - Features a white flower lapel and a playing card in the second image.\\n - The style is flamboyant, consistent with a comic villain.\\n\\n2. Makeup:\\n - White face makeup covering the entire face.\\n - Red lips forming a wide, exaggerated smile.\\n - Blue eyeshadow with dark eye accents.\\n - Slicked-back green hair.\\n',\n",
488
+ " 'character': 'The Joker'}"
489
+ ]
490
+ },
491
+ "execution_count": 40,
492
+ "metadata": {},
493
+ "output_type": "execute_result"
494
+ }
495
+ ],
496
+ "source": [
497
+ "response"
498
+ ]
499
+ },
500
+ {
501
+ "cell_type": "markdown",
502
+ "source": [
503
+ "In this case, the output reveals that the person is impersonating someone else, so we can prevent The Joker from entering the party!"
504
+ ],
505
+ "metadata": {
506
+ "id": "NrV-yK5zbT9r"
507
+ }
508
+ },
509
+ {
510
+ "cell_type": "markdown",
511
+ "metadata": {
512
+ "id": "ziyfk-3ZrHw5"
513
+ },
514
+ "source": [
515
+ "## Providing Images with Dynamic Retrieval\n",
516
+ "\n",
517
+ "This examples is provided as a `.py` file since it needs to be run locally since it'll browse the web. Go to the [Hugging Face Agents Course](https://www.hf.co/learn/agents-course) for more details."
518
+ ]
519
+ }
520
+ ],
521
+ "metadata": {
522
+ "colab": {
523
+ "provenance": []
524
+ },
525
+ "kernelspec": {
526
+ "display_name": "Python 3",
527
+ "name": "python3"
528
+ },
529
+ "language_info": {
530
+ "name": "python"
531
+ }
532
+ },
533
+ "nbformat": 4,
534
+ "nbformat_minor": 0
535
+ }
unit2/smolagents/vision_web_browser.py ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ from io import BytesIO
3
+ from time import sleep
4
+
5
+ import helium
6
+ from dotenv import load_dotenv
7
+ from PIL import Image
8
+ from selenium import webdriver
9
+ from selenium.webdriver.common.by import By
10
+ from selenium.webdriver.common.keys import Keys
11
+
12
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, tool
13
+ from smolagents.agents import ActionStep
14
+ from smolagents.cli import load_model
15
+
16
+
17
+ alfred_guest_list_request = """
18
+ I am Alfred, the butler of Wayne Manor, responsible for verifying the identity of guests at party. A superhero has arrived at the entrance claiming to be Wonder Woman, but I need to confirm if she is who she says she is.
19
+
20
+ Please search for images of Wonder Woman and generate a detailed visual description based on those images. Additionally, navigate to Wikipedia to gather key details about her appearance. With this information, I can determine whether to grant her access to the event.
21
+ """
22
+
23
+
24
+ def parse_arguments():
25
+ parser = argparse.ArgumentParser(description="Run a web browser automation script with a specified model.")
26
+ parser.add_argument(
27
+ "prompt",
28
+ type=str,
29
+ nargs="?", # Makes it optional
30
+ default=alfred_guest_list_request,
31
+ help="The prompt to run with the agent",
32
+ )
33
+ parser.add_argument(
34
+ "--model-type",
35
+ type=str,
36
+ default="LiteLLMModel",
37
+ help="The model type to use (e.g., OpenAIServerModel, LiteLLMModel, TransformersModel, HfApiModel)",
38
+ )
39
+ parser.add_argument(
40
+ "--model-id",
41
+ type=str,
42
+ default="gpt-4o",
43
+ help="The model ID to use for the specified model type",
44
+ )
45
+ return parser.parse_args()
46
+
47
+
48
+ def save_screenshot(memory_step: ActionStep, agent: CodeAgent) -> None:
49
+ sleep(1.0) # Let JavaScript animations happen before taking the screenshot
50
+ driver = helium.get_driver()
51
+ current_step = memory_step.step_number
52
+ if driver is not None:
53
+ for previous_memory_step in agent.memory.steps: # Remove previous screenshots from logs for lean processing
54
+ if isinstance(previous_memory_step, ActionStep) and previous_memory_step.step_number <= current_step - 2:
55
+ previous_memory_step.observations_images = None
56
+ png_bytes = driver.get_screenshot_as_png()
57
+ image = Image.open(BytesIO(png_bytes))
58
+ print(f"Captured a browser screenshot: {image.size} pixels")
59
+ memory_step.observations_images = [image.copy()] # Create a copy to ensure it persists, important!
60
+
61
+ # Update observations with current URL
62
+ url_info = f"Current url: {driver.current_url}"
63
+ memory_step.observations = (
64
+ url_info if memory_step.observations is None else memory_step.observations + "\n" + url_info
65
+ )
66
+ return
67
+
68
+
69
+ @tool
70
+ def search_item_ctrl_f(text: str, nth_result: int = 1) -> str:
71
+ """
72
+ Searches for text on the current page via Ctrl + F and jumps to the nth occurrence.
73
+ Args:
74
+ text: The text to search for
75
+ nth_result: Which occurrence to jump to (default: 1)
76
+ """
77
+ elements = driver.find_elements(By.XPATH, f"//*[contains(text(), '{text}')]")
78
+ if nth_result > len(elements):
79
+ raise Exception(f"Match n°{nth_result} not found (only {len(elements)} matches found)")
80
+ result = f"Found {len(elements)} matches for '{text}'."
81
+ elem = elements[nth_result - 1]
82
+ driver.execute_script("arguments[0].scrollIntoView(true);", elem)
83
+ result += f"Focused on element {nth_result} of {len(elements)}"
84
+ return result
85
+
86
+
87
+ @tool
88
+ def go_back() -> None:
89
+ """Goes back to previous page."""
90
+ driver.back()
91
+
92
+
93
+ @tool
94
+ def close_popups() -> str:
95
+ """
96
+ Closes any visible modal or pop-up on the page. Use this to dismiss pop-up windows! This does not work on cookie consent banners.
97
+ """
98
+ webdriver.ActionChains(driver).send_keys(Keys.ESCAPE).perform()
99
+
100
+
101
+ def initialize_driver():
102
+ """Initialize the Selenium WebDriver."""
103
+ chrome_options = webdriver.ChromeOptions()
104
+ chrome_options.add_argument("--force-device-scale-factor=1")
105
+ chrome_options.add_argument("--window-size=1000,1350")
106
+ chrome_options.add_argument("--disable-pdf-viewer")
107
+ chrome_options.add_argument("--window-position=0,0")
108
+ return helium.start_chrome(headless=False, options=chrome_options)
109
+
110
+
111
+ def initialize_agent(model):
112
+ """Initialize the CodeAgent with the specified model."""
113
+ return CodeAgent(
114
+ tools=[DuckDuckGoSearchTool(), go_back, close_popups, search_item_ctrl_f],
115
+ model=model,
116
+ additional_authorized_imports=["helium"],
117
+ step_callbacks=[save_screenshot],
118
+ max_steps=20,
119
+ verbosity_level=2,
120
+ )
121
+
122
+
123
+ helium_instructions = """
124
+ Use your web_search tool when you want to get Google search results.
125
+ Then you can use helium to access websites. Don't use helium for Google search, only for navigating websites!
126
+ Don't bother about the helium driver, it's already managed.
127
+ We've already ran "from helium import *"
128
+ Then you can go to pages!
129
+ Code:
130
+ ```py
131
+ go_to('github.com/trending')
132
+ ```<end_code>
133
+
134
+ You can directly click clickable elements by inputting the text that appears on them.
135
+ Code:
136
+ ```py
137
+ click("Top products")
138
+ ```<end_code>
139
+
140
+ If it's a link:
141
+ Code:
142
+ ```py
143
+ click(Link("Top products"))
144
+ ```<end_code>
145
+
146
+ If you try to interact with an element and it's not found, you'll get a LookupError.
147
+ In general stop your action after each button click to see what happens on your screenshot.
148
+ Never try to login in a page.
149
+
150
+ To scroll up or down, use scroll_down or scroll_up with as an argument the number of pixels to scroll from.
151
+ Code:
152
+ ```py
153
+ scroll_down(num_pixels=1200) # This will scroll one viewport down
154
+ ```<end_code>
155
+
156
+ When you have pop-ups with a cross icon to close, don't try to click the close icon by finding its element or targeting an 'X' element (this most often fails).
157
+ Just use your built-in tool `close_popups` to close them:
158
+ Code:
159
+ ```py
160
+ close_popups()
161
+ ```<end_code>
162
+
163
+ You can use .exists() to check for the existence of an element. For example:
164
+ Code:
165
+ ```py
166
+ if Text('Accept cookies?').exists():
167
+ click('I accept')
168
+ ```<end_code>
169
+
170
+ Proceed in several steps rather than trying to solve the task in one shot.
171
+ And at the end, only when you have your answer, return your final answer.
172
+ Code:
173
+ ```py
174
+ final_answer("YOUR_ANSWER_HERE")
175
+ ```<end_code>
176
+
177
+ If pages seem stuck on loading, you might have to wait, for instance `import time` and run `time.sleep(5.0)`. But don't overuse this!
178
+ To list elements on page, DO NOT try code-based element searches like 'contributors = find_all(S("ol > li"))': just look at the latest screenshot you have and read it visually, or use your tool search_item_ctrl_f.
179
+ Of course, you can act on buttons like a user would do when navigating.
180
+ After each code blob you write, you will be automatically provided with an updated screenshot of the browser and the current browser url.
181
+ But beware that the screenshot will only be taken at the end of the whole action, it won't see intermediate states.
182
+ Don't kill the browser.
183
+ When you have modals or cookie banners on screen, you should get rid of them before you can click anything else.
184
+ """
185
+
186
+
187
+ def main():
188
+ # Load environment variables
189
+ load_dotenv()
190
+
191
+ # Parse command line arguments
192
+ args = parse_arguments()
193
+
194
+ # Initialize the model based on the provided arguments
195
+ model = load_model(args.model_type, args.model_id)
196
+
197
+ global driver
198
+ driver = initialize_driver()
199
+ agent = initialize_agent(model)
200
+
201
+ # Run the agent with the provided prompt
202
+ agent.python_executor("from helium import *", agent.state)
203
+ agent.run(args.prompt + helium_instructions)
204
+
205
+
206
+ if __name__ == "__main__":
207
+ main()