{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "vSlRv-Eczy9L"
},
"source": [
"# Building Agents That Use Code\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",
"\n",
"\n",
"Alfred is planning a party at the Wayne family mansion and needs your help to ensure everything goes smoothly. To assist him, we'll apply what we've learned about how a multi-step `CodeAgent` operates.\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "fXCVEZC2z3Pf"
},
"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": 1,
"metadata": {
"id": "u8AXJMCnxm6C",
"outputId": "6eef2da9-2bc9-45cb-df9f-ba894a9aace6",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Collecting smolagents\n",
" Downloading smolagents-1.24.0-py3-none-any.whl.metadata (17 kB)\n",
"Collecting huggingface-hub<1.0.0,>=0.31.2 (from smolagents)\n",
" Downloading huggingface_hub-0.36.2-py3-none-any.whl.metadata (15 kB)\n",
"Requirement already satisfied: requests>=2.32.3 in /usr/local/lib/python3.12/dist-packages (from smolagents) (2.32.4)\n",
"Requirement already satisfied: rich>=13.9.4 in /usr/local/lib/python3.12/dist-packages (from smolagents) (13.9.4)\n",
"Requirement already satisfied: jinja2>=3.1.4 in /usr/local/lib/python3.12/dist-packages (from smolagents) (3.1.6)\n",
"Requirement already satisfied: pillow>=10.0.1 in /usr/local/lib/python3.12/dist-packages (from smolagents) (11.3.0)\n",
"Requirement already satisfied: python-dotenv in /usr/local/lib/python3.12/dist-packages (from smolagents) (1.2.2)\n",
"Requirement already satisfied: filelock in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<1.0.0,>=0.31.2->smolagents) (3.25.2)\n",
"Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<1.0.0,>=0.31.2->smolagents) (2025.3.0)\n",
"Requirement already satisfied: hf-xet<2.0.0,>=1.1.3 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<1.0.0,>=0.31.2->smolagents) (1.4.2)\n",
"Requirement already satisfied: packaging>=20.9 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<1.0.0,>=0.31.2->smolagents) (26.0)\n",
"Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<1.0.0,>=0.31.2->smolagents) (6.0.3)\n",
"Requirement already satisfied: tqdm>=4.42.1 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<1.0.0,>=0.31.2->smolagents) (4.67.3)\n",
"Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<1.0.0,>=0.31.2->smolagents) (4.15.0)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.12/dist-packages (from jinja2>=3.1.4->smolagents) (3.0.3)\n",
"Requirement already satisfied: charset_normalizer<4,>=2 in /usr/local/lib/python3.12/dist-packages (from requests>=2.32.3->smolagents) (3.4.6)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.12/dist-packages (from requests>=2.32.3->smolagents) (3.11)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.12/dist-packages (from requests>=2.32.3->smolagents) (2.5.0)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.12/dist-packages (from requests>=2.32.3->smolagents) (2026.2.25)\n",
"Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.12/dist-packages (from rich>=13.9.4->smolagents) (4.0.0)\n",
"Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.12/dist-packages (from rich>=13.9.4->smolagents) (2.19.2)\n",
"Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.12/dist-packages (from markdown-it-py>=2.2.0->rich>=13.9.4->smolagents) (0.1.2)\n",
"Downloading smolagents-1.24.0-py3-none-any.whl (155 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m155.7/155.7 kB\u001b[0m \u001b[31m4.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading huggingface_hub-0.36.2-py3-none-any.whl (566 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m566.4/566.4 kB\u001b[0m \u001b[31m20.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hInstalling collected packages: huggingface-hub, smolagents\n",
" Attempting uninstall: huggingface-hub\n",
" Found existing installation: huggingface_hub 1.7.1\n",
" Uninstalling huggingface_hub-1.7.1:\n",
" Successfully uninstalled huggingface_hub-1.7.1\n",
"\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n",
"transformers 5.0.0 requires huggingface-hub<2.0,>=1.3.0, but you have huggingface-hub 0.36.2 which is incompatible.\u001b[0m\u001b[31m\n",
"\u001b[0mSuccessfully installed huggingface-hub-0.36.2 smolagents-1.24.0\n"
]
}
],
"source": [
"!pip install smolagents -U"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "hcfn1TDmVqqg"
},
"source": [
"Let's also login to the Hugging Face Hub to have access to the Inference API."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 17,
"referenced_widgets": [
"16919d62fd534907b12e3e2dc9ad4c16",
"48e2b3e0d8c240a0b9af0d7ac335a735",
"2c75449d71ff43308175fa499e60f780",
"2d0f9c6cbad74f2895fe54c1a7b83248",
"19b79f6e24dd45eb8a8ac2848643f802",
"5b338bddadda4cac8fb0d1eba1c9a7ff",
"39d853faf09649219a6d344d2e80217c",
"44b39310dc5a47f188eb4f34c79f5a10",
"3bb76419b65d4e84857adffce1175247",
"9eec23a0db92459796123c66fdbbb311",
"16b304f91bcc4894b38ae39ef453c427",
"350c434650f447a58415df9c5347f62d",
"517efaa785ba49239830bb3bbfe28e3b",
"4f0a325524024b19a4b732507b7ff3a6",
"27c4fc5b03d24f3e808b4777a01fd119",
"6344e6fa3e314db3a7915057611d72c7",
"b9943dd889874ad5b7795c949eb22880",
"0019059228ed4f959f24d7cc6e277d0b",
"6101ddbdd75f429d931fc4550c7bb020",
"0034986bb3474086aa32ca6e9dfb93f2"
]
},
"id": "3TuJYDo2yGZP",
"outputId": "16432234-9d55-492d-8584-e8ce181b2d31"
},
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
"VBox(children=(HTML(value='
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Step 1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n", "\n" ] }, "metadata": {} }, { "output_type": "stream", "name": "stderr", "text": [ "/usr/local/lib/python3.12/dist-packages/huggingface_hub/utils/_auth.py:94: UserWarning: \n", "The secret `HF_TOKEN` does not exist in your Colab secrets.\n", "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", "You will be able to reuse this secret in all of your notebooks.\n", "Please note that authentication is recommended but still optional to access public models or datasets.\n", " warnings.warn(\n" ] }, { "output_type": "display_data", "data": { "text/plain": [ " ─ \u001b[1mExecuting parsed code:\u001b[0m ──────────────────────────────────────────────────────────────────────────────────────── \n", " \u001b[38;2;248;248;242;48;2;39;40;34msearch_results\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;248;248;242;48;2;39;40;34mweb_search\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;34mquery\u001b[0m\u001b[38;2;255;70;137;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;34mbest music recommendations for Wayne\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;34ms mansion party\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[48;2;39;40;34m \u001b[0m \n", " \u001b[38;2;248;248;242;48;2;39;40;34mprint\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;34msearch_results\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" ], "text/html": [ "
─ Executing parsed code: ──────────────────────────────────────────────────────────────────────────────────────── \n", " search_results = web_search(query=\"best music recommendations for Wayne's mansion party\") \n", " print(search_results) \n", " ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── \n", "\n" ] }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ "\u001b[1mExecution logs:\u001b[0m\n", "## Search Results\n", "\n", "[late nights in the wayne manor - YouTube Music](https://music.youtube.com/watch?v=oOdHCjj3jn4)\n", "these are songs that bruce wayne listens to while wandering the halls of the great wayne manor. find this playlist \n", "on my spotify: https://open.spotify.com/u...\n", "\n", "[Best Songs To Party: DJ's Ultimate Party Songs Playlist](https://top40weekly.com/best-songs-to-party/)\n", "Planning a celebration? Don't forget the music ! We've compiled the best songs to party that are sure to get \n", "everyone in the mood to dance and have a good time.\n", "\n", "[The 10 Best Party Music Playlist Ideas for Any Vibe in 2025](https://1021events.com/best-party-music-playlist/)\n", "Craft the ultimate soundtrack with our guide to the 10 best party music playlist ideas, from 80s throwbacks to \n", "current hits. Perfect for any event!\n", "\n", "[50 Songs on Every Event Planner's Playlist - \n", "Eventbrite](https://www.eventbrite.com/blog/event-planning-playlist-ds00/)\n", "Need help choosing the perfect event music ? Discover how to curate the right playlist with song suggestions from \n", "Eventbrite.\n", "\n", "[WAYNE soundtrack - playlist by Charlie Linskey | \n", "Spotify](https://open.spotify.com/playlist/5iVbp78KnovfXzpwSOgzDB)\n", " WAYNE soundtrack · Playlist · 46 songs · 8.4K likes Preview of Spotify Sign up to get unlimited songs and podcasts\n", "with occasional ads. No credit card needed.\n", "\n", "[104 Best Wedding Reception Songs to Dance to at Your \n", "Party](https://www.brides.com/most-requested-wedding-songs-of-all-time-4774512)\n", "Looking for the ultimate wedding reception playlist? We asked five experts to share 104 of the most requested \n", "wedding reception songs to get you and your guests out on the dance floor. Use their ...\n", "\n", "[10 Best Music Playlists for Parties to Ignite Your Night \n", "(2026)](https://www.playlistnames.org/best-music-playlists-for-parties/)\n", "Throwing a party and want to be that host—the one who keeps the dance floor packed and the good vibes flowing? \n", "You're in the right place. We've curated the 10 best music playlists for parties that cover every vibe, from \n", "high-energy EDM bangers to chill background beats perfect for cocktail hour. Did you know that 72% of party -goers \n", "say bad music is the top reason they leave early? Yikes ...\n", "\n", "[The Best Cocktail Hour Music For Your \n", "Wedding](https://www.theknot.com/content/should-you-have-cocktail-hour-music)\n", "When it comes to ensuring a fun and memorable wedding day for you and your guests, music is instrumental (see what \n", "we did there?). And while the focus may be on creating a playlist for your wedding reception and ceremony, don't \n", "forget about your cocktail hour music , which marks the midpoint of the big day.\n", "\n", "[The Ultimate Playlist to Get the Party Started](https://alekasgettogether.com/top-songs-for-any-party/)\n", "Discover the ultimate party playlist for 2025 with over 50 top songs to keep your guests dancing all night long.\n", "\n", "[Top 15 Walk-On Songs for Corporate Events in \n", "2025](https://rentforevent.com/blog/top-15-walk-on-songs-for-corporate-events-in-2025/)\n", "In this post, we listed 15 popular walk-on songs that you can consider for your next corporate gathering. See which\n", "beat or tempo creates the biggest entrance.\n", "\n", "Out: None\n" ], "text/html": [ "
Execution logs:\n",
"## Search Results\n",
"\n",
"[late nights in the wayne manor - YouTube Music](https://music.youtube.com/watch?v=oOdHCjj3jn4)\n",
"these are songs that bruce wayne listens to while wandering the halls of the great wayne manor. find this playlist \n",
"on my spotify: https://open.spotify.com/u...\n",
"\n",
"[Best Songs To Party: DJ's Ultimate Party Songs Playlist](https://top40weekly.com/best-songs-to-party/)\n",
"Planning a celebration? Don't forget the music ! We've compiled the best songs to party that are sure to get \n",
"everyone in the mood to dance and have a good time.\n",
"\n",
"[The 10 Best Party Music Playlist Ideas for Any Vibe in 2025](https://1021events.com/best-party-music-playlist/)\n",
"Craft the ultimate soundtrack with our guide to the 10 best party music playlist ideas, from 80s throwbacks to \n",
"current hits. Perfect for any event!\n",
"\n",
"[50 Songs on Every Event Planner's Playlist - \n",
"Eventbrite](https://www.eventbrite.com/blog/event-planning-playlist-ds00/)\n",
"Need help choosing the perfect event music ? Discover how to curate the right playlist with song suggestions from \n",
"Eventbrite.\n",
"\n",
"[WAYNE soundtrack - playlist by Charlie Linskey | \n",
"Spotify](https://open.spotify.com/playlist/5iVbp78KnovfXzpwSOgzDB)\n",
" WAYNE soundtrack · Playlist · 46 songs · 8.4K likes Preview of Spotify Sign up to get unlimited songs and podcasts\n",
"with occasional ads. No credit card needed.\n",
"\n",
"[104 Best Wedding Reception Songs to Dance to at Your \n",
"Party](https://www.brides.com/most-requested-wedding-songs-of-all-time-4774512)\n",
"Looking for the ultimate wedding reception playlist? We asked five experts to share 104 of the most requested \n",
"wedding reception songs to get you and your guests out on the dance floor. Use their ...\n",
"\n",
"[10 Best Music Playlists for Parties to Ignite Your Night \n",
"(2026)](https://www.playlistnames.org/best-music-playlists-for-parties/)\n",
"Throwing a party and want to be that host—the one who keeps the dance floor packed and the good vibes flowing? \n",
"You're in the right place. We've curated the 10 best music playlists for parties that cover every vibe, from \n",
"high-energy EDM bangers to chill background beats perfect for cocktail hour. Did you know that 72% of party -goers \n",
"say bad music is the top reason they leave early? Yikes ...\n",
"\n",
"[The Best Cocktail Hour Music For Your \n",
"Wedding](https://www.theknot.com/content/should-you-have-cocktail-hour-music)\n",
"When it comes to ensuring a fun and memorable wedding day for you and your guests, music is instrumental (see what \n",
"we did there?). And while the focus may be on creating a playlist for your wedding reception and ceremony, don't \n",
"forget about your cocktail hour music , which marks the midpoint of the big day.\n",
"\n",
"[The Ultimate Playlist to Get the Party Started](https://alekasgettogether.com/top-songs-for-any-party/)\n",
"Discover the ultimate party playlist for 2025 with over 50 top songs to keep your guests dancing all night long.\n",
"\n",
"[Top 15 Walk-On Songs for Corporate Events in \n",
"2025](https://rentforevent.com/blog/top-15-walk-on-songs-for-corporate-events-in-2025/)\n",
"In this post, we listed 15 popular walk-on songs that you can consider for your next corporate gathering. See which\n",
"beat or tempo creates the biggest entrance.\n",
"\n",
"Out: None\n",
"\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"\u001b[2m[Step 1: Duration 17.44 seconds| Input tokens: 2,093 | Output tokens: 2,106]\u001b[0m\n"
],
"text/html": [
"[Step 1: Duration 17.44 seconds| Input tokens: 2,093 | Output tokens: 2,106]\n",
"\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"\u001b[38;2;212;183;2m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ \u001b[0m\u001b[1;37mStep 2\u001b[0m\u001b[38;2;212;183;2m ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\n"
],
"text/html": [
"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Step 2 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n", "\n" ] }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ " ─ \u001b[1mExecuting parsed code:\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;230;219;116;48;2;39;40;34m\"\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34mThe best music recommendation for a party at Wayne\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;34ms mansion is the \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;34mWAYNE soundtrack\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;34m playlist \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \n", " \u001b[38;2;230;219;116;48;2;39;40;34mon Spotify by Charlie Linskey (46 songs, 8.4K likes), which features a curated selection of songs fitting for a\u001b[0m \n", " \u001b[38;2;230;219;116;48;2;39;40;34mhigh-society event.\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[48;2;39;40;34m \u001b[0m \n", " ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── \n" ], "text/html": [ "
─ Executing parsed code: ──────────────────────────────────────────────────────────────────────────────────────── \n", " final_answer(\"The best music recommendation for a party at Wayne's mansion is the 'WAYNE soundtrack' playlist \n", " on Spotify by Charlie Linskey (46 songs, 8.4K likes), which features a curated selection of songs fitting for a \n", " high-society event.\") \n", " ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── \n", "\n" ] }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [], "text/html": [ "\n" ] }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ "\u001b[1;38;2;212;183;2mFinal answer: The best music recommendation for a party at Wayne's mansion is the 'WAYNE soundtrack' playlist on \u001b[0m\n", "\u001b[1;38;2;212;183;2mSpotify by Charlie Linskey (46 songs, 8.4K likes), which features a curated selection of songs fitting for a \u001b[0m\n", "\u001b[1;38;2;212;183;2mhigh-society event.\u001b[0m\n" ], "text/html": [ "
Final answer: The best music recommendation for a party at Wayne's mansion is the 'WAYNE soundtrack' playlist on \n", "Spotify by Charlie Linskey (46 songs, 8.4K likes), which features a curated selection of songs fitting for a \n", "high-society event.\n", "\n" ] }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ "\u001b[2m[Step 2: Duration 15.24 seconds| Input tokens: 5,114 | Output tokens: 4,085]\u001b[0m\n" ], "text/html": [ "
[Step 2: Duration 15.24 seconds| Input tokens: 5,114 | Output tokens: 4,085]\n",
"\n"
]
},
"metadata": {}
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"\"The best music recommendation for a party at Wayne's mansion is the 'WAYNE soundtrack' playlist on Spotify by Charlie Linskey (46 songs, 8.4K likes), which features a curated selection of songs fitting for a high-society event.\""
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
}
},
"metadata": {},
"execution_count": 3
}
],
"source": [
"from smolagents import CodeAgent, WebSearchTool, InferenceClientModel\n",
"\n",
"agent = CodeAgent(tools=[WebSearchTool()], model=InferenceClientModel())\n",
"\n",
"agent.run(\"Search for the best music recommendations for a party at the Wayne's mansion.\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "waE-prPUVzrh"
},
"source": [
"When you run this example, the output will **display a trace of the workflow steps being executed**. It will also print the corresponding Python code with the message:\n",
"\n",
"```python\n",
" ─ Executing parsed code: ────────────────────────────────────────────────────────────────────────────────────────\n",
" results = web_search(query=\"best music for a Batman party\") \n",
" print(results) \n",
" ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────\n",
"```\n",
"\n",
"After a few steps, you'll see the generated playlist that Alfred can use for the party! 🎵"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "-d9XLJkfyiNQ"
},
"source": [
"## Using a Custom Tool to Prepare the Menu\n",
"\n",
"Now that we have selected a playlist, we need to organize the menu for the guests. Again, Alfred can take advantage of `smolagents` to do so. Here, we use the `@tool` decorator to define a custom function that acts as a tool. We'll cover tool creation in more detail later, so for now, we can simply run the code.\n",
"\n",
"As you can see in the example below, we will create a tool using `@tool` decorator and include it in the `tools` list."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 269
},
"id": "K2oN9pagyhFX",
"outputId": "6c04bf39-fd64-4acf-83a9-9a2f9a82cae0"
},
"outputs": [
{
"output_type": "display_data",
"data": {
"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[1mPrepare a formal menu for the party.\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 InferenceClientModel - Qwen/Qwen3-Next-80B-A3B-Thinking \u001b[0m\u001b[38;2;212;183;2m──────────────────────────────────────────────────────\u001b[0m\u001b[38;2;212;183;2m─╯\u001b[0m\n"
],
"text/html": [
"╭──────────────────────────────────────────────────── New run ────────────────────────────────────────────────────╮\n", "│ │\n", "│ Prepare a formal menu for the party. │\n", "│ │\n", "╰─ InferenceClientModel - Qwen/Qwen3-Next-80B-A3B-Thinking ───────────────────────────────────────────────────────╯\n", "\n" ] }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ "\u001b[38;2;212;183;2m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ \u001b[0m\u001b[1;37mStep 1\u001b[0m\u001b[38;2;212;183;2m ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\n" ], "text/html": [ "
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Step 1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n", "\n" ] }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ " ─ \u001b[1mExecuting parsed code:\u001b[0m ──────────────────────────────────────────────────────────────────────────────────────── \n", " \u001b[38;2;248;248;242;48;2;39;40;34mmenu\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;248;248;242;48;2;39;40;34msuggest_menu\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;34moccasion\u001b[0m\u001b[38;2;255;70;137;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;34mformal\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[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;34mmenu\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" ], "text/html": [ "
─ Executing parsed code: ──────────────────────────────────────────────────────────────────────────────────────── \n", " menu = suggest_menu(occasion=\"formal\") \n", " final_answer(menu) \n", " ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── \n", "\n" ] }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [], "text/html": [ "\n" ] }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ "\u001b[1;38;2;212;183;2mFinal answer: 3-course dinner with wine and dessert.\u001b[0m\n" ], "text/html": [ "
Final answer: 3-course dinner with wine and dessert.\n",
"\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"\u001b[2m[Step 1: Duration 3.12 seconds| Input tokens: 2,112 | Output tokens: 412]\u001b[0m\n"
],
"text/html": [
"[Step 1: Duration 3.12 seconds| Input tokens: 2,112 | Output tokens: 412]\n",
"\n"
]
},
"metadata": {}
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"'3-course dinner with wine and dessert.'"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
}
},
"metadata": {},
"execution_count": 4
}
],
"source": [
"from smolagents import CodeAgent, tool\n",
"\n",
"@tool\n",
"def suggest_menu(occasion: str) -> str:\n",
" \"\"\"\n",
" Suggests a menu based on the occasion.\n",
" Args:\n",
" occasion (str): The type of occasion for the party. Allowed values are:\n",
" - \"casual\": Menu for casual party.\n",
" - \"formal\": Menu for formal party.\n",
" - \"superhero\": Menu for superhero party.\n",
" - \"custom\": Custom menu.\n",
" \"\"\"\n",
" if occasion == \"casual\":\n",
" return \"Pizza, snacks, and drinks.\"\n",
" elif occasion == \"formal\":\n",
" return \"3-course dinner with wine and dessert.\"\n",
" elif occasion == \"superhero\":\n",
" return \"Buffet with high-energy and healthy food.\"\n",
" else:\n",
" return \"Custom menu for the butler.\"\n",
"\n",
"agent = CodeAgent(tools=[suggest_menu], model=InferenceClientModel())\n",
"\n",
"agent.run(\"Prepare a formal menu for the party.\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "QZmuYtGPWKfO"
},
"source": [
"The agent will run for a few steps until finding the answer.\n",
"\n",
"The menu is ready! 🥗"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "0jrMJssQy-xr"
},
"source": [
"## Using Python Imports Inside the Agent\n",
"\n",
"We have the playlist and menu ready, but we need to check one more crucial detail: preparation time!\n",
"\n",
"Alfred needs to calculate when everything would be ready if he started preparing now, in case they need assistance from other superheroes.\n",
"\n",
"`smolagents` specializes in agents that write and execute Python code snippets, offering sandboxed execution for security. It supports both open-source and proprietary language models, making it adaptable to various development environments.\n",
"\n",
"**Code execution has strict security measures** - imports outside a predefined safe list are blocked by default. However, you can authorize additional imports by passing them as strings in `additional_authorized_imports`.\n",
"For more details on secure code execution, see the official [guide](https://huggingface.co/docs/smolagents/tutorials/secure_code_execution).\n",
"\n",
"When creating the agent, we will use `additional_authorized_imports` to allow for importing the `datetime` module."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 385
},
"id": "_3-2KZMny-8z",
"outputId": "e1a55eae-4071-4567-b778-23bd2b836b90"
},
"outputs": [
{
"output_type": "display_data",
"data": {
"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[1mAlfred needs to prepare for the party. Here are the tasks:\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
"\u001b[38;2;212;183;2m│\u001b[0m \u001b[1m 1. Prepare the drinks - 30 minutes\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
"\u001b[38;2;212;183;2m│\u001b[0m \u001b[1m 2. Decorate the mansion - 60 minutes\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
"\u001b[38;2;212;183;2m│\u001b[0m \u001b[1m 3. Set up the menu - 45 minutes\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
"\u001b[38;2;212;183;2m│\u001b[0m \u001b[1m 3. Prepare the music and playlist - 45 minutes\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[1m If we start right now, at what time will the party be ready?\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 InferenceClientModel - Qwen/Qwen3-Next-80B-A3B-Thinking \u001b[0m\u001b[38;2;212;183;2m──────────────────────────────────────────────────────\u001b[0m\u001b[38;2;212;183;2m─╯\u001b[0m\n"
],
"text/html": [
"╭──────────────────────────────────────────────────── New run ────────────────────────────────────────────────────╮\n", "│ │\n", "│ Alfred needs to prepare for the party. Here are the tasks: │\n", "│ 1. Prepare the drinks - 30 minutes │\n", "│ 2. Decorate the mansion - 60 minutes │\n", "│ 3. Set up the menu - 45 minutes │\n", "│ 3. Prepare the music and playlist - 45 minutes │\n", "│ │\n", "│ If we start right now, at what time will the party be ready? │\n", "│ │\n", "╰─ InferenceClientModel - Qwen/Qwen3-Next-80B-A3B-Thinking ───────────────────────────────────────────────────────╯\n", "\n" ] }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ "\u001b[38;2;212;183;2m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ \u001b[0m\u001b[1;37mStep 1\u001b[0m\u001b[38;2;212;183;2m ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\n" ], "text/html": [ "
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Step 1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n", "\n" ] }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ " ─ \u001b[1mExecuting parsed code:\u001b[0m ──────────────────────────────────────────────────────────────────────────────────────── \n", " \u001b[38;2;248;248;242;48;2;39;40;34mtotal_minutes\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;174;129;255;48;2;39;40;34m30\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;174;129;255;48;2;39;40;34m60\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;174;129;255;48;2;39;40;34m45\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;174;129;255;48;2;39;40;34m45\u001b[0m\u001b[48;2;39;40;34m \u001b[0m \n", " \u001b[38;2;248;248;242;48;2;39;40;34mhours\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;248;248;242;48;2;39;40;34mtotal_minutes\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;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;174;129;255;48;2;39;40;34m60\u001b[0m\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;230;219;116;48;2;39;40;34mf\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;34m{\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mhours\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;34m hours\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[48;2;39;40;34m \u001b[0m \n", " ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── \n" ], "text/html": [ "
─ Executing parsed code: ──────────────────────────────────────────────────────────────────────────────────────── \n", " total_minutes = 30 + 60 + 45 + 45 \n", " hours = total_minutes // 60 \n", " final_answer(f\"{hours} hours\") \n", " ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── \n", "\n" ] }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [], "text/html": [ "\n" ] }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ "\u001b[1;38;2;212;183;2mFinal answer: 3 hours\u001b[0m\n" ], "text/html": [ "
Final answer: 3 hours\n",
"\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"\u001b[2m[Step 1: Duration 23.40 seconds| Input tokens: 2,111 | Output tokens: 4,372]\u001b[0m\n"
],
"text/html": [
"[Step 1: Duration 23.40 seconds| Input tokens: 2,111 | Output tokens: 4,372]\n",
"\n"
]
},
"metadata": {}
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"'3 hours'"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
}
},
"metadata": {},
"execution_count": 5
}
],
"source": [
"from smolagents import CodeAgent, InferenceClientModel\n",
"import numpy as np\n",
"import time\n",
"import datetime\n",
"\n",
"agent = CodeAgent(tools=[], model=InferenceClientModel(), additional_authorized_imports=['datetime'])\n",
"\n",
"agent.run(\n",
" \"\"\"\n",
" Alfred needs to prepare for the party. Here are the tasks:\n",
" 1. Prepare the drinks - 30 minutes\n",
" 2. Decorate the mansion - 60 minutes\n",
" 3. Set up the menu - 45 minutes\n",
" 3. Prepare the music and playlist - 45 minutes\n",
"\n",
" If we start right now, at what time will the party be ready?\n",
" \"\"\"\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "T7pLiWCcWSsU"
},
"source": [
"These examples are just the beginning of what you can do with code agents, and we're already starting to see their utility for preparing the party.\n",
"You can learn more about how to build code agents in the [smolagents documentation](https://huggingface.co/docs/smolagents).\n",
"\n",
"`smolagents` specializes in agents that write and execute Python code snippets, offering sandboxed execution for security. It supports both open-source and proprietary language models, making it adaptable to various development environments."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "9UK049QDQjsB"
},
"source": [
"## Sharing Our Custom Party Preparator Agent to the Hub\n",
"\n",
"Wouldn't it be **amazing to share our very own Alfred agent with the community**? By doing so, anyone can easily download and use the agent directly from the Hub, bringing the ultimate party planner of Gotham to their fingertips! Let's make it happen! 🎉\n",
"\n",
"The `smolagents` library makes this possible by allowing you to share a complete agent with the community and download others for immediate use. It's as simple as the following:\n"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1000
},
"id": "uQuWg8TDRYQD",
"outputId": "bff6fccc-f702-4cb3-a4c0-4b648479bd0e"
},
"outputs": [
{
"output_type": "display_data",
"data": {
"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[1mGive me best playlist for a party at the Wayne's mansion. The party idea is a 'villain masquerade' theme\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 InferenceClientModel - Qwen/Qwen3-Next-80B-A3B-Thinking \u001b[0m\u001b[38;2;212;183;2m──────────────────────────────────────────────────────\u001b[0m\u001b[38;2;212;183;2m─╯\u001b[0m\n"
],
"text/html": [
"╭──────────────────────────────────────────────────── New run ────────────────────────────────────────────────────╮\n", "│ │\n", "│ Give me best playlist for a party at the Wayne's mansion. The party idea is a 'villain masquerade' theme │\n", "│ │\n", "╰─ InferenceClientModel - Qwen/Qwen3-Next-80B-A3B-Thinking ───────────────────────────────────────────────────────╯\n", "\n" ] }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ "\u001b[38;2;212;183;2m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ \u001b[0m\u001b[1;37mStep 1\u001b[0m\u001b[38;2;212;183;2m ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\n" ], "text/html": [ "
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Step 1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n", "\n" ] }, "metadata": {} }, { "output_type": "display_data", "data": { "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;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;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;23mneed\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;23mfind\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;23mplaylist\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;23mfor\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;23mvillain\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;23mmasquerade\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;23mparty\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;23mat\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;23mWayne's\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;23mmansion.\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'll\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;23mstart\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;23mby\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;23msearching\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;23mfor\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;230;237;243;48;2;13;17;23m\"villain\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;23mmasquerade\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;23mparty\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;23mplaylist\"\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;23mget\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;23mrecommended\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;23msongs.\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;23m
\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
"\u001b[38;2;230;237;243;48;2;13;17;23msearch_results\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;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mweb_search(query=\"villain\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;23mmasquerade\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;23mparty\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;23mplaylist\")\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
"\u001b[38;2;230;237;243;48;2;13;17;23mprint(search_results)\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
"\u001b[48;2;13;17;23m \u001b[0m\n"
],
"text/html": [
"Output message of the LLM: ────────────────────────────────────────────────────────────────────────────────────────\n",
"Thought: I need to find a playlist for a villain masquerade party at Wayne's mansion. I'll start by searching for \n",
"\"villain masquerade party playlist\" to get recommended songs. \n",
" \n",
"<code> \n",
"search_results = web_search(query=\"villain masquerade party playlist\") \n",
"print(search_results) \n",
" \n",
"
\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
" ─ \u001b[1mExecuting parsed code:\u001b[0m ──────────────────────────────────────────────────────────────────────────────────────── \n",
" \u001b[38;2;248;248;242;48;2;39;40;34msearch_results\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;248;248;242;48;2;39;40;34mweb_search\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;34mquery\u001b[0m\u001b[38;2;255;70;137;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;34mvillain masquerade party playlist\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[48;2;39;40;34m \u001b[0m \n",
" \u001b[38;2;248;248;242;48;2;39;40;34mprint\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;34msearch_results\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"
],
"text/html": [
" ─ Executing parsed code: ──────────────────────────────────────────────────────────────────────────────────────── \n",
" search_results = web_search(query=\"villain masquerade party playlist\") \n",
" print(search_results) \n",
" ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── \n",
"
\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"\u001b[1mExecution logs:\u001b[0m\n",
"## Search Results\n",
"\n",
"[you're at a masquerade and unknowingly dancing with the \n",
"villain](https://open.spotify.com/playlist/4zxYvQs9gByjRhAn5ujSfQ)\n",
"you're at a masquerade and unknowingly dancing with the villain · Playlist · 89 songs · 10 likes\n",
"\n",
"[The Complete playlist for your next Masquerade \n",
"party](https://vivomasks.com/blogs/masquerade/the-complete-playlist-for-your-next-masquerade-party)\n",
"The Masquerade Waltz by Armenian composer Aram Khachaturian is a must-add on your masquerade party playlist . \n",
"Originally written to accompany a play, the Masquerade Suite written by Mikhail Lermontov. Once you hear this \n",
"music, you can already imagine the highs and lows of emotion that one may encounter while at a masquerade ball.\n",
"\n",
"[Masquerade ball playlist - YouTube \n",
"Music](https://music.youtube.com/playlist?list=PLY6joegkeG1R75YMvOwO6CjVJ1EZQDUJF)\n",
"Waltzing with your nemesis in a masquerade ball (dark royalty core playlist ) evyenia 24:22 You're in the Last \n",
"Romanov Royal Ball | a playlist ultravclet 57:06 the hero falling for the villain during a waltz dance (dark royal \n",
"core)\n",
"\n",
"[Masquerade Party Songs - YouTube](https://www.youtube.com/playlist?list=PL0msuI7SJDFfR1Y1j74MlwPfFRDYjQFjj)\n",
" Masquerade Party Songs by Jason Hill • Playlist • 40 videos • 31,497 views Play all 1 5:30\n",
"\n",
"[Villain Vibes & Antihero Energy - INDIEMONO](https://indiemono.com/playlist/villain-vibes-antihero-energy/)\n",
" Playlist Villain Vibes & Antihero Energy Curated by Love Bedroom Pop villainess energy. Activate your villain \n",
"mode, you're the villain and you need the perfect soundtrack. Start your villain era with this playlist full of \n",
"songs that make you feel like a badass.\n",
"\n",
"[Songs for Villains | Villain Music Playlist | Epidemic \n",
"Sound](https://www.epidemicsound.com/music/themes/horror-thriller/the-villain/)\n",
"Beware of the villain ! Suspenseful and dramatic music, created to soundtrack classic horror tales and on-screen \n",
"villains .\n",
"\n",
"[Villain Party Mix - playlist by DerangedOrange | \n",
"Spotify](https://open.spotify.com/playlist/1wMp0fyFWPGBpX3fIlWZzK)\n",
" Villain Party Mix · Playlist · 297 songs · 7 likes\n",
"\n",
"[Best villains Songs Lists for DJs: Your Complete contemporary Playlist \n",
"...](https://stagebibles.com/best-songs-for-villains/)\n",
"If you're looking for the best villains music or throwing a party , these are songs you'll want to include. We \n",
"rounded up the best villains songs to build the ultimate Playlist \n",
"\n",
"[Villain Mode Spotify - Playlist to Feel Like a Villain Spotify - Badass \n",
"...](https://www.redlist.com/playlist/spotify/19661)\n",
"entering my reputation era ⭐You can also find us with: villain mode spotify - songs that make you realize you're \n",
"the villain - pov you realize you're the villain - music for when you realize you're the villain - playlist to feel\n",
"like a villain - villain mode - badass villain vibes - songs that give villain vibes - villain mode playlist ...\n",
"\n",
"[Masquerade Party - DJMone - Serato DJ Playlists](https://serato.com/playlists/DJMone/masquerade-party)\n",
"Serato DJ, World Leading DJ and Music software. Serato provides award-winning DJ software used by the leading \n",
"touring and club DJs. Blend, mix and scratch your tracks with Serato DJ.\n",
"\n",
"Out: None\n"
],
"text/html": [
"Execution logs:\n",
"## Search Results\n",
"\n",
"[you're at a masquerade and unknowingly dancing with the \n",
"villain](https://open.spotify.com/playlist/4zxYvQs9gByjRhAn5ujSfQ)\n",
"you're at a masquerade and unknowingly dancing with the villain · Playlist · 89 songs · 10 likes\n",
"\n",
"[The Complete playlist for your next Masquerade \n",
"party](https://vivomasks.com/blogs/masquerade/the-complete-playlist-for-your-next-masquerade-party)\n",
"The Masquerade Waltz by Armenian composer Aram Khachaturian is a must-add on your masquerade party playlist . \n",
"Originally written to accompany a play, the Masquerade Suite written by Mikhail Lermontov. Once you hear this \n",
"music, you can already imagine the highs and lows of emotion that one may encounter while at a masquerade ball.\n",
"\n",
"[Masquerade ball playlist - YouTube \n",
"Music](https://music.youtube.com/playlist?list=PLY6joegkeG1R75YMvOwO6CjVJ1EZQDUJF)\n",
"Waltzing with your nemesis in a masquerade ball (dark royalty core playlist ) evyenia 24:22 You're in the Last \n",
"Romanov Royal Ball | a playlist ultravclet 57:06 the hero falling for the villain during a waltz dance (dark royal \n",
"core)\n",
"\n",
"[Masquerade Party Songs - YouTube](https://www.youtube.com/playlist?list=PL0msuI7SJDFfR1Y1j74MlwPfFRDYjQFjj)\n",
" Masquerade Party Songs by Jason Hill • Playlist • 40 videos • 31,497 views Play all 1 5:30\n",
"\n",
"[Villain Vibes & Antihero Energy - INDIEMONO](https://indiemono.com/playlist/villain-vibes-antihero-energy/)\n",
" Playlist Villain Vibes & Antihero Energy Curated by Love Bedroom Pop villainess energy. Activate your villain \n",
"mode, you're the villain and you need the perfect soundtrack. Start your villain era with this playlist full of \n",
"songs that make you feel like a badass.\n",
"\n",
"[Songs for Villains | Villain Music Playlist | Epidemic \n",
"Sound](https://www.epidemicsound.com/music/themes/horror-thriller/the-villain/)\n",
"Beware of the villain ! Suspenseful and dramatic music, created to soundtrack classic horror tales and on-screen \n",
"villains .\n",
"\n",
"[Villain Party Mix - playlist by DerangedOrange | \n",
"Spotify](https://open.spotify.com/playlist/1wMp0fyFWPGBpX3fIlWZzK)\n",
" Villain Party Mix · Playlist · 297 songs · 7 likes\n",
"\n",
"[Best villains Songs Lists for DJs: Your Complete contemporary Playlist \n",
"...](https://stagebibles.com/best-songs-for-villains/)\n",
"If you're looking for the best villains music or throwing a party , these are songs you'll want to include. We \n",
"rounded up the best villains songs to build the ultimate Playlist \n",
"\n",
"[Villain Mode Spotify - Playlist to Feel Like a Villain Spotify - Badass \n",
"...](https://www.redlist.com/playlist/spotify/19661)\n",
"entering my reputation era ⭐You can also find us with: villain mode spotify - songs that make you realize you're \n",
"the villain - pov you realize you're the villain - music for when you realize you're the villain - playlist to feel\n",
"like a villain - villain mode - badass villain vibes - songs that give villain vibes - villain mode playlist ...\n",
"\n",
"[Masquerade Party - DJMone - Serato DJ Playlists](https://serato.com/playlists/DJMone/masquerade-party)\n",
"Serato DJ, World Leading DJ and Music software. Serato provides award-winning DJ software used by the leading \n",
"touring and club DJs. Blend, mix and scratch your tracks with Serato DJ.\n",
"\n",
"Out: None\n",
"\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"\u001b[2m[Step 1: Duration 18.95 seconds| Input tokens: 2,312 | Output tokens: 2,710]\u001b[0m\n"
],
"text/html": [
"[Step 1: Duration 18.95 seconds| Input tokens: 2,312 | Output tokens: 2,710]\n",
"\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"\u001b[38;2;212;183;2m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ \u001b[0m\u001b[1;37mStep 2\u001b[0m\u001b[38;2;212;183;2m ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\n"
],
"text/html": [
"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Step 2 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n",
"
\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"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;23m\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
"\u001b[38;2;230;237;243;48;2;13;17;23mfinal_answer(\"The\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;23mbest\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;23mplaylist\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;23mfor\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;23mvillain\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;23mmasquerade\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;23mparty\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;23mat\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;23mWayne's\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;23mmansion\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;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;23m'Villain\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;23mParty\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;23mMix'\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;23mon\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;230;237;243;48;2;13;17;23mSpotify:\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;23mhttps://open.spotify.com/playlist/1wMp0fyFWPGBpX3fIlWZzK\")\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
"\u001b[48;2;13;17;23m \u001b[0m\n"
],
"text/html": [
"Output message of the LLM: ────────────────────────────────────────────────────────────────────────────────────────\n",
"<code> \n",
"final_answer(\"The best playlist for a villain masquerade party at Wayne's mansion is the 'Villain Party Mix' on \n",
"Spotify: https://open.spotify.com/playlist/1wMp0fyFWPGBpX3fIlWZzK\") \n",
" \n",
"
\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
" ─ \u001b[1mExecuting parsed code:\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;230;219;116;48;2;39;40;34m\"\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34mThe best playlist for a villain masquerade party at Wayne\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;34ms mansion is the \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;34mVillain Party Mix\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;34m on\u001b[0m \n",
" \u001b[38;2;230;219;116;48;2;39;40;34mSpotify: https://open.spotify.com/playlist/1wMp0fyFWPGBpX3fIlWZzK\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[48;2;39;40;34m \u001b[0m \n",
" ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── \n"
],
"text/html": [
" ─ Executing parsed code: ──────────────────────────────────────────────────────────────────────────────────────── \n",
" final_answer(\"The best playlist for a villain masquerade party at Wayne's mansion is the 'Villain Party Mix' on \n",
" Spotify: https://open.spotify.com/playlist/1wMp0fyFWPGBpX3fIlWZzK\") \n",
" ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── \n",
"
\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [],
"text/html": [
"\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"\u001b[1;38;2;212;183;2mFinal answer: The best playlist for a villain masquerade party at Wayne's mansion is the 'Villain Party Mix' on \u001b[0m\n",
"\u001b[1;38;2;212;183;2mSpotify: https://open.spotify.com/playlist/1wMp0fyFWPGBpX3fIlWZzK\u001b[0m\n"
],
"text/html": [
"Final answer: The best playlist for a villain masquerade party at Wayne's mansion is the 'Villain Party Mix' on \n",
"Spotify: https://open.spotify.com/playlist/1wMp0fyFWPGBpX3fIlWZzK\n",
"
\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"\u001b[2m[Step 2: Duration 26.68 seconds| Input tokens: 5,602 | Output tokens: 6,980]\u001b[0m\n"
],
"text/html": [
"[Step 2: Duration 26.68 seconds| Input tokens: 5,602 | Output tokens: 6,980]\n",
"\n"
]
},
"metadata": {}
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"\"The best playlist for a villain masquerade party at Wayne's mansion is the 'Villain Party Mix' on Spotify: https://open.spotify.com/playlist/1wMp0fyFWPGBpX3fIlWZzK\""
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
}
},
"metadata": {},
"execution_count": 10
}
],
"source": [
"from smolagents import CodeAgent, WebSearchTool, InferenceClientModel, VisitWebpageTool, FinalAnswerTool, Tool, tool\n",
"\n",
"@tool\n",
"def suggest_menu(occasion: str) -> str:\n",
" \"\"\"\n",
" Suggests a menu based on the occasion.\n",
" Args:\n",
" occasion: The type of occasion for the party.\n",
" \"\"\"\n",
" if occasion == \"casual\":\n",
" return \"Pizza, snacks, and drinks.\"\n",
" elif occasion == \"formal\":\n",
" return \"3-course dinner with wine and dessert.\"\n",
" elif occasion == \"superhero\":\n",
" return \"Buffet with high-energy and healthy food.\"\n",
" else:\n",
" return \"Custom menu for the butler.\"\n",
"\n",
"@tool\n",
"def catering_service_tool(query: str) -> str:\n",
" \"\"\"\n",
" This tool returns the highest-rated catering service in Gotham City.\n",
"\n",
" Args:\n",
" query: A search term for finding catering services.\n",
" \"\"\"\n",
" # Example list of catering services and their ratings\n",
" services = {\n",
" \"Gotham Catering Co.\": 4.9,\n",
" \"Wayne Manor Catering\": 4.8,\n",
" \"Gotham City Events\": 4.7,\n",
" }\n",
"\n",
" # Find the highest rated catering service (simulating search query filtering)\n",
" best_service = max(services, key=services.get)\n",
"\n",
" return best_service\n",
"\n",
"class SuperheroPartyThemeTool(Tool):\n",
" name = \"superhero_party_theme_generator\"\n",
" description = \"\"\"\n",
" This tool suggests creative superhero-themed party ideas based on a category.\n",
" It returns a unique party theme idea.\"\"\"\n",
"\n",
" inputs = {\n",
" \"category\": {\n",
" \"type\": \"string\",\n",
" \"description\": \"The type of superhero party (e.g., 'classic heroes', 'villain masquerade', 'futuristic gotham').\",\n",
" }\n",
" }\n",
"\n",
" output_type = \"string\"\n",
"\n",
" def forward(self, category: str):\n",
" themes = {\n",
" \"classic heroes\": \"Justice League Gala: Guests come dressed as their favorite DC heroes with themed cocktails like 'The Kryptonite Punch'.\",\n",
" \"villain masquerade\": \"Gotham Rogues' Ball: A mysterious masquerade where guests dress as classic Batman villains.\",\n",
" \"futuristic gotham\": \"Neo-Gotham Night: A cyberpunk-style party inspired by Batman Beyond, with neon decorations and futuristic gadgets.\"\n",
" }\n",
"\n",
" return themes.get(category.lower(), \"Themed party idea not found. Try 'classic heroes', 'villain masquerade', or 'futuristic gotham'.\")\n",
"\n",
"\n",
"# Alfred, the butler, preparing the menu for the party\n",
"agent = CodeAgent(\n",
" tools=[\n",
" WebSearchTool(),\n",
" VisitWebpageTool(),\n",
" suggest_menu,\n",
" catering_service_tool,\n",
" SuperheroPartyThemeTool()\n",
" ],\n",
" model=InferenceClientModel(),\n",
" max_steps=10,\n",
" verbosity_level=2\n",
")\n",
"\n",
"agent.run(\"Give me best playlist for a party at the Wayne's mansion. The party idea is a 'villain masquerade' theme\")"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"id": "kDskouXzRdIi",
"outputId": "edc48948-ad2e-468b-bd94-188debba82de",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 193,
"referenced_widgets": [
"06ad6969aeba418685d5bd7bae00468d",
"860252c79d244997856337750414808c",
"3a0ab3df6d604796b156b07a754ebd49",
"c32e844ec8be46a19d8aee01a8aa3177",
"e02736f833344bdcaf82141fa98b13ec",
"b7bd43b9231e4af6a9ed11864821b5bf",
"8e1f4a89aeb44cb5a68edf3966493307",
"1f64a67524ae4c72beba4dc4724a57b9",
"64e13e5b19c94d75851355821ddb201c",
"550cd91ee5604f2facc8841aa22b0ef8",
"14f11f51724549ac8b8a7e56182c6821"
]
}
},
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
"README.md: 0%| | 0.00/231 [00:00, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "06ad6969aeba418685d5bd7bae00468d"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"This agent has step_callbacks: they will be ignored by this method. 1\n"
],
"text/html": [
"This agent has step_callbacks: they will be ignored by this method. 1\n",
"\n"
]
},
"metadata": {}
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"CommitInfo(commit_url='https://huggingface.co/spaces/br1ttle/AlfredAgent/commit/df8274ce10714351e368ac20594c9afe62c38ba3', commit_message='Upload agent', commit_description='', oid='df8274ce10714351e368ac20594c9afe62c38ba3', pr_url=None, repo_url=RepoUrl('https://huggingface.co/spaces/br1ttle/AlfredAgent', endpoint='https://huggingface.co', repo_type='space', repo_id='br1ttle/AlfredAgent'), pr_revision=None, pr_num=None)"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
}
},
"metadata": {},
"execution_count": 7
}
],
"source": [
"agent.push_to_hub('br1ttle/AlfredAgent')"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "3iPLK1IQWguH"
},
"source": [
"To download the agent again, use the code below:"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 273,
"referenced_widgets": [
"32c3fdf136e8428891f98ba52ec69535",
"a6e189363f42470598d91ed4cb1c4c95",
"8e1b88a52d57412981ebdce8c0aeb194",
"a58bf5c78b61490ca3aed0afd482951b",
"8f11d5873bef461b8f8f1afac6a541c9",
"b2950bb25b4344b9a95d8337d5545a3f",
"3152c827b4594565add96c4a02b70913",
"463637c8496f4dd99233f64e6d74e78c",
"27c34ca0af0a4c869e84b320d6a29b98",
"452ac9113d2242f180845bef79704e99",
"4e2eb5816667442c9dcaadec79864501",
"5e5f20e7c5144c4bb4bd7b22e501fc35",
"dfa4750449b4411c9b9b50adb23083a4",
"a3be3c711f404793bd22880427d3e613",
"29b9e2584bd1478b94d2aa56fde091c8",
"56907f7f21c644b29d54bae0ca9638d3",
"cc6ee2b97ff0418a82aad2dbaf4f0206",
"ea9d875224af4f149f1b52689abd8e5a",
"5bec4ff358b048cbbeb6ad0f5f614c6f",
"03c7e3ebda7f49bfb31092b30058638e",
"2348981a3a6f4fbe939f489cf1efed87",
"c0230adbf1644d76baecc5f051b84ee7",
"b2638a76d4d94c3085e64792df69dd07",
"da67d3ebeca3422a822d09bc84be694b",
"6f2fd3236dab4a47a4b13cd22fb029a2",
"53bad98173ab47219ef15992aabc7090",
"e8b97214322a45a1b3d2de4eb314ac3d",
"3f0a0d6444544526b506cc6e0d39b84d",
"db512c4ada564f86af34826f6db890de",
"3cb1ce6d6d424a5593e3fc405042db82",
"64811ea0a6174ed7934990f8da8269f5",
"1d922f96879740a7a26ac61fc5cf431d",
"4687cc5989534e5c94679877b4dba835",
"5ac0706129c44b23bf85533d1cc657dc",
"8e29bfaf2e314cf3b8dead2249d6d2ce",
"0114b54ae9ed48218fdceb87296d1274",
"1520ea4c387c4ed989f120f1330efdf1",
"27f947153d5148f6b7dda98349896d4f",
"60bfbfd64f3c40aea14c185f4ebf85b9",
"5331a996f4f84af18dfe6054fa6d404d",
"ce73352b94ed4217a69abdd0fc7fc053",
"4fcc6ce6e7fc49a6bc627ca89437ec11",
"8bb06029f659487ebc5390e37c15df3e",
"f3c3c54c7a6a4431a412f91d08dd34ee",
"d7fe95fc49f9478db0a147201cd7672b",
"b0d3bb3ba09e4cff8ca331090f1e4fbb",
"8f0a651643024808aae3be16cba217e1",
"33cc20c6705d4c7083310c0a1b948d0a",
"76a503937d354f02b0c47a68ff39e6c4",
"da73632b1f024450ab0310045b7b47b5",
"3da09a4645d345f29a86b11d44f25096",
"a5e44d78c32d41ab87d204458a3147e5",
"6a5e150658254dea9256d8a5ca8d5851",
"4bcf48a7df6e4686991db786f61ece43",
"dab83b695533455cbf4aa9fa814eb4d8",
"fa7885ad0b5b4c518354b4098aeb7069",
"c8f9239b8f1e4ed99aea4b008f58f961",
"530644470dc04581827436e3f76ab1a4",
"ea3fb9c7285549388bcd93c13b6f9627",
"535cbaefa3004ffda47480bf19613c61",
"2339a535e0094a8baac7cbaad2ef5c31",
"9d448d811adf45688dc1a9c83dad4d64",
"bdc159561ecf4cdda0e545fe9d1a9794",
"093a2ee1379e44a79e63a27ef2979421",
"a563083270564e0d8c7f3d24569e9377",
"c3e324f63a404dab98fc22211fdac945",
"278ea026078b468d91cea71bd41369aa",
"fd4e05c604aa4158b41d5c999075c378",
"44130c39d66f4940b3a9c6efaa8cf172",
"fc3fc346c88e42e8a0fbf11d26e7462c",
"a1bd89dfbbb740bca13da65efff423f2",
"51d9fbf8bbe5495db70f12edb2197b39",
"4d8c0c2225e84f4f969047ae362f5c0f",
"ad55d9a055de4f14a1c433994e4e6836",
"1d1520f677b8432abadbf1e0005559a8",
"c3a50ce9fba94ba9a92f20caf51383ce",
"d6b3bbdea49e4f6b8f586806d7bc8a06",
"cc23d50f6f124237890d379b67752b0b",
"0936912bdf81485880ae9f5a303b6718",
"a2bff84e04644bb18dc490334833d3e3",
"a41d81f54a68416db4e11f5bc2c7f607",
"dfdf0dead1194ab09c4701fa67ca75c6",
"168cb80143db470c917f5b49750f0b15",
"6c2138f65d9f440ab018ac3a3084aa81",
"dfda7681d6e5478387b69826bedee235",
"adbcb002765346baafe87891d3f06b5d",
"be19f223012943dba1ceb22bc25db103",
"b9c32d2e1376456fa7306670dc2b9464"
]
},
"id": "WB4tMMGHReYI",
"outputId": "32dcbbaf-ad54-4304-f3ab-92e35c63e53c"
},
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
"Fetching 9 files: 0%| | 0/9 [00:00, ?it/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "32c3fdf136e8428891f98ba52ec69535"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
".gitattributes: 0.00B [00:00, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "5e5f20e7c5144c4bb4bd7b22e501fc35"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"requirements.txt: 0%| | 0.00/11.0 [00:00, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "b2638a76d4d94c3085e64792df69dd07"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"agent.json: 0.00B [00:00, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "5ac0706129c44b23bf85533d1cc657dc"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"app.py: 0%| | 0.00/826 [00:00, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "d7fe95fc49f9478db0a147201cd7672b"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"prompts.yaml: 0.00B [00:00, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "fa7885ad0b5b4c518354b4098aeb7069"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"README.md: 0%| | 0.00/258 [00:00, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "278ea026078b468d91cea71bd41369aa"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"final_answer.py: 0%| | 0.00/448 [00:00, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "cc23d50f6f124237890d379b67752b0b"
}
},
"metadata": {}
}
],
"source": [
"agent = CodeAgent(tools=[], model=InferenceClientModel())\n",
"alfred_agent = agent.from_hub('br1ttle/AlfredAgent', trust_remote_code=True)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1000
},
"id": "PTTBVyESRgF6",
"outputId": "833dfe95-39ed-4cbd-e070-9824da17dc6e"
},
"outputs": [
{
"output_type": "display_data",
"data": {
"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[1mGive me best playlist for a party at the Wayne's mansion. The party idea is a 'villain masquerade' theme\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 InferenceClientModel - Qwen/Qwen3-Next-80B-A3B-Thinking \u001b[0m\u001b[38;2;212;183;2m──────────────────────────────────────────────────────\u001b[0m\u001b[38;2;212;183;2m─╯\u001b[0m\n"
],
"text/html": [
"╭──────────────────────────────────────────────────── New run ────────────────────────────────────────────────────╮\n",
"│ │\n",
"│ Give me best playlist for a party at the Wayne's mansion. The party idea is a 'villain masquerade' theme │\n",
"│ │\n",
"╰─ InferenceClientModel - Qwen/Qwen3-Next-80B-A3B-Thinking ───────────────────────────────────────────────────────╯\n",
"
\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"\u001b[38;2;212;183;2m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ \u001b[0m\u001b[1;37mStep 1\u001b[0m\u001b[38;2;212;183;2m ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\n"
],
"text/html": [
"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Step 1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n",
"
\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"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;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;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;23mneed\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;23mfind\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;23mbest\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;23mplaylist\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;23mfor\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;23mvillain\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;23mmasquerade\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;23mparty\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;23mat\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;23mWayne's\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;23mmansion.\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'll\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;23mstart\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;23mby\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;230;237;243;48;2;13;17;23msearching\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;23mweb\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;23mfor\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\"villain\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;23mmasquerade\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;23mparty\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;23mplaylist\"\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;23mget\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;23mrelevant\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;23mresults.\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;23m\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
"\u001b[38;2;230;237;243;48;2;13;17;23msearch_results\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;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mweb_search(query=\"villain\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;23mmasquerade\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;23mparty\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;23mplaylist\")\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
"\u001b[38;2;230;237;243;48;2;13;17;23mprint(search_results)\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
"\u001b[48;2;13;17;23m \u001b[0m\n"
],
"text/html": [
"Output message of the LLM: ────────────────────────────────────────────────────────────────────────────────────────\n",
"Thought: I need to find the best playlist for a villain masquerade party at Wayne's mansion. I'll start by \n",
"searching the web for \"villain masquerade party playlist\" to get relevant results. \n",
" \n",
"<code> \n",
"search_results = web_search(query=\"villain masquerade party playlist\") \n",
"print(search_results) \n",
" \n",
"
\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
" ─ \u001b[1mExecuting parsed code:\u001b[0m ──────────────────────────────────────────────────────────────────────────────────────── \n",
" \u001b[38;2;248;248;242;48;2;39;40;34msearch_results\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;248;248;242;48;2;39;40;34mweb_search\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;34mquery\u001b[0m\u001b[38;2;255;70;137;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;34mvillain masquerade party playlist\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[48;2;39;40;34m \u001b[0m \n",
" \u001b[38;2;248;248;242;48;2;39;40;34mprint\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;34msearch_results\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"
],
"text/html": [
" ─ Executing parsed code: ──────────────────────────────────────────────────────────────────────────────────────── \n",
" search_results = web_search(query=\"villain masquerade party playlist\") \n",
" print(search_results) \n",
" ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── \n",
"
\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"\u001b[1mExecution logs:\u001b[0m\n",
"## Search Results\n",
"\n",
"[you're at a masquerade and unknowingly dancing with the \n",
"villain](https://open.spotify.com/playlist/4zxYvQs9gByjRhAn5ujSfQ)\n",
"you're at a masquerade and unknowingly dancing with the villain · Playlist · 89 songs · 10 likes\n",
"\n",
"[The Complete playlist for your next Masquerade \n",
"party](https://vivomasks.com/blogs/masquerade/the-complete-playlist-for-your-next-masquerade-party)\n",
"The Masquerade Waltz by Armenian composer Aram Khachaturian is a must-add on your masquerade party playlist . \n",
"Originally written to accompany a play, the Masquerade Suite written by Mikhail Lermontov. Once you hear this \n",
"music, you can already imagine the highs and lows of emotion that one may encounter while at a masquerade ball.\n",
"\n",
"[Masquerade ball playlist - YouTube \n",
"Music](https://music.youtube.com/playlist?list=PLY6joegkeG1R75YMvOwO6CjVJ1EZQDUJF)\n",
"Waltzing with your nemesis in a masquerade ball (dark royalty core playlist ) evyenia 24:22 You're in the Last \n",
"Romanov Royal Ball | a playlist ultravclet 57:06 the hero falling for the villain during a waltz dance (dark royal \n",
"core)\n",
"\n",
"[Masquerade Party Songs - YouTube](https://www.youtube.com/playlist?list=PL0msuI7SJDFfR1Y1j74MlwPfFRDYjQFjj)\n",
" Masquerade Party Songs by Jason Hill • Playlist • 40 videos • 31,497 views Play all 1 5:30\n",
"\n",
"[Villain Vibes & Antihero Energy - INDIEMONO](https://indiemono.com/playlist/villain-vibes-antihero-energy/)\n",
" Playlist Villain Vibes & Antihero Energy Curated by Love Bedroom Pop villainess energy. Activate your villain \n",
"mode, you're the villain and you need the perfect soundtrack. Start your villain era with this playlist full of \n",
"songs that make you feel like a badass.\n",
"\n",
"[The 99 Best Songs for Villains (Our Villain Arc Playlist) - \n",
"iSpyTunes](https://www.ispytunes.com/post/best-songs-for-villains)\n",
"Enter the captivating world of villain songs with our curated playlist of the 99 best songs for villains , where \n",
"darkness and power converge.\n",
"\n",
"[Villain Party Mix - playlist by DerangedOrange | \n",
"Spotify](https://open.spotify.com/playlist/1wMp0fyFWPGBpX3fIlWZzK)\n",
" Villain Party Mix · Playlist · 297 songs · 7 likes\n",
"\n",
"[Songs for Villains | Villain Music Playlist | Epidemic \n",
"Sound](https://www.epidemicsound.com/music/themes/horror-thriller/the-villain/)\n",
"Beware of the villain ! Suspenseful and dramatic music, created to soundtrack classic horror tales and on-screen \n",
"villains .\n",
"\n",
"[Villain Mode Spotify - Playlist to Feel Like a Villain Spotify - Badass \n",
"...](https://www.redlist.com/playlist/spotify/19661)\n",
"entering my reputation era ⭐You can also find us with: villain mode spotify - songs that make you realize you're \n",
"the villain - pov you realize you're the villain - music for when you realize you're the villain - playlist to feel\n",
"like a villain - villain mode - badass villain vibes - songs that give villain vibes - villain mode playlist ...\n",
"\n",
"[Best villains Songs Lists for DJs: Your Complete contemporary Playlist \n",
"...](https://stagebibles.com/best-songs-for-villains/)\n",
"If you're looking for the best villains music or throwing a party , these are songs you'll want to include. We \n",
"rounded up the best villains songs to build the ultimate Playlist \n",
"\n",
"Out: None\n"
],
"text/html": [
"Execution logs:\n",
"## Search Results\n",
"\n",
"[you're at a masquerade and unknowingly dancing with the \n",
"villain](https://open.spotify.com/playlist/4zxYvQs9gByjRhAn5ujSfQ)\n",
"you're at a masquerade and unknowingly dancing with the villain · Playlist · 89 songs · 10 likes\n",
"\n",
"[The Complete playlist for your next Masquerade \n",
"party](https://vivomasks.com/blogs/masquerade/the-complete-playlist-for-your-next-masquerade-party)\n",
"The Masquerade Waltz by Armenian composer Aram Khachaturian is a must-add on your masquerade party playlist . \n",
"Originally written to accompany a play, the Masquerade Suite written by Mikhail Lermontov. Once you hear this \n",
"music, you can already imagine the highs and lows of emotion that one may encounter while at a masquerade ball.\n",
"\n",
"[Masquerade ball playlist - YouTube \n",
"Music](https://music.youtube.com/playlist?list=PLY6joegkeG1R75YMvOwO6CjVJ1EZQDUJF)\n",
"Waltzing with your nemesis in a masquerade ball (dark royalty core playlist ) evyenia 24:22 You're in the Last \n",
"Romanov Royal Ball | a playlist ultravclet 57:06 the hero falling for the villain during a waltz dance (dark royal \n",
"core)\n",
"\n",
"[Masquerade Party Songs - YouTube](https://www.youtube.com/playlist?list=PL0msuI7SJDFfR1Y1j74MlwPfFRDYjQFjj)\n",
" Masquerade Party Songs by Jason Hill • Playlist • 40 videos • 31,497 views Play all 1 5:30\n",
"\n",
"[Villain Vibes & Antihero Energy - INDIEMONO](https://indiemono.com/playlist/villain-vibes-antihero-energy/)\n",
" Playlist Villain Vibes & Antihero Energy Curated by Love Bedroom Pop villainess energy. Activate your villain \n",
"mode, you're the villain and you need the perfect soundtrack. Start your villain era with this playlist full of \n",
"songs that make you feel like a badass.\n",
"\n",
"[The 99 Best Songs for Villains (Our Villain Arc Playlist) - \n",
"iSpyTunes](https://www.ispytunes.com/post/best-songs-for-villains)\n",
"Enter the captivating world of villain songs with our curated playlist of the 99 best songs for villains , where \n",
"darkness and power converge.\n",
"\n",
"[Villain Party Mix - playlist by DerangedOrange | \n",
"Spotify](https://open.spotify.com/playlist/1wMp0fyFWPGBpX3fIlWZzK)\n",
" Villain Party Mix · Playlist · 297 songs · 7 likes\n",
"\n",
"[Songs for Villains | Villain Music Playlist | Epidemic \n",
"Sound](https://www.epidemicsound.com/music/themes/horror-thriller/the-villain/)\n",
"Beware of the villain ! Suspenseful and dramatic music, created to soundtrack classic horror tales and on-screen \n",
"villains .\n",
"\n",
"[Villain Mode Spotify - Playlist to Feel Like a Villain Spotify - Badass \n",
"...](https://www.redlist.com/playlist/spotify/19661)\n",
"entering my reputation era ⭐You can also find us with: villain mode spotify - songs that make you realize you're \n",
"the villain - pov you realize you're the villain - music for when you realize you're the villain - playlist to feel\n",
"like a villain - villain mode - badass villain vibes - songs that give villain vibes - villain mode playlist ...\n",
"\n",
"[Best villains Songs Lists for DJs: Your Complete contemporary Playlist \n",
"...](https://stagebibles.com/best-songs-for-villains/)\n",
"If you're looking for the best villains music or throwing a party , these are songs you'll want to include. We \n",
"rounded up the best villains songs to build the ultimate Playlist \n",
"\n",
"Out: None\n",
"\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"\u001b[2m[Step 1: Duration 26.39 seconds| Input tokens: 2,312 | Output tokens: 4,705]\u001b[0m\n"
],
"text/html": [
"[Step 1: Duration 26.39 seconds| Input tokens: 2,312 | Output tokens: 4,705]\n",
"\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"\u001b[38;2;212;183;2m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ \u001b[0m\u001b[1;37mStep 2\u001b[0m\u001b[38;2;212;183;2m ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\n"
],
"text/html": [
"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Step 2 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n",
"
\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"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;23m\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
"\u001b[38;2;230;237;243;48;2;13;17;23mfinal_answer(\"Villain\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;23mVibes\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;23m \u001b[0m\u001b[38;2;230;237;243;48;2;13;17;23mAntihero\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;23mEnergy\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;23mby\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;23mINDIEMONO\")\u001b[0m\u001b[48;2;13;17;23m \u001b[0m\n",
"\u001b[48;2;13;17;23m \u001b[0m\n"
],
"text/html": [
"Output message of the LLM: ────────────────────────────────────────────────────────────────────────────────────────\n",
"<code> \n",
"final_answer(\"Villain Vibes & Antihero Energy by INDIEMONO\") \n",
" \n",
"
\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
" ─ \u001b[1mExecuting parsed code:\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;230;219;116;48;2;39;40;34m\"\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34mVillain Vibes & Antihero Energy by INDIEMONO\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[48;2;39;40;34m \u001b[0m \n",
" ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── \n"
],
"text/html": [
" ─ Executing parsed code: ──────────────────────────────────────────────────────────────────────────────────────── \n",
" final_answer(\"Villain Vibes & Antihero Energy by INDIEMONO\") \n",
" ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── \n",
"
\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [],
"text/html": [
"\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"\u001b[1;38;2;212;183;2mFinal answer: Villain Vibes & Antihero Energy by INDIEMONO\u001b[0m\n"
],
"text/html": [
"Final answer: Villain Vibes & Antihero Energy by INDIEMONO\n",
"\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"\u001b[2m[Step 2: Duration 23.72 seconds| Input tokens: 5,602 | Output tokens: 8,447]\u001b[0m\n"
],
"text/html": [
"[Step 2: Duration 23.72 seconds| Input tokens: 5,602 | Output tokens: 8,447]\n",
"\n"
]
},
"metadata": {}
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"'Villain Vibes & Antihero Energy by INDIEMONO'"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
}
},
"metadata": {},
"execution_count": 11
}
],
"source": [
"#alfred_agent.run(\"Give me best playlist for a party at the Wayne's mansion. The party idea is a 'villain masquerade' theme\")\n",
"agent.run(\"Give me best playlist for a party at the Wayne's mansion. The party idea is a 'villain masquerade' theme\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "qz-vwxu9Wobn"
},
"source": [
"What's also exciting is that shared agents are directly available as Hugging Face Spaces, allowing you to interact with them in real-time. You can explore other agents [here](https://huggingface.co/spaces/davidberenstein1957/smolagents-and-tools).\n",
"\n",
"For example, the _AlfredAgent_ is available [here](https://huggingface.co/spaces/sergiopaniego/AlfredAgent)."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "wxWcQqkYl1Pm"
},
"source": [
"### Inspecting Our Party Preparator Agent with OpenTelemetry and Langfuse 📡\n",
"\n",
"Full trace can be found [here](https://cloud.langfuse.com/project/cm7bq0abj025rad078ak3luwi/traces/995fc019255528e4f48cf6770b0ce27b?timestamp=2025-02-19T10%3A28%3A36.929Z).\n",
"\n",
"As Alfred fine-tunes the Party Preparator Agent, he's growing weary of debugging its runs. Agents, by nature, are unpredictable and difficult to inspect. But since he aims to build the ultimate Party Preparator Agent and deploy it in production, he needs robust traceability for future monitoring and analysis. \n",
"\n",
"Once again, `smolagents` comes to the rescue! It embraces the [OpenTelemetry](https://opentelemetry.io/) standard for instrumenting agent runs, allowing seamless inspection and logging. With the help of [Langfuse](https://langfuse.com/) and the `SmolagentsInstrumentor`, Alfred can easily track and analyze his agent’s behavior. \n",
"\n",
"Setting it up is straightforward! \n",
"\n",
"First, we need to install the necessary dependencies: "
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"id": "CTtNDFOMl3BM",
"outputId": "1df55b1a-c4f6-4de1-c6ad-b75292053138",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Requirement already satisfied: opentelemetry-sdk in /usr/local/lib/python3.12/dist-packages (1.38.0)\n",
"Collecting opentelemetry-exporter-otlp\n",
" Downloading opentelemetry_exporter_otlp-1.40.0-py3-none-any.whl.metadata (2.4 kB)\n",
"Collecting openinference-instrumentation-smolagents\n",
" Downloading openinference_instrumentation_smolagents-0.1.25-py3-none-any.whl.metadata (4.3 kB)\n",
"Requirement already satisfied: smolagents[telemetry] in /usr/local/lib/python3.12/dist-packages (1.24.0)\n",
"Requirement already satisfied: huggingface-hub<1.0.0,>=0.31.2 in /usr/local/lib/python3.12/dist-packages (from smolagents[telemetry]) (0.36.2)\n",
"Requirement already satisfied: requests>=2.32.3 in /usr/local/lib/python3.12/dist-packages (from smolagents[telemetry]) (2.32.4)\n",
"Requirement already satisfied: rich>=13.9.4 in /usr/local/lib/python3.12/dist-packages (from smolagents[telemetry]) (13.9.4)\n",
"Requirement already satisfied: jinja2>=3.1.4 in /usr/local/lib/python3.12/dist-packages (from smolagents[telemetry]) (3.1.6)\n",
"Requirement already satisfied: pillow>=10.0.1 in /usr/local/lib/python3.12/dist-packages (from smolagents[telemetry]) (11.3.0)\n",
"Requirement already satisfied: python-dotenv in /usr/local/lib/python3.12/dist-packages (from smolagents[telemetry]) (1.2.2)\n",
"Collecting arize-phoenix (from smolagents[telemetry])\n",
" Downloading arize_phoenix-13.22.0-py3-none-any.whl.metadata (38 kB)\n",
"Requirement already satisfied: opentelemetry-api==1.38.0 in /usr/local/lib/python3.12/dist-packages (from opentelemetry-sdk) (1.38.0)\n",
"Requirement already satisfied: opentelemetry-semantic-conventions==0.59b0 in /usr/local/lib/python3.12/dist-packages (from opentelemetry-sdk) (0.59b0)\n",
"Requirement already satisfied: typing-extensions>=4.5.0 in /usr/local/lib/python3.12/dist-packages (from opentelemetry-sdk) (4.15.0)\n",
"Requirement already satisfied: importlib-metadata<8.8.0,>=6.0 in /usr/local/lib/python3.12/dist-packages (from opentelemetry-api==1.38.0->opentelemetry-sdk) (8.7.1)\n",
"Collecting opentelemetry-exporter-otlp-proto-grpc==1.40.0 (from opentelemetry-exporter-otlp)\n",
" Downloading opentelemetry_exporter_otlp_proto_grpc-1.40.0-py3-none-any.whl.metadata (2.6 kB)\n",
"Collecting opentelemetry-exporter-otlp-proto-http==1.40.0 (from opentelemetry-exporter-otlp)\n",
" Downloading opentelemetry_exporter_otlp_proto_http-1.40.0-py3-none-any.whl.metadata (2.5 kB)\n",
"Requirement already satisfied: googleapis-common-protos~=1.57 in /usr/local/lib/python3.12/dist-packages (from opentelemetry-exporter-otlp-proto-grpc==1.40.0->opentelemetry-exporter-otlp) (1.73.0)\n",
"Requirement already satisfied: grpcio<2.0.0,>=1.63.2 in /usr/local/lib/python3.12/dist-packages (from opentelemetry-exporter-otlp-proto-grpc==1.40.0->opentelemetry-exporter-otlp) (1.78.0)\n",
"Collecting opentelemetry-exporter-otlp-proto-common==1.40.0 (from opentelemetry-exporter-otlp-proto-grpc==1.40.0->opentelemetry-exporter-otlp)\n",
" Downloading opentelemetry_exporter_otlp_proto_common-1.40.0-py3-none-any.whl.metadata (1.9 kB)\n",
"Collecting opentelemetry-proto==1.40.0 (from opentelemetry-exporter-otlp-proto-grpc==1.40.0->opentelemetry-exporter-otlp)\n",
" Downloading opentelemetry_proto-1.40.0-py3-none-any.whl.metadata (2.4 kB)\n",
"Collecting opentelemetry-sdk\n",
" Downloading opentelemetry_sdk-1.40.0-py3-none-any.whl.metadata (1.6 kB)\n",
"Requirement already satisfied: protobuf<7.0,>=5.0 in /usr/local/lib/python3.12/dist-packages (from opentelemetry-proto==1.40.0->opentelemetry-exporter-otlp-proto-grpc==1.40.0->opentelemetry-exporter-otlp) (5.29.6)\n",
"INFO: pip is looking at multiple versions of opentelemetry-sdk to determine which version is compatible with other requirements. This could take a while.\n",
"Collecting opentelemetry-exporter-otlp\n",
" Downloading opentelemetry_exporter_otlp-1.39.1-py3-none-any.whl.metadata (2.4 kB)\n",
"Collecting opentelemetry-exporter-otlp-proto-grpc==1.39.1 (from opentelemetry-exporter-otlp)\n",
" Downloading opentelemetry_exporter_otlp_proto_grpc-1.39.1-py3-none-any.whl.metadata (2.5 kB)\n",
"Collecting opentelemetry-exporter-otlp-proto-http==1.39.1 (from opentelemetry-exporter-otlp)\n",
" Downloading opentelemetry_exporter_otlp_proto_http-1.39.1-py3-none-any.whl.metadata (2.4 kB)\n",
"Collecting opentelemetry-exporter-otlp-proto-common==1.39.1 (from opentelemetry-exporter-otlp-proto-grpc==1.39.1->opentelemetry-exporter-otlp)\n",
" Downloading opentelemetry_exporter_otlp_proto_common-1.39.1-py3-none-any.whl.metadata (1.8 kB)\n",
"Collecting opentelemetry-proto==1.39.1 (from opentelemetry-exporter-otlp-proto-grpc==1.39.1->opentelemetry-exporter-otlp)\n",
" Downloading opentelemetry_proto-1.39.1-py3-none-any.whl.metadata (2.3 kB)\n",
"Collecting opentelemetry-sdk\n",
" Downloading opentelemetry_sdk-1.39.1-py3-none-any.whl.metadata (1.5 kB)\n",
"Collecting opentelemetry-exporter-otlp\n",
" Downloading opentelemetry_exporter_otlp-1.39.0-py3-none-any.whl.metadata (2.4 kB)\n",
"Collecting opentelemetry-exporter-otlp-proto-grpc==1.39.0 (from opentelemetry-exporter-otlp)\n",
" Downloading opentelemetry_exporter_otlp_proto_grpc-1.39.0-py3-none-any.whl.metadata (2.5 kB)\n",
"Collecting opentelemetry-exporter-otlp-proto-http==1.39.0 (from opentelemetry-exporter-otlp)\n",
" Downloading opentelemetry_exporter_otlp_proto_http-1.39.0-py3-none-any.whl.metadata (2.4 kB)\n",
"Collecting opentelemetry-exporter-otlp-proto-common==1.39.0 (from opentelemetry-exporter-otlp-proto-grpc==1.39.0->opentelemetry-exporter-otlp)\n",
" Downloading opentelemetry_exporter_otlp_proto_common-1.39.0-py3-none-any.whl.metadata (1.8 kB)\n",
"Collecting opentelemetry-proto==1.39.0 (from opentelemetry-exporter-otlp-proto-grpc==1.39.0->opentelemetry-exporter-otlp)\n",
" Downloading opentelemetry_proto-1.39.0-py3-none-any.whl.metadata (2.3 kB)\n",
"Collecting opentelemetry-sdk\n",
" Downloading opentelemetry_sdk-1.39.0-py3-none-any.whl.metadata (1.5 kB)\n",
"Collecting opentelemetry-exporter-otlp\n",
" Downloading opentelemetry_exporter_otlp-1.38.0-py3-none-any.whl.metadata (2.4 kB)\n",
"Collecting opentelemetry-exporter-otlp-proto-grpc==1.38.0 (from opentelemetry-exporter-otlp)\n",
" Downloading opentelemetry_exporter_otlp_proto_grpc-1.38.0-py3-none-any.whl.metadata (2.4 kB)\n",
"Requirement already satisfied: opentelemetry-exporter-otlp-proto-http==1.38.0 in /usr/local/lib/python3.12/dist-packages (from opentelemetry-exporter-otlp) (1.38.0)\n",
"Requirement already satisfied: opentelemetry-exporter-otlp-proto-common==1.38.0 in /usr/local/lib/python3.12/dist-packages (from opentelemetry-exporter-otlp-proto-grpc==1.38.0->opentelemetry-exporter-otlp) (1.38.0)\n",
"Requirement already satisfied: opentelemetry-proto==1.38.0 in /usr/local/lib/python3.12/dist-packages (from opentelemetry-exporter-otlp-proto-grpc==1.38.0->opentelemetry-exporter-otlp) (1.38.0)\n",
"Collecting openinference-instrumentation>=0.1.27 (from openinference-instrumentation-smolagents)\n",
" Downloading openinference_instrumentation-0.1.46-py3-none-any.whl.metadata (5.0 kB)\n",
"Collecting openinference-semantic-conventions>=0.1.17 (from openinference-instrumentation-smolagents)\n",
" Downloading openinference_semantic_conventions-0.1.28-py3-none-any.whl.metadata (1.3 kB)\n",
"Collecting opentelemetry-instrumentation (from openinference-instrumentation-smolagents)\n",
" Downloading opentelemetry_instrumentation-0.61b0-py3-none-any.whl.metadata (7.2 kB)\n",
"Requirement already satisfied: wrapt in /usr/local/lib/python3.12/dist-packages (from openinference-instrumentation-smolagents) (2.1.2)\n",
"Requirement already satisfied: filelock in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<1.0.0,>=0.31.2->smolagents[telemetry]) (3.25.2)\n",
"Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<1.0.0,>=0.31.2->smolagents[telemetry]) (2025.3.0)\n",
"Requirement already satisfied: hf-xet<2.0.0,>=1.1.3 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<1.0.0,>=0.31.2->smolagents[telemetry]) (1.4.2)\n",
"Requirement already satisfied: packaging>=20.9 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<1.0.0,>=0.31.2->smolagents[telemetry]) (26.0)\n",
"Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<1.0.0,>=0.31.2->smolagents[telemetry]) (6.0.3)\n",
"Requirement already satisfied: tqdm>=4.42.1 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<1.0.0,>=0.31.2->smolagents[telemetry]) (4.67.3)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.12/dist-packages (from jinja2>=3.1.4->smolagents[telemetry]) (3.0.3)\n",
"Collecting wrapt (from openinference-instrumentation-smolagents)\n",
" Downloading wrapt-1.17.3-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.metadata (6.4 kB)\n",
"Requirement already satisfied: charset_normalizer<4,>=2 in /usr/local/lib/python3.12/dist-packages (from requests>=2.32.3->smolagents[telemetry]) (3.4.6)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.12/dist-packages (from requests>=2.32.3->smolagents[telemetry]) (3.11)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.12/dist-packages (from requests>=2.32.3->smolagents[telemetry]) (2.5.0)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.12/dist-packages (from requests>=2.32.3->smolagents[telemetry]) (2026.2.25)\n",
"Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.12/dist-packages (from rich>=13.9.4->smolagents[telemetry]) (4.0.0)\n",
"Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.12/dist-packages (from rich>=13.9.4->smolagents[telemetry]) (2.19.2)\n",
"Collecting aioitertools (from arize-phoenix->smolagents[telemetry])\n",
" Downloading aioitertools-0.13.0-py3-none-any.whl.metadata (3.3 kB)\n",
"Requirement already satisfied: aiosqlite in /usr/local/lib/python3.12/dist-packages (from arize-phoenix->smolagents[telemetry]) (0.22.1)\n",
"Requirement already satisfied: alembic<2,>=1.3.0 in /usr/local/lib/python3.12/dist-packages (from arize-phoenix->smolagents[telemetry]) (1.18.4)\n",
"Collecting arize-phoenix-client>=2.1.0 (from arize-phoenix->smolagents[telemetry])\n",
" Downloading arize_phoenix_client-2.2.0-py3-none-any.whl.metadata (15 kB)\n",
"Collecting arize-phoenix-evals>=2.12.0 (from arize-phoenix->smolagents[telemetry])\n",
" Downloading arize_phoenix_evals-2.13.0-py3-none-any.whl.metadata (9.3 kB)\n",
"Collecting arize-phoenix-otel>=0.15.0 (from arize-phoenix->smolagents[telemetry])\n",
" Downloading arize_phoenix_otel-0.15.0-py3-none-any.whl.metadata (8.4 kB)\n",
"Requirement already satisfied: authlib in /usr/local/lib/python3.12/dist-packages (from arize-phoenix->smolagents[telemetry]) (1.6.9)\n",
"Requirement already satisfied: cachetools in /usr/local/lib/python3.12/dist-packages (from arize-phoenix->smolagents[telemetry]) (6.2.6)\n",
"Collecting email-validator (from arize-phoenix->smolagents[telemetry])\n",
" Downloading email_validator-2.3.0-py3-none-any.whl.metadata (26 kB)\n",
"Collecting fastapi>=0.135.2 (from arize-phoenix->smolagents[telemetry])\n",
" Downloading fastapi-0.135.2-py3-none-any.whl.metadata (28 kB)\n",
"Collecting graphql-core<3.4,>=3.3.0a0 (from arize-phoenix->smolagents[telemetry])\n",
" Downloading graphql_core-3.3.0a12-py3-none-any.whl.metadata (11 kB)\n",
"Requirement already satisfied: grpc-interceptor in /usr/local/lib/python3.12/dist-packages (from arize-phoenix->smolagents[telemetry]) (0.15.4)\n",
"Requirement already satisfied: httpx in /usr/local/lib/python3.12/dist-packages (from arize-phoenix->smolagents[telemetry]) (0.28.1)\n",
"Collecting jmespath (from arize-phoenix->smolagents[telemetry])\n",
" Downloading jmespath-1.1.0-py3-none-any.whl.metadata (7.6 kB)\n",
"Collecting jsonpath-ng (from arize-phoenix->smolagents[telemetry])\n",
" Downloading jsonpath_ng-1.8.0-py3-none-any.whl.metadata (18 kB)\n",
"Requirement already satisfied: jsonschema in /usr/local/lib/python3.12/dist-packages (from arize-phoenix->smolagents[telemetry]) (4.26.0)\n",
"Collecting ldap3 (from arize-phoenix->smolagents[telemetry])\n",
" Downloading ldap3-2.9.1-py2.py3-none-any.whl.metadata (5.4 kB)\n",
"Requirement already satisfied: numpy in /usr/local/lib/python3.12/dist-packages (from arize-phoenix->smolagents[telemetry]) (2.0.2)\n",
"Collecting openinference-instrumentation-openai>=0.1.41 (from arize-phoenix->smolagents[telemetry])\n",
" Downloading openinference_instrumentation_openai-0.1.43-py3-none-any.whl.metadata (4.8 kB)\n",
"Requirement already satisfied: orjson in /usr/local/lib/python3.12/dist-packages (from arize-phoenix->smolagents[telemetry]) (3.11.7)\n",
"Requirement already satisfied: pandas>=1.0 in /usr/local/lib/python3.12/dist-packages (from arize-phoenix->smolagents[telemetry]) (2.2.2)\n",
"Requirement already satisfied: prometheus-client in /usr/local/lib/python3.12/dist-packages (from arize-phoenix->smolagents[telemetry]) (0.24.1)\n",
"Requirement already satisfied: psutil in /usr/local/lib/python3.12/dist-packages (from arize-phoenix->smolagents[telemetry]) (5.9.5)\n",
"Requirement already satisfied: pyarrow in /usr/local/lib/python3.12/dist-packages (from arize-phoenix->smolagents[telemetry]) (18.1.0)\n",
"Requirement already satisfied: pydantic>=2.1.0 in /usr/local/lib/python3.12/dist-packages (from arize-phoenix->smolagents[telemetry]) (2.12.3)\n",
"Collecting pystache (from arize-phoenix->smolagents[telemetry])\n",
" Downloading pystache-0.6.8-py3-none-any.whl.metadata (14 kB)\n",
"Requirement already satisfied: python-dateutil in /usr/local/lib/python3.12/dist-packages (from arize-phoenix->smolagents[telemetry]) (2.9.0.post0)\n",
"Requirement already satisfied: python-multipart in /usr/local/lib/python3.12/dist-packages (from arize-phoenix->smolagents[telemetry]) (0.0.22)\n",
"Requirement already satisfied: scikit-learn in /usr/local/lib/python3.12/dist-packages (from arize-phoenix->smolagents[telemetry]) (1.6.1)\n",
"Requirement already satisfied: scipy in /usr/local/lib/python3.12/dist-packages (from arize-phoenix->smolagents[telemetry]) (1.16.3)\n",
"Requirement already satisfied: sqlalchemy<3,>=2.0.4 in /usr/local/lib/python3.12/dist-packages (from sqlalchemy[asyncio]<3,>=2.0.4->arize-phoenix->smolagents[telemetry]) (2.0.48)\n",
"Collecting sqlean-py>=3.45.1 (from arize-phoenix->smolagents[telemetry])\n",
" Downloading sqlean_py-3.50.4.5-cp312-cp312-manylinux_2_28_x86_64.whl.metadata (4.5 kB)\n",
"Requirement already satisfied: starlette>=0.37.0 in /usr/local/lib/python3.12/dist-packages (from arize-phoenix->smolagents[telemetry]) (0.52.1)\n",
"Collecting strawberry-graphql==0.287.3 (from arize-phoenix->smolagents[telemetry])\n",
" Downloading strawberry_graphql-0.287.3-py3-none-any.whl.metadata (7.6 kB)\n",
"Requirement already satisfied: uvicorn in /usr/local/lib/python3.12/dist-packages (from arize-phoenix->smolagents[telemetry]) (0.42.0)\n",
"Collecting lia-web>=0.2.1 (from strawberry-graphql==0.287.3->arize-phoenix->smolagents[telemetry])\n",
" Downloading lia_web-0.3.1-py3-none-any.whl.metadata (1.2 kB)\n",
"INFO: pip is looking at multiple versions of opentelemetry-instrumentation to determine which version is compatible with other requirements. This could take a while.\n",
"Collecting opentelemetry-instrumentation (from openinference-instrumentation-smolagents)\n",
" Downloading opentelemetry_instrumentation-0.60b1-py3-none-any.whl.metadata (7.2 kB)\n",
" Downloading opentelemetry_instrumentation-0.60b0-py3-none-any.whl.metadata (7.2 kB)\n",
" Downloading opentelemetry_instrumentation-0.59b0-py3-none-any.whl.metadata (7.1 kB)\n",
"Requirement already satisfied: Mako in /usr/local/lib/python3.12/dist-packages (from alembic<2,>=1.3.0->arize-phoenix->smolagents[telemetry]) (1.3.10)\n",
"Requirement already satisfied: typing-inspection>=0.4.2 in /usr/local/lib/python3.12/dist-packages (from fastapi>=0.135.2->arize-phoenix->smolagents[telemetry]) (0.4.2)\n",
"Requirement already satisfied: annotated-doc>=0.0.2 in /usr/local/lib/python3.12/dist-packages (from fastapi>=0.135.2->arize-phoenix->smolagents[telemetry]) (0.0.4)\n",
"Requirement already satisfied: zipp>=3.20 in /usr/local/lib/python3.12/dist-packages (from importlib-metadata<8.8.0,>=6.0->opentelemetry-api==1.38.0->opentelemetry-sdk) (3.23.0)\n",
"Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.12/dist-packages (from markdown-it-py>=2.2.0->rich>=13.9.4->smolagents[telemetry]) (0.1.2)\n",
"Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.12/dist-packages (from pandas>=1.0->arize-phoenix->smolagents[telemetry]) (2025.2)\n",
"Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.12/dist-packages (from pandas>=1.0->arize-phoenix->smolagents[telemetry]) (2025.3)\n",
"Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.12/dist-packages (from pydantic>=2.1.0->arize-phoenix->smolagents[telemetry]) (0.7.0)\n",
"Requirement already satisfied: pydantic-core==2.41.4 in /usr/local/lib/python3.12/dist-packages (from pydantic>=2.1.0->arize-phoenix->smolagents[telemetry]) (2.41.4)\n",
"Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.12/dist-packages (from python-dateutil->arize-phoenix->smolagents[telemetry]) (1.17.0)\n",
"Requirement already satisfied: greenlet>=1 in /usr/local/lib/python3.12/dist-packages (from sqlalchemy<3,>=2.0.4->sqlalchemy[asyncio]<3,>=2.0.4->arize-phoenix->smolagents[telemetry]) (3.3.2)\n",
"Requirement already satisfied: anyio<5,>=3.6.2 in /usr/local/lib/python3.12/dist-packages (from starlette>=0.37.0->arize-phoenix->smolagents[telemetry]) (4.12.1)\n",
"Requirement already satisfied: cryptography in /usr/local/lib/python3.12/dist-packages (from authlib->arize-phoenix->smolagents[telemetry]) (43.0.3)\n",
"Collecting dnspython>=2.0.0 (from email-validator->arize-phoenix->smolagents[telemetry])\n",
" Downloading dnspython-2.8.0-py3-none-any.whl.metadata (5.7 kB)\n",
"Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.12/dist-packages (from httpx->arize-phoenix->smolagents[telemetry]) (1.0.9)\n",
"Requirement already satisfied: h11>=0.16 in /usr/local/lib/python3.12/dist-packages (from httpcore==1.*->httpx->arize-phoenix->smolagents[telemetry]) (0.16.0)\n",
"Requirement already satisfied: attrs>=22.2.0 in /usr/local/lib/python3.12/dist-packages (from jsonschema->arize-phoenix->smolagents[telemetry]) (25.4.0)\n",
"Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /usr/local/lib/python3.12/dist-packages (from jsonschema->arize-phoenix->smolagents[telemetry]) (2025.9.1)\n",
"Requirement already satisfied: referencing>=0.28.4 in /usr/local/lib/python3.12/dist-packages (from jsonschema->arize-phoenix->smolagents[telemetry]) (0.37.0)\n",
"Requirement already satisfied: rpds-py>=0.25.0 in /usr/local/lib/python3.12/dist-packages (from jsonschema->arize-phoenix->smolagents[telemetry]) (0.30.0)\n",
"Requirement already satisfied: pyasn1>=0.4.6 in /usr/local/lib/python3.12/dist-packages (from ldap3->arize-phoenix->smolagents[telemetry]) (0.6.3)\n",
"Requirement already satisfied: joblib>=1.2.0 in /usr/local/lib/python3.12/dist-packages (from scikit-learn->arize-phoenix->smolagents[telemetry]) (1.5.3)\n",
"Requirement already satisfied: threadpoolctl>=3.1.0 in /usr/local/lib/python3.12/dist-packages (from scikit-learn->arize-phoenix->smolagents[telemetry]) (3.6.0)\n",
"Requirement already satisfied: click>=7.0 in /usr/local/lib/python3.12/dist-packages (from uvicorn->arize-phoenix->smolagents[telemetry]) (8.3.1)\n",
"Collecting cross-web>=0.3.0 (from lia-web>=0.2.1->strawberry-graphql==0.287.3->arize-phoenix->smolagents[telemetry])\n",
" Downloading cross_web-0.4.1-py3-none-any.whl.metadata (1.5 kB)\n",
"Requirement already satisfied: cffi>=1.12 in /usr/local/lib/python3.12/dist-packages (from cryptography->authlib->arize-phoenix->smolagents[telemetry]) (2.0.0)\n",
"Requirement already satisfied: pycparser in /usr/local/lib/python3.12/dist-packages (from cffi>=1.12->cryptography->authlib->arize-phoenix->smolagents[telemetry]) (3.0)\n",
"Downloading opentelemetry_exporter_otlp-1.38.0-py3-none-any.whl (7.0 kB)\n",
"Downloading opentelemetry_exporter_otlp_proto_grpc-1.38.0-py3-none-any.whl (19 kB)\n",
"Downloading openinference_instrumentation_smolagents-0.1.25-py3-none-any.whl (15 kB)\n",
"Downloading openinference_instrumentation-0.1.46-py3-none-any.whl (30 kB)\n",
"Downloading openinference_semantic_conventions-0.1.28-py3-none-any.whl (10 kB)\n",
"Downloading wrapt-1.17.3-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (88 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m88.0/88.0 kB\u001b[0m \u001b[31m3.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading arize_phoenix-13.22.0-py3-none-any.whl (4.9 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m4.9/4.9 MB\u001b[0m \u001b[31m61.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading strawberry_graphql-0.287.3-py3-none-any.whl (309 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m309.2/309.2 kB\u001b[0m \u001b[31m26.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading opentelemetry_instrumentation-0.59b0-py3-none-any.whl (33 kB)\n",
"Downloading arize_phoenix_client-2.2.0-py3-none-any.whl (159 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m159.7/159.7 kB\u001b[0m \u001b[31m14.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading arize_phoenix_evals-2.13.0-py3-none-any.whl (183 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m183.7/183.7 kB\u001b[0m \u001b[31m16.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading arize_phoenix_otel-0.15.0-py3-none-any.whl (17 kB)\n",
"Downloading fastapi-0.135.2-py3-none-any.whl (117 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m117.4/117.4 kB\u001b[0m \u001b[31m10.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading graphql_core-3.3.0a12-py3-none-any.whl (234 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m234.1/234.1 kB\u001b[0m \u001b[31m18.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading openinference_instrumentation_openai-0.1.43-py3-none-any.whl (30 kB)\n",
"Downloading sqlean_py-3.50.4.5-cp312-cp312-manylinux_2_28_x86_64.whl (3.1 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.1/3.1 MB\u001b[0m \u001b[31m81.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading aioitertools-0.13.0-py3-none-any.whl (24 kB)\n",
"Downloading email_validator-2.3.0-py3-none-any.whl (35 kB)\n",
"Downloading jmespath-1.1.0-py3-none-any.whl (20 kB)\n",
"Downloading jsonpath_ng-1.8.0-py3-none-any.whl (67 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m67.8/67.8 kB\u001b[0m \u001b[31m6.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading ldap3-2.9.1-py2.py3-none-any.whl (432 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m432.2/432.2 kB\u001b[0m \u001b[31m30.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading pystache-0.6.8-py3-none-any.whl (82 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m82.1/82.1 kB\u001b[0m \u001b[31m7.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading dnspython-2.8.0-py3-none-any.whl (331 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m331.1/331.1 kB\u001b[0m \u001b[31m26.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading lia_web-0.3.1-py3-none-any.whl (5.9 kB)\n",
"Downloading cross_web-0.4.1-py3-none-any.whl (14 kB)\n",
"Installing collected packages: jsonpath-ng, wrapt, sqlean-py, pystache, openinference-semantic-conventions, ldap3, jmespath, graphql-core, dnspython, cross-web, aioitertools, lia-web, email-validator, strawberry-graphql, fastapi, opentelemetry-instrumentation, opentelemetry-exporter-otlp-proto-grpc, openinference-instrumentation, opentelemetry-exporter-otlp, openinference-instrumentation-smolagents, openinference-instrumentation-openai, arize-phoenix-evals, arize-phoenix-otel, arize-phoenix-client, arize-phoenix\n",
" Attempting uninstall: wrapt\n",
" Found existing installation: wrapt 2.1.2\n",
" Uninstalling wrapt-2.1.2:\n",
" Successfully uninstalled wrapt-2.1.2\n",
" Attempting uninstall: fastapi\n",
" Found existing installation: fastapi 0.135.1\n",
" Uninstalling fastapi-0.135.1:\n",
" Successfully uninstalled fastapi-0.135.1\n",
"Successfully installed aioitertools-0.13.0 arize-phoenix-13.22.0 arize-phoenix-client-2.2.0 arize-phoenix-evals-2.13.0 arize-phoenix-otel-0.15.0 cross-web-0.4.1 dnspython-2.8.0 email-validator-2.3.0 fastapi-0.135.2 graphql-core-3.3.0a12 jmespath-1.1.0 jsonpath-ng-1.8.0 ldap3-2.9.1 lia-web-0.3.1 openinference-instrumentation-0.1.46 openinference-instrumentation-openai-0.1.43 openinference-instrumentation-smolagents-0.1.25 openinference-semantic-conventions-0.1.28 opentelemetry-exporter-otlp-1.38.0 opentelemetry-exporter-otlp-proto-grpc-1.38.0 opentelemetry-instrumentation-0.59b0 pystache-0.6.8 sqlean-py-3.50.4.5 strawberry-graphql-0.287.3 wrapt-1.17.3\n"
]
}
],
"source": [
"!pip install smolagents[telemetry] opentelemetry-sdk opentelemetry-exporter-otlp openinference-instrumentation-smolagents"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "IVBwrNgbXPS-"
},
"source": [
"Next, Alfred has already created an account on Langfuse and has his API keys ready. If you haven’t done so yet, you can sign up for Langfuse Cloud [here](https://cloud.langfuse.com/) or explore [alternatives](https://huggingface.co/docs/smolagents/tutorials/inspect_runs). \n",
"\n",
"Once you have your API keys, they need to be properly configured as follows:"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"id": "9mJfphSMnGwZ"
},
"outputs": [],
"source": [
"import os\n",
"import base64\n",
"from google.colab import userdata\n",
"\n",
"LANGFUSE_PUBLIC_KEY=userdata.get(\"LANGFUSE_PUBLIC_KEY\")\n",
"LANGFUSE_SECRET_KEY=userdata.get(\"LANGFUSE_SECRET_KEY\")\n",
"LANGFUSE_AUTH=base64.b64encode(f\"{LANGFUSE_PUBLIC_KEY}:{LANGFUSE_SECRET_KEY}\".encode()).decode()\n",
"\n",
"os.environ[\"OTEL_EXPORTER_OTLP_ENDPOINT\"] = \"https://cloud.langfuse.com/api/public/otel\" # EU data region\n",
"# os.environ[\"OTEL_EXPORTER_OTLP_ENDPOINT\"] = \"https://us.cloud.langfuse.com/api/public/otel\" # US data region\n",
"os.environ[\"OTEL_EXPORTER_OTLP_HEADERS\"] = f\"Authorization=Basic {LANGFUSE_AUTH}\""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ZIRRj-PJXRGH"
},
"source": [
"Finally, Alfred is ready to initialize the `SmolagentsInstrumentor` and start tracking his agent's performance. "
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"id": "kmQdrMK_nyU0"
},
"outputs": [],
"source": [
"from opentelemetry.sdk.trace import TracerProvider\n",
"\n",
"from openinference.instrumentation.smolagents import SmolagentsInstrumentor\n",
"from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter\n",
"from opentelemetry.sdk.trace.export import SimpleSpanProcessor\n",
"\n",
"trace_provider = TracerProvider()\n",
"trace_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter()))\n",
"\n",
"SmolagentsInstrumentor().instrument(tracer_provider=trace_provider)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "B0oLBr_qXSjA"
},
"source": [
"Alfred is now connected 🔌! The runs from `smolagents` are being logged in Langfuse, giving him full visibility into the agent's behavior. With this setup, he's ready to revisit previous runs and refine his Party Preparator Agent even further. "
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1000,
"referenced_widgets": [
"b569d24e129c4270bd71f9e224b688f9",
"66e577f3a8dc4c2bbf7fb2cecfbfefff",
"f5300fbc64e04614810b434e1a32ae11",
"b9c6be3d105d42ff811fd65a06f2d4df",
"0451ab53cc5b478c9ec9334a55b96bc5",
"a7198c7223af4cd894a47468bcd37869",
"b26d97e9488349609ccbcdcfa4c09786",
"1204b50ce7a946528b1642620a1f317c",
"242a22c17e4a4dffa924274526c593e6",
"7249fe72c5e94565abfc1a1d7bf41458",
"6bb234520a8243cf88043bebb2baa020"
]
},
"id": "3Oer9q0AoG28",
"outputId": "5912e7a7-63e7-4f1d-a745-1a00e9d7d2b2"
},
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
"Fetching 9 files: 0%| | 0/9 [00:00, ?it/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "b569d24e129c4270bd71f9e224b688f9"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"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[1mGive me best playlist for a party at the Wayne's mansion. The party idea is a 'villain masquerade' theme\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 InferenceClientModel - Qwen/Qwen3-Next-80B-A3B-Thinking \u001b[0m\u001b[38;2;212;183;2m──────────────────────────────────────────────────────\u001b[0m\u001b[38;2;212;183;2m─╯\u001b[0m\n"
],
"text/html": [
"╭──────────────────────────────────────────────────── New run ────────────────────────────────────────────────────╮\n",
"│ │\n",
"│ Give me best playlist for a party at the Wayne's mansion. The party idea is a 'villain masquerade' theme │\n",
"│ │\n",
"╰─ InferenceClientModel - Qwen/Qwen3-Next-80B-A3B-Thinking ───────────────────────────────────────────────────────╯\n",
"
\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"\u001b[38;2;212;183;2m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ \u001b[0m\u001b[1;37mStep 1\u001b[0m\u001b[38;2;212;183;2m ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\n"
],
"text/html": [
"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Step 1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n",
"
\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
" ─ \u001b[1mExecuting parsed code:\u001b[0m ──────────────────────────────────────────────────────────────────────────────────────── \n",
" \u001b[38;2;248;248;242;48;2;39;40;34mplaylist\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;248;248;242;48;2;39;40;34m[\u001b[0m\u001b[48;2;39;40;34m \u001b[0m \n",
" \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;34mSympathy for the Devil - The Rolling Stones\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[48;2;39;40;34m \u001b[0m \n",
" \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;34mBad Guy - Billie Eilish\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[48;2;39;40;34m \u001b[0m \n",
" \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;34mEvil - Interpol\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[48;2;39;40;34m \u001b[0m \n",
" \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 Phantom of the Opera - Andrew Lloyd Webber\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[48;2;39;40;34m \u001b[0m \n",
" \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;34mDon\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;34mt Stop Me Now - Queen\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[48;2;39;40;34m \u001b[0m \n",
" \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;34mPsycho - Muse\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[48;2;39;40;34m \u001b[0m \n",
" \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;34mBad to the Bone - George Thorogood\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[48;2;39;40;34m \u001b[0m \n",
" \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 - Steve Miller Band\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[48;2;39;40;34m \u001b[0m \n",
" \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;34mEnter Sandman - Metallica\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[48;2;39;40;34m \u001b[0m \n",
" \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;34mSweet Dreams (Are Made of This) - Eurythmics\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[48;2;39;40;34m \u001b[0m \n",
" \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;34mVillain - Skillet\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[48;2;39;40;34m \u001b[0m \n",
" \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;34mYou\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;34mre So Vain - Carly Simon\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[48;2;39;40;34m \u001b[0m \n",
" \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;34mGangsta\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;34ms Paradise - Coolio\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[48;2;39;40;34m \u001b[0m \n",
" \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 Devil Went Down to Georgia - Charlie Daniels Band\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[48;2;39;40;34m \u001b[0m \n",
" \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;34mO Fortuna - Carl Orff\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[48;2;39;40;34m \u001b[0m \n",
" \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;34mTime - Hans Zimmer (from Inception)\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[48;2;39;40;34m \u001b[0m \n",
" \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 Imperial March - John Williams (Star Wars)\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[48;2;39;40;34m \u001b[0m \n",
" \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;34mI\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;34mm Bad - LL Cool J\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[48;2;39;40;34m \u001b[0m \n",
" \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 Power of Love - Huey Lewis and the News (from Back to the Future)\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[48;2;39;40;34m \u001b[0m \n",
" \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;34mCrimson and Clover - Tommy James and the Shondells\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;248;248;242;48;2;39;40;34m]\u001b[0m\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;34mplaylist\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"
],
"text/html": [
" ─ Executing parsed code: ──────────────────────────────────────────────────────────────────────────────────────── \n",
" playlist = [ \n",
" \"Sympathy for the Devil - The Rolling Stones\", \n",
" \"Bad Guy - Billie Eilish\", \n",
" \"Evil - Interpol\", \n",
" \"The Phantom of the Opera - Andrew Lloyd Webber\", \n",
" \"Don't Stop Me Now - Queen\", \n",
" \"Psycho - Muse\", \n",
" \"Bad to the Bone - George Thorogood\", \n",
" \"The Joker - Steve Miller Band\", \n",
" \"Enter Sandman - Metallica\", \n",
" \"Sweet Dreams (Are Made of This) - Eurythmics\", \n",
" \"Villain - Skillet\", \n",
" \"You're So Vain - Carly Simon\", \n",
" \"Gangsta's Paradise - Coolio\", \n",
" \"The Devil Went Down to Georgia - Charlie Daniels Band\", \n",
" \"O Fortuna - Carl Orff\", \n",
" \"Time - Hans Zimmer (from Inception)\", \n",
" \"The Imperial March - John Williams (Star Wars)\", \n",
" \"I'm Bad - LL Cool J\", \n",
" \"The Power of Love - Huey Lewis and the News (from Back to the Future)\", \n",
" \"Crimson and Clover - Tommy James and the Shondells\" \n",
" ] \n",
" final_answer(playlist) \n",
" ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── \n",
"
\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [],
"text/html": [
"\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"\u001b[1;38;2;212;183;2mFinal answer: ['Sympathy for the Devil - The Rolling Stones', 'Bad Guy - Billie Eilish', 'Evil - Interpol', 'The \u001b[0m\n",
"\u001b[1;38;2;212;183;2mPhantom of the Opera - Andrew Lloyd Webber', \"Don't Stop Me Now - Queen\", 'Psycho - Muse', 'Bad to the Bone - \u001b[0m\n",
"\u001b[1;38;2;212;183;2mGeorge Thorogood', 'The Joker - Steve Miller Band', 'Enter Sandman - Metallica', 'Sweet Dreams (Are Made of This) -\u001b[0m\n",
"\u001b[1;38;2;212;183;2mEurythmics', 'Villain - Skillet', \"You're So Vain - Carly Simon\", \"Gangsta's Paradise - Coolio\", 'The Devil Went \u001b[0m\n",
"\u001b[1;38;2;212;183;2mDown to Georgia - Charlie Daniels Band', 'O Fortuna - Carl Orff', 'Time - Hans Zimmer (from Inception)', 'The \u001b[0m\n",
"\u001b[1;38;2;212;183;2mImperial March - John Williams (Star Wars)', \"I'm Bad - LL Cool J\", 'The Power of Love - Huey Lewis and the News \u001b[0m\n",
"\u001b[1;38;2;212;183;2m(from Back to the Future)', 'Crimson and Clover - Tommy James and the Shondells']\u001b[0m\n"
],
"text/html": [
"Final answer: ['Sympathy for the Devil - The Rolling Stones', 'Bad Guy - Billie Eilish', 'Evil - Interpol', 'The \n",
"Phantom of the Opera - Andrew Lloyd Webber', \"Don't Stop Me Now - Queen\", 'Psycho - Muse', 'Bad to the Bone - \n",
"George Thorogood', 'The Joker - Steve Miller Band', 'Enter Sandman - Metallica', 'Sweet Dreams (Are Made of This) -\n",
"Eurythmics', 'Villain - Skillet', \"You're So Vain - Carly Simon\", \"Gangsta's Paradise - Coolio\", 'The Devil Went \n",
"Down to Georgia - Charlie Daniels Band', 'O Fortuna - Carl Orff', 'Time - Hans Zimmer (from Inception)', 'The \n",
"Imperial March - John Williams (Star Wars)', \"I'm Bad - LL Cool J\", 'The Power of Love - Huey Lewis and the News \n",
"(from Back to the Future)', 'Crimson and Clover - Tommy James and the Shondells']\n",
"
\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"\u001b[2m[Step 1: Duration 25.40 seconds| Input tokens: 2,051 | Output tokens: 3,174]\u001b[0m\n"
],
"text/html": [
"[Step 1: Duration 25.40 seconds| Input tokens: 2,051 | Output tokens: 3,174]\n",
"\n"
]
},
"metadata": {}
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"['Sympathy for the Devil - The Rolling Stones',\n",
" 'Bad Guy - Billie Eilish',\n",
" 'Evil - Interpol',\n",
" 'The Phantom of the Opera - Andrew Lloyd Webber',\n",
" \"Don't Stop Me Now - Queen\",\n",
" 'Psycho - Muse',\n",
" 'Bad to the Bone - George Thorogood',\n",
" 'The Joker - Steve Miller Band',\n",
" 'Enter Sandman - Metallica',\n",
" 'Sweet Dreams (Are Made of This) - Eurythmics',\n",
" 'Villain - Skillet',\n",
" \"You're So Vain - Carly Simon\",\n",
" \"Gangsta's Paradise - Coolio\",\n",
" 'The Devil Went Down to Georgia - Charlie Daniels Band',\n",
" 'O Fortuna - Carl Orff',\n",
" 'Time - Hans Zimmer (from Inception)',\n",
" 'The Imperial March - John Williams (Star Wars)',\n",
" \"I'm Bad - LL Cool J\",\n",
" 'The Power of Love - Huey Lewis and the News (from Back to the Future)',\n",
" 'Crimson and Clover - Tommy James and the Shondells']"
]
},
"metadata": {},
"execution_count": 19
}
],
"source": [
"from smolagents import CodeAgent, InferenceClientModel\n",
"\n",
"agent = CodeAgent(tools=[], model=InferenceClientModel())\n",
"alfred_agent = agent.from_hub('br1ttle/AlfredAgent', trust_remote_code=True)\n",
"alfred_agent.run(\"Give me best playlist for a party at the Wayne's mansion. The party idea is a 'villain masquerade' theme\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "KBpqTBK1XVLz"
},
"source": [
"Alfred can now access this logs [here](https://cloud.langfuse.com/project/cm7bq0abj025rad078ak3luwi/traces/995fc019255528e4f48cf6770b0ce27b?timestamp=2025-02-19T10%3A28%3A36.929Z) to review and analyze them. \n",
"\n",
"Meanwhile, the [suggested playlist](https://open.spotify.com/playlist/0gZMMHjuxMrrybQ7wTMTpw) sets the perfect vibe for the party preparations. Cool, right? 🎶\n"
]
}
],
"metadata": {
"colab": {
"provenance": [],
"include_colab_link": true
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"16919d62fd534907b12e3e2dc9ad4c16": {
"model_module": "@jupyter-widgets/controls",
"model_name": "VBoxModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "VBoxModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "VBoxView",
"box_style": "",
"children": [],
"layout": "IPY_MODEL_39d853faf09649219a6d344d2e80217c"
}
},
"48e2b3e0d8c240a0b9af0d7ac335a735": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "HTMLModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "HTMLView",
"description": "",
"description_tooltip": null,
"layout": "IPY_MODEL_44b39310dc5a47f188eb4f34c79f5a10",
"placeholder": "",
"style": "IPY_MODEL_3bb76419b65d4e84857adffce1175247",
"value": "
Copy a token from your Hugging Face\ntokens page and paste it below.
Immediately click login after copying\nyour token or it might be stored in plain text in this notebook file. "
}
},
"2c75449d71ff43308175fa499e60f780": {
"model_module": "@jupyter-widgets/controls",
"model_name": "PasswordModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "PasswordModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "PasswordView",
"continuous_update": true,
"description": "Token:",
"description_tooltip": null,
"disabled": false,
"layout": "IPY_MODEL_9eec23a0db92459796123c66fdbbb311",
"placeholder": "",
"style": "IPY_MODEL_16b304f91bcc4894b38ae39ef453c427",
"value": ""
}
},
"2d0f9c6cbad74f2895fe54c1a7b83248": {
"model_module": "@jupyter-widgets/controls",
"model_name": "CheckboxModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "CheckboxModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "CheckboxView",
"description": "Add token as git credential?",
"description_tooltip": null,
"disabled": false,
"indent": true,
"layout": "IPY_MODEL_350c434650f447a58415df9c5347f62d",
"style": "IPY_MODEL_517efaa785ba49239830bb3bbfe28e3b",
"value": true
}
},
"19b79f6e24dd45eb8a8ac2848643f802": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ButtonModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "ButtonModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "ButtonView",
"button_style": "",
"description": "Login",
"disabled": false,
"icon": "",
"layout": "IPY_MODEL_4f0a325524024b19a4b732507b7ff3a6",
"style": "IPY_MODEL_27c4fc5b03d24f3e808b4777a01fd119",
"tooltip": ""
}
},
"5b338bddadda4cac8fb0d1eba1c9a7ff": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "HTMLModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "HTMLView",
"description": "",
"description_tooltip": null,
"layout": "IPY_MODEL_6344e6fa3e314db3a7915057611d72c7",
"placeholder": "",
"style": "IPY_MODEL_b9943dd889874ad5b7795c949eb22880",
"value": "\nPro Tip: If you don't already have one, you can create a dedicated\n'notebooks' token with 'write' access, that you can then easily reuse for all\nnotebooks.