update function tool suggest_menu prompt
#37
by
Ridhwan
- opened
unit2/smolagents/code_agents.ipynb
CHANGED
|
@@ -39,12 +39,12 @@
|
|
| 39 |
},
|
| 40 |
{
|
| 41 |
"cell_type": "markdown",
|
| 42 |
-
"source": [
|
| 43 |
-
"Let's also login to the Hugging Face Hub to have access to the Inference API."
|
| 44 |
-
],
|
| 45 |
"metadata": {
|
| 46 |
"id": "hcfn1TDmVqqg"
|
| 47 |
-
}
|
|
|
|
|
|
|
|
|
|
| 48 |
},
|
| 49 |
{
|
| 50 |
"cell_type": "code",
|
|
@@ -725,6 +725,9 @@
|
|
| 725 |
},
|
| 726 |
{
|
| 727 |
"cell_type": "markdown",
|
|
|
|
|
|
|
|
|
|
| 728 |
"source": [
|
| 729 |
"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",
|
| 730 |
"\n",
|
|
@@ -736,10 +739,7 @@
|
|
| 736 |
"```\n",
|
| 737 |
"\n",
|
| 738 |
"After a few steps, you'll see the generated playlist that Alfred can use for the party! 🎵"
|
| 739 |
-
]
|
| 740 |
-
"metadata": {
|
| 741 |
-
"id": "waE-prPUVzrh"
|
| 742 |
-
}
|
| 743 |
},
|
| 744 |
{
|
| 745 |
"cell_type": "markdown",
|
|
@@ -1021,7 +1021,7 @@
|
|
| 1021 |
" \"\"\"\n",
|
| 1022 |
" Suggests a menu based on the occasion.\n",
|
| 1023 |
" Args:\n",
|
| 1024 |
-
" occasion: The type of occasion for the party
|
| 1025 |
" \"\"\"\n",
|
| 1026 |
" if occasion == \"casual\":\n",
|
| 1027 |
" return \"Pizza, snacks, and drinks.\"\n",
|
|
@@ -1039,14 +1039,14 @@
|
|
| 1039 |
},
|
| 1040 |
{
|
| 1041 |
"cell_type": "markdown",
|
|
|
|
|
|
|
|
|
|
| 1042 |
"source": [
|
| 1043 |
"The agent will run for a few steps until finding the answer.\n",
|
| 1044 |
"\n",
|
| 1045 |
"The menu is ready! 🥗"
|
| 1046 |
-
]
|
| 1047 |
-
"metadata": {
|
| 1048 |
-
"id": "QZmuYtGPWKfO"
|
| 1049 |
-
}
|
| 1050 |
},
|
| 1051 |
{
|
| 1052 |
"cell_type": "markdown",
|
|
@@ -1590,15 +1590,15 @@
|
|
| 1590 |
},
|
| 1591 |
{
|
| 1592 |
"cell_type": "markdown",
|
|
|
|
|
|
|
|
|
|
| 1593 |
"source": [
|
| 1594 |
"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",
|
| 1595 |
"You can learn more about how to build code agents in the [smolagents documentation](https://huggingface.co/docs/smolagents).\n",
|
| 1596 |
"\n",
|
| 1597 |
"`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."
|
| 1598 |
-
]
|
| 1599 |
-
"metadata": {
|
| 1600 |
-
"id": "T7pLiWCcWSsU"
|
| 1601 |
-
}
|
| 1602 |
},
|
| 1603 |
{
|
| 1604 |
"cell_type": "markdown",
|
|
@@ -3555,12 +3555,12 @@
|
|
| 3555 |
},
|
| 3556 |
{
|
| 3557 |
"cell_type": "markdown",
|
| 3558 |
-
"source": [
|
| 3559 |
-
"To download the agent again, use the code below:"
|
| 3560 |
-
],
|
| 3561 |
"metadata": {
|
| 3562 |
"id": "3iPLK1IQWguH"
|
| 3563 |
-
}
|
|
|
|
|
|
|
|
|
|
| 3564 |
},
|
| 3565 |
{
|
| 3566 |
"cell_type": "code",
|
|
@@ -4539,14 +4539,14 @@
|
|
| 4539 |
},
|
| 4540 |
{
|
| 4541 |
"cell_type": "markdown",
|
|
|
|
|
|
|
|
|
|
| 4542 |
"source": [
|
| 4543 |
"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",
|
| 4544 |
"\n",
|
| 4545 |
"For example, the _AlfredAgent_ is available [here](https://huggingface.co/spaces/sergiopaniego/AlfredAgent)."
|
| 4546 |
-
]
|
| 4547 |
-
"metadata": {
|
| 4548 |
-
"id": "qz-vwxu9Wobn"
|
| 4549 |
-
}
|
| 4550 |
},
|
| 4551 |
{
|
| 4552 |
"cell_type": "markdown",
|
|
@@ -4580,14 +4580,14 @@
|
|
| 4580 |
},
|
| 4581 |
{
|
| 4582 |
"cell_type": "markdown",
|
|
|
|
|
|
|
|
|
|
| 4583 |
"source": [
|
| 4584 |
"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",
|
| 4585 |
"\n",
|
| 4586 |
"Once you have your API keys, they need to be properly configured as follows:"
|
| 4587 |
-
]
|
| 4588 |
-
"metadata": {
|
| 4589 |
-
"id": "IVBwrNgbXPS-"
|
| 4590 |
-
}
|
| 4591 |
},
|
| 4592 |
{
|
| 4593 |
"cell_type": "code",
|
|
@@ -4612,12 +4612,12 @@
|
|
| 4612 |
},
|
| 4613 |
{
|
| 4614 |
"cell_type": "markdown",
|
| 4615 |
-
"source": [
|
| 4616 |
-
"Finally, Alfred is ready to initialize the `SmolagentsInstrumentor` and start tracking his agent's performance. "
|
| 4617 |
-
],
|
| 4618 |
"metadata": {
|
| 4619 |
"id": "ZIRRj-PJXRGH"
|
| 4620 |
-
}
|
|
|
|
|
|
|
|
|
|
| 4621 |
},
|
| 4622 |
{
|
| 4623 |
"cell_type": "code",
|
|
@@ -4641,12 +4641,12 @@
|
|
| 4641 |
},
|
| 4642 |
{
|
| 4643 |
"cell_type": "markdown",
|
| 4644 |
-
"source": [
|
| 4645 |
-
"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. "
|
| 4646 |
-
],
|
| 4647 |
"metadata": {
|
| 4648 |
"id": "B0oLBr_qXSjA"
|
| 4649 |
-
}
|
|
|
|
|
|
|
|
|
|
| 4650 |
},
|
| 4651 |
{
|
| 4652 |
"cell_type": "code",
|
|
@@ -5212,14 +5212,14 @@
|
|
| 5212 |
},
|
| 5213 |
{
|
| 5214 |
"cell_type": "markdown",
|
|
|
|
|
|
|
|
|
|
| 5215 |
"source": [
|
| 5216 |
"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",
|
| 5217 |
"\n",
|
| 5218 |
"Meanwhile, the [suggested playlist](https://open.spotify.com/playlist/0gZMMHjuxMrrybQ7wTMTpw) sets the perfect vibe for the party preparations. Cool, right? 🎶\n"
|
| 5219 |
-
]
|
| 5220 |
-
"metadata": {
|
| 5221 |
-
"id": "KBpqTBK1XVLz"
|
| 5222 |
-
}
|
| 5223 |
}
|
| 5224 |
],
|
| 5225 |
"metadata": {
|
|
@@ -10631,4 +10631,4 @@
|
|
| 10631 |
},
|
| 10632 |
"nbformat": 4,
|
| 10633 |
"nbformat_minor": 0
|
| 10634 |
-
}
|
|
|
|
| 39 |
},
|
| 40 |
{
|
| 41 |
"cell_type": "markdown",
|
|
|
|
|
|
|
|
|
|
| 42 |
"metadata": {
|
| 43 |
"id": "hcfn1TDmVqqg"
|
| 44 |
+
},
|
| 45 |
+
"source": [
|
| 46 |
+
"Let's also login to the Hugging Face Hub to have access to the Inference API."
|
| 47 |
+
]
|
| 48 |
},
|
| 49 |
{
|
| 50 |
"cell_type": "code",
|
|
|
|
| 725 |
},
|
| 726 |
{
|
| 727 |
"cell_type": "markdown",
|
| 728 |
+
"metadata": {
|
| 729 |
+
"id": "waE-prPUVzrh"
|
| 730 |
+
},
|
| 731 |
"source": [
|
| 732 |
"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",
|
| 733 |
"\n",
|
|
|
|
| 739 |
"```\n",
|
| 740 |
"\n",
|
| 741 |
"After a few steps, you'll see the generated playlist that Alfred can use for the party! 🎵"
|
| 742 |
+
]
|
|
|
|
|
|
|
|
|
|
| 743 |
},
|
| 744 |
{
|
| 745 |
"cell_type": "markdown",
|
|
|
|
| 1021 |
" \"\"\"\n",
|
| 1022 |
" Suggests a menu based on the occasion.\n",
|
| 1023 |
" Args:\n",
|
| 1024 |
+
" occasion: The type of occasion for the party. enums: ['casual', 'formal', 'superhero', 'others']\n",
|
| 1025 |
" \"\"\"\n",
|
| 1026 |
" if occasion == \"casual\":\n",
|
| 1027 |
" return \"Pizza, snacks, and drinks.\"\n",
|
|
|
|
| 1039 |
},
|
| 1040 |
{
|
| 1041 |
"cell_type": "markdown",
|
| 1042 |
+
"metadata": {
|
| 1043 |
+
"id": "QZmuYtGPWKfO"
|
| 1044 |
+
},
|
| 1045 |
"source": [
|
| 1046 |
"The agent will run for a few steps until finding the answer.\n",
|
| 1047 |
"\n",
|
| 1048 |
"The menu is ready! 🥗"
|
| 1049 |
+
]
|
|
|
|
|
|
|
|
|
|
| 1050 |
},
|
| 1051 |
{
|
| 1052 |
"cell_type": "markdown",
|
|
|
|
| 1590 |
},
|
| 1591 |
{
|
| 1592 |
"cell_type": "markdown",
|
| 1593 |
+
"metadata": {
|
| 1594 |
+
"id": "T7pLiWCcWSsU"
|
| 1595 |
+
},
|
| 1596 |
"source": [
|
| 1597 |
"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",
|
| 1598 |
"You can learn more about how to build code agents in the [smolagents documentation](https://huggingface.co/docs/smolagents).\n",
|
| 1599 |
"\n",
|
| 1600 |
"`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."
|
| 1601 |
+
]
|
|
|
|
|
|
|
|
|
|
| 1602 |
},
|
| 1603 |
{
|
| 1604 |
"cell_type": "markdown",
|
|
|
|
| 3555 |
},
|
| 3556 |
{
|
| 3557 |
"cell_type": "markdown",
|
|
|
|
|
|
|
|
|
|
| 3558 |
"metadata": {
|
| 3559 |
"id": "3iPLK1IQWguH"
|
| 3560 |
+
},
|
| 3561 |
+
"source": [
|
| 3562 |
+
"To download the agent again, use the code below:"
|
| 3563 |
+
]
|
| 3564 |
},
|
| 3565 |
{
|
| 3566 |
"cell_type": "code",
|
|
|
|
| 4539 |
},
|
| 4540 |
{
|
| 4541 |
"cell_type": "markdown",
|
| 4542 |
+
"metadata": {
|
| 4543 |
+
"id": "qz-vwxu9Wobn"
|
| 4544 |
+
},
|
| 4545 |
"source": [
|
| 4546 |
"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",
|
| 4547 |
"\n",
|
| 4548 |
"For example, the _AlfredAgent_ is available [here](https://huggingface.co/spaces/sergiopaniego/AlfredAgent)."
|
| 4549 |
+
]
|
|
|
|
|
|
|
|
|
|
| 4550 |
},
|
| 4551 |
{
|
| 4552 |
"cell_type": "markdown",
|
|
|
|
| 4580 |
},
|
| 4581 |
{
|
| 4582 |
"cell_type": "markdown",
|
| 4583 |
+
"metadata": {
|
| 4584 |
+
"id": "IVBwrNgbXPS-"
|
| 4585 |
+
},
|
| 4586 |
"source": [
|
| 4587 |
"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",
|
| 4588 |
"\n",
|
| 4589 |
"Once you have your API keys, they need to be properly configured as follows:"
|
| 4590 |
+
]
|
|
|
|
|
|
|
|
|
|
| 4591 |
},
|
| 4592 |
{
|
| 4593 |
"cell_type": "code",
|
|
|
|
| 4612 |
},
|
| 4613 |
{
|
| 4614 |
"cell_type": "markdown",
|
|
|
|
|
|
|
|
|
|
| 4615 |
"metadata": {
|
| 4616 |
"id": "ZIRRj-PJXRGH"
|
| 4617 |
+
},
|
| 4618 |
+
"source": [
|
| 4619 |
+
"Finally, Alfred is ready to initialize the `SmolagentsInstrumentor` and start tracking his agent's performance. "
|
| 4620 |
+
]
|
| 4621 |
},
|
| 4622 |
{
|
| 4623 |
"cell_type": "code",
|
|
|
|
| 4641 |
},
|
| 4642 |
{
|
| 4643 |
"cell_type": "markdown",
|
|
|
|
|
|
|
|
|
|
| 4644 |
"metadata": {
|
| 4645 |
"id": "B0oLBr_qXSjA"
|
| 4646 |
+
},
|
| 4647 |
+
"source": [
|
| 4648 |
+
"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. "
|
| 4649 |
+
]
|
| 4650 |
},
|
| 4651 |
{
|
| 4652 |
"cell_type": "code",
|
|
|
|
| 5212 |
},
|
| 5213 |
{
|
| 5214 |
"cell_type": "markdown",
|
| 5215 |
+
"metadata": {
|
| 5216 |
+
"id": "KBpqTBK1XVLz"
|
| 5217 |
+
},
|
| 5218 |
"source": [
|
| 5219 |
"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",
|
| 5220 |
"\n",
|
| 5221 |
"Meanwhile, the [suggested playlist](https://open.spotify.com/playlist/0gZMMHjuxMrrybQ7wTMTpw) sets the perfect vibe for the party preparations. Cool, right? 🎶\n"
|
| 5222 |
+
]
|
|
|
|
|
|
|
|
|
|
| 5223 |
}
|
| 5224 |
],
|
| 5225 |
"metadata": {
|
|
|
|
| 10631 |
},
|
| 10632 |
"nbformat": 4,
|
| 10633 |
"nbformat_minor": 0
|
| 10634 |
+
}
|