File size: 72,662 Bytes
6487247 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 |
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "O7wvDb5Xq0ZH"
},
"source": [
"# Vision Agents with smolagents\n",
"\n",
"\n",
"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",
"\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "fqKoOdz8q6fF"
},
"source": [
"## Let's install the dependencies and login to our HF account to access the Inference API\n",
"\n",
"If you haven't installed `smolagents` yet, you can do so by running the following command:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "m_muGXjDRhTD"
},
"outputs": [],
"source": [
"!pip install smolagents"
]
},
{
"cell_type": "markdown",
"source": [
"Let's also login to the Hugging Face Hub to have access to the Inference API."
],
"metadata": {
"id": "WJGFjRbZbL50"
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "MnLNhxDzRiKh"
},
"outputs": [],
"source": [
"from huggingface_hub import notebook_login\n",
"\n",
"notebook_login()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "qOp72sO9q-TD"
},
"source": [
"## Providing Images at the Start of the Agent's Execution\n",
"\n",
"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",
"\n",
"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",
"\n",
"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",
"\n",
"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!"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "BI9E3okPR5wc"
},
"outputs": [],
"source": [
"from PIL import Image\n",
"import requests\n",
"from io import BytesIO\n",
"\n",
"image_urls = [\n",
" \"https://upload.wikimedia.org/wikipedia/commons/e/e8/The_Joker_at_Wax_Museum_Plus.jpg\",\n",
" \"https://upload.wikimedia.org/wikipedia/en/9/98/Joker_%28DC_Comics_character%29.jpg\"\n",
"]\n",
"\n",
"images = []\n",
"for url in image_urls:\n",
" response = requests.get(url)\n",
" image = Image.open(BytesIO(response.content)).convert(\"RGB\")\n",
" images.append(image)"
]
},
{
"cell_type": "markdown",
"source": [
"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)."
],
"metadata": {
"id": "vUBQjETkbRU6"
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "6HroQ3eIT-3m"
},
"outputs": [],
"source": [
"from google.colab import userdata\n",
"import os\n",
"os.environ[\"OPENAI_API_KEY\"] = userdata.get('OPENAI_API_KEY')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1000
},
"id": "A8qra0deRkUY",
"outputId": "2867daa1-e84e-4d02-ef10-eeeaf3ea863d"
},
"outputs": [
{
"data": {
"text/html": [
"<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",
"<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
"<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",
"<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",
"<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
"<span style=\"color: #d4b702; text-decoration-color: #d4b702\">╰─ OpenAIServerModel - gpt-4o ────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
"</pre>\n"
],
"text/plain": [
"\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",
"\u001b[38;2;212;183;2m│\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
"\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",
"\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",
"\u001b[38;2;212;183;2m│\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
"\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"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<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",
"</pre>\n"
],
"text/plain": [
"\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"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<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",
"<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",
"<span style=\"background-color: #0d1117\"> </span>\n",
"<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",
"<span style=\"background-color: #0d1117\"> </span>\n",
"<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",
"<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",
"<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",
"<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",
"<span style=\"background-color: #0d1117\"> </span>\n",
"<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",
"<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",
"<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",
"<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",
"<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",
"<span style=\"background-color: #0d1117\"> </span>\n",
"<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",
"</pre>\n"
],
"text/plain": [
"\u001b[1;3mOutput message of the LLM:\u001b[0m \u001b[38;2;212;183;2m────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n",
"\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",
"\u001b[48;2;13;17;23m \u001b[0m\n",
"\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",
"\u001b[48;2;13;17;23m \u001b[0m\n",
"\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",
"\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",
"\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",
"\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",
"\u001b[48;2;13;17;23m \u001b[0m\n",
"\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",
"\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",
"\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",
"\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",
"\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",
"\u001b[48;2;13;17;23m \u001b[0m\n",
"\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"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<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",
"<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",
"<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">Here is your code snippet:</span>\n",
"<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",
"\n",
"<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">The character in the photos you provided is wearing:</span>\n",
"\n",
"<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",
"<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> - A purple suit with a large bow tie in one image.</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> - A white flower lapel and card in another image.</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> - The style is flamboyant and colorful, typical of a comic villain.</span>\n",
"\n",
"<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",
"<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> - White face makeup covering the entire face.</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> - Red lips forming a wide, exaggerated smile.</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> - Dark makeup around the eyes.</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> - Green hair.</span>\n",
"\n",
"<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",
"<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">Make sure to include code with the correct pattern, for instance:</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">Thoughts: Your thoughts</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">Code:</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">```py</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"># Your python code here</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">```<end_code></span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">Make sure to provide correct code blobs.</span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[1;31mError in code parsing:\u001b[0m\n",
"\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",
"\u001b[1;31mHere is your code snippet:\u001b[0m\n",
"\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",
"\n",
"\u001b[1;31mThe character in the photos you provided is wearing:\u001b[0m\n",
"\n",
"\u001b[1;31m1\u001b[0m\u001b[1;31m. **Costume:**\u001b[0m\n",
"\u001b[1;31m - A purple suit with a large bow tie in one image.\u001b[0m\n",
"\u001b[1;31m - A white flower lapel and card in another image.\u001b[0m\n",
"\u001b[1;31m - The style is flamboyant and colorful, typical of a comic villain.\u001b[0m\n",
"\n",
"\u001b[1;31m2\u001b[0m\u001b[1;31m. **Makeup:**\u001b[0m\n",
"\u001b[1;31m - White face makeup covering the entire face.\u001b[0m\n",
"\u001b[1;31m - Red lips forming a wide, exaggerated smile.\u001b[0m\n",
"\u001b[1;31m - Dark makeup around the eyes.\u001b[0m\n",
"\u001b[1;31m - Green hair.\u001b[0m\n",
"\n",
"\u001b[1;31mFrom the description, this character resembles The Joker, a well-known comic book villain.\u001b[0m\n",
"\u001b[1;31mMake sure to include code with the correct pattern, for instance:\u001b[0m\n",
"\u001b[1;31mThoughts: Your thoughts\u001b[0m\n",
"\u001b[1;31mCode:\u001b[0m\n",
"\u001b[1;31m```py\u001b[0m\n",
"\u001b[1;31m# Your python code here\u001b[0m\n",
"\u001b[1;31m```\u001b[0m\u001b[1;31m<\u001b[0m\u001b[1;31mend_code\u001b[0m\u001b[1;31m>\u001b[0m\n",
"\u001b[1;31mMake sure to provide correct code blobs.\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<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",
"</pre>\n"
],
"text/plain": [
"\u001b[2m[Step 0: Duration 4.30 seconds| Input tokens: 3,004 | Output tokens: 139]\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<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",
"</pre>\n"
],
"text/plain": [
"\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"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<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",
"<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",
"<span style=\"background-color: #0d1117\"> </span>\n",
"<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",
"<span style=\"background-color: #0d1117\"> </span>\n",
"<span style=\"color: #e6edf3; text-decoration-color: #e6edf3; background-color: #0d1117\">Code:</span><span style=\"background-color: #0d1117\"> </span>\n",
"<span style=\"color: #a5d6ff; text-decoration-color: #a5d6ff; background-color: #0d1117\">```py</span><span style=\"background-color: #0d1117\"> </span>\n",
"<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",
"<span style=\"color: #a5d6ff; text-decoration-color: #a5d6ff; background-color: #0d1117\">1. Costume:</span><span style=\"background-color: #0d1117\"> </span>\n",
"<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",
"<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",
"<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",
"<span style=\"background-color: #0d1117\"> </span>\n",
"<span style=\"color: #a5d6ff; text-decoration-color: #a5d6ff; background-color: #0d1117\">2. Makeup:</span><span style=\"background-color: #0d1117\"> </span>\n",
"<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",
"<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",
"<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",
"<span style=\"color: #a5d6ff; text-decoration-color: #a5d6ff; background-color: #0d1117\"> - Slicked-back green hair.</span><span style=\"background-color: #0d1117\"> </span>\n",
"<span style=\"color: #a5d6ff; text-decoration-color: #a5d6ff; background-color: #0d1117\">\"\"\"</span><span style=\"background-color: #0d1117\"> </span>\n",
"<span style=\"background-color: #0d1117\"> </span>\n",
"<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",
"<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",
"<span style=\"background-color: #0d1117\"> </span>\n",
"<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",
"<span style=\"color: #a5d6ff; text-decoration-color: #a5d6ff; background-color: #0d1117\">```</span><span style=\"background-color: #0d1117\"> </span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[1;3mOutput message of the LLM:\u001b[0m \u001b[38;2;212;183;2m────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n",
"\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",
"\u001b[48;2;13;17;23m \u001b[0m\n",
"\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",
"\u001b[48;2;13;17;23m \u001b[0m\n",
"\u001b[38;2;230;237;243;48;2;13;17;23mCode:\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
"\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",
"\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",
"\u001b[38;2;165;214;255;48;2;13;17;23m1. Costume:\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
"\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",
"\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",
"\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",
"\u001b[48;2;13;17;23m \u001b[0m\n",
"\u001b[38;2;165;214;255;48;2;13;17;23m2. Makeup:\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
"\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",
"\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",
"\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",
"\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",
"\u001b[38;2;165;214;255;48;2;13;17;23m\"\"\"\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
"\u001b[48;2;13;17;23m \u001b[0m\n",
"\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",
"\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",
"\u001b[48;2;13;17;23m \u001b[0m\n",
"\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",
"\u001b[38;2;165;214;255;48;2;13;17;23m```\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<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",
" <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",
" <span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\">1. Costume:</span><span style=\"background-color: #272822\"> </span> \n",
" <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",
" <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",
" <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",
" <span style=\"background-color: #272822\"> </span> \n",
" <span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\">2. Makeup:</span><span style=\"background-color: #272822\"> </span> \n",
" <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",
" <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",
" <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",
" <span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\"> - Slicked-back green hair.</span><span style=\"background-color: #272822\"> </span> \n",
" <span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\">\"\"\"</span><span style=\"background-color: #272822\"> </span> \n",
" <span style=\"background-color: #272822\"> </span> \n",
" <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",
" <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",
" <span style=\"background-color: #272822\"> </span> \n",
" <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",
" ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── \n",
"</pre>\n"
],
"text/plain": [
" ─ \u001b[1mExecuting parsed code:\u001b[0m ──────────────────────────────────────────────────────────────────────────────────────── \n",
" \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",
" \u001b[38;2;230;219;116;48;2;39;40;34m1. Costume:\u001b[0m\u001b[48;2;39;40;34m \u001b[0m \n",
" \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",
" \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",
" \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",
" \u001b[48;2;39;40;34m \u001b[0m \n",
" \u001b[38;2;230;219;116;48;2;39;40;34m2. Makeup:\u001b[0m\u001b[48;2;39;40;34m \u001b[0m \n",
" \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",
" \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",
" \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",
" \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",
" \u001b[38;2;230;219;116;48;2;39;40;34m\"\"\"\u001b[0m\u001b[48;2;39;40;34m \u001b[0m \n",
" \u001b[48;2;39;40;34m \u001b[0m \n",
" \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",
" \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",
" \u001b[48;2;39;40;34m \u001b[0m \n",
" \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",
" ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── \n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<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",
"<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",
"<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",
"<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",
"<span style=\"color: #d4b702; text-decoration-color: #d4b702; font-weight: bold\">'character': 'The Joker'}</span>\n",
"</pre>\n"
],
"text/plain": [
"\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",
"\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",
"\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",
"\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",
"\u001b[1;38;2;212;183;2m'character': 'The Joker'}\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<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",
"</pre>\n"
],
"text/plain": [
"\u001b[2m[Step 1: Duration 7.36 seconds| Input tokens: 7,431 | Output tokens: 302]\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from smolagents import CodeAgent, OpenAIServerModel\n",
"\n",
"model = OpenAIServerModel(model_id=\"gpt-4o\")\n",
"\n",
"# Instantiate the agent\n",
"agent = CodeAgent(\n",
" tools=[],\n",
" model=model,\n",
" max_steps=20,\n",
" verbosity_level=2\n",
")\n",
"\n",
"response = agent.run(\n",
" \"\"\"\n",
" Describe the costume and makeup that the comic character in these photos is wearing and return the description.\n",
" Tell me if the guest is The Joker or Wonder Woman.\n",
" \"\"\",\n",
" images=images\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "uvKj37AmeIu0",
"outputId": "ed7984d4-f6a2-4062-9939-41cb2e97b3b2"
},
"outputs": [
{
"data": {
"text/plain": [
"{'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",
" 'character': 'The Joker'}"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"response"
]
},
{
"cell_type": "markdown",
"source": [
"In this case, the output reveals that the person is impersonating someone else, so we can prevent The Joker from entering the party!"
],
"metadata": {
"id": "NrV-yK5zbT9r"
}
},
{
"cell_type": "markdown",
"metadata": {
"id": "ziyfk-3ZrHw5"
},
"source": [
"## Providing Images with Dynamic Retrieval\n",
"\n",
"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."
]
}
],
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
} |