浏览代码

Update tool calling nbs to 3.3 (#888)

Igor Kasianenko 1 月之前
父节点
当前提交
3c4cc8d670

+ 424 - 64
end-to-end-use-cases/agents/Agents_Tutorial/Tool_Calling_101.ipynb

@@ -6,17 +6,23 @@
    "source": [
     "# Tool Calling 101:\n",
     "\n",
-    "Note: If you are looking for `3.2` Featherlight Model (1B and 3B) instructions, please see the respective notebook, this one covers 3.1 models.\n",
+    "This tutorial shows you how to apply Tool Calling using Llama models. This tutorial uses Llama 3.3 models. \n",
+    "\n",
+    "For continuity, we show built-in tool calling that we introduced in Llama-3.1 namely allowing you to use `brave_search` and `wolfram_alpha`. \n",
+    "\n",
+    "However, please remember `3.3` models will work great with zero-shot tool calling which we showcase in second notebook. In fact that is the recommended path.\n",
+    "\n",
+    "Note: If you are looking for `3.2` Featherlight Model (1B and 3B) instructions, please see the respective sections in our website, this one covers 3.1 models.\n",
     "\n",
     "We are briefly introduction the `3.2` models at the end. \n",
     "\n",
     "Note: The new vision models behave same as `3.1` models when you are talking to the models without an image\n",
     "\n",
-    "This is part (1/2) in the tool calling series, this notebook will cover the basics of what tool calling is and how to perform it with `Llama 3.1 models`\n",
+    "This is part (1/2) in the tool calling series, this notebook will cover the basics of what tool calling is and how to perform it with `Llama 3.3 models`\n",
     "\n",
     "Here's what you will learn in this notebook:\n",
     "\n",
-    "- Setup Groq to access Llama 3.1 70B model\n",
+    "- Setup Groq to access Llama 3.3 70B model\n",
     "- Avoid common mistakes when performing tool-calling with Llama\n",
     "- Understand Prompt templates for Tool Calling\n",
     "- Understand how the tool calls are handled under the hood\n",
@@ -54,7 +60,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 1,
+   "execution_count": null,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -64,14 +70,14 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 2,
+   "execution_count": null,
    "metadata": {},
    "outputs": [],
    "source": [
     "import os\n",
     "from groq import Groq\n",
     "# Create the Groq client\n",
-    "client = Groq(api_key='YOUR_API_KEY')"
+    "client = Groq(api_key='')"
    ]
   },
   {
@@ -99,7 +105,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 6,
+   "execution_count": 5,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -113,7 +119,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 7,
+   "execution_count": 6,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -131,7 +137,7 @@
     "    \n",
     "    chat_history.append({\"role\": \"user\", \"content\": user_input})\n",
     "    \n",
-    "    response = client.chat.completions.create(model=\"llama-3.1-70b-versatile\",\n",
+    "    response = client.chat.completions.create(model=\"llama-3.3-70b-versatile\",\n",
     "                                          messages=chat_history,\n",
     "                                          max_tokens=max_tokens,\n",
     "                                          temperature=temperature)\n",
@@ -158,26 +164,24 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 85,
+   "execution_count": null,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "Assistant: Unfortunately, I don't have information on a specific release date for the next Elden Ring game. However, I can tell you that there have been rumors and speculations about a potential sequel or DLC (Downloadable Content) for Elden Ring.\n",
-      "\n",
-      "In June 2022, the game's director, Hidetaka Miyazaki, mentioned that FromSoftware, the developer of Elden Ring, was working on \"multiple\" new projects, but no official announcements have been made since then.\n",
+      "Assistant: As of my knowledge cutoff in December 2023, there has been no official announcement from FromSoftware, the developers of the Elden Ring series, regarding a release date for a new Elden Ring game.\n",
       "\n",
-      "It's also worth noting that FromSoftware has a history of taking their time to develop new games, and the studio is known for its attention to detail and commitment to quality. So, even if there is a new Elden Ring game in development, it's likely that we won't see it anytime soon.\n",
+      "However, it's worth noting that FromSoftware has mentioned that they are working on new projects, and there have been rumors and speculation about a potential Elden Ring sequel or DLC. But until an official announcement is made, we can't confirm any details about a new Elden Ring game.\n",
       "\n",
-      "Keep an eye on official announcements from FromSoftware and Bandai Namco, the publisher of Elden Ring, for any updates on a potential sequel or new game in the series.\n"
+      "If you're eager for more Elden Ring content, you can keep an eye on the official Elden Ring website, social media channels, and gaming news outlets for any updates or announcements. I'll be happy to help you stay informed if any new information becomes available!\n"
      ]
     }
    ],
    "source": [
     "user_input = \"\"\"\n",
-    "When is the next elden ring game coming out?\n",
+    "When is the next Elden Ring game coming out?\n",
     "\"\"\"\n",
     "\n",
     "print(\"Assistant:\", model_chat(user_input, sys_prompt=SYSTEM_PROMPT))"
@@ -194,16 +198,16 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 86,
+   "execution_count": 8,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "Assistant: To find the square root of 23131231, I'll calculate it for you.\n",
+      "Assistant: To find the square root of 23131231, we'll calculate it directly.\n",
       "\n",
-      "√23131231 ≈ 4813.61\n"
+      "The square root of 23131231 is approximately 4807.035.\n"
      ]
     }
    ],
@@ -224,18 +228,20 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 87,
+   "execution_count": 9,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "Assistant: I can use a mathematical tool to solve the question.\n",
+      "Assistant: To find the square root of 23131231, I can use a calculator or a computational tool.\n",
+      "\n",
+      "Using a calculator, I get:\n",
       "\n",
-      "The square root of 23131231 is:\n",
+      "√23131231 ≈ 4817.42\n",
       "\n",
-      "√23131231 ≈ 4810.51\n"
+      "So, the square root of 23131231 is approximately 4817.42.\n"
      ]
     }
    ],
@@ -258,18 +264,21 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 88,
+   "execution_count": 10,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "Assistant: I can use Wolfram Alpha to calculate the square root of 23131231.\n",
+      "Assistant: To find the square root of 23131231, I can use a tool like Wolfram Alpha.\n",
+      "\n",
+      "The square root of 23131231 is approximately 4817.316.\n",
+      "\n",
       "\n",
-      "According to Wolfram Alpha, the square root of 23131231 is:\n",
+      "Wolfram Alpha calculation:\n",
       "\n",
-      "√23131231 ≈ 4809.07\n"
+      "√23131231 ≈ 4817.316\n"
      ]
     }
    ],
@@ -295,16 +304,16 @@
     "\n",
     "The Llama Stack is the go to approach to use the Llama model family and build applications. \n",
     "\n",
-    "Let's first install the `llama_toolchain` Python package to have the Llama CLI available."
+    "Let's first install the `llama-stack` Python package to have the Llama CLI available."
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 12,
+   "execution_count": 13,
    "metadata": {},
    "outputs": [],
    "source": [
-    "#!pip3 install llama-toolchain"
+    "#!pip3 install llama-stack"
    ]
   },
   {
@@ -318,24 +327,15 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 20,
+   "execution_count": 14,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "Traceback (most recent call last):\n",
-      "  File \"/opt/miniconda3/bin/llama\", line 8, in <module>\n",
-      "    sys.exit(main())\n",
-      "             ^^^^^^\n",
-      "  File \"/opt/miniconda3/lib/python3.12/site-packages/llama_toolchain/cli/llama.py\", line 44, in main\n",
-      "    parser.run(args)\n",
-      "  File \"/opt/miniconda3/lib/python3.12/site-packages/llama_toolchain/cli/llama.py\", line 38, in run\n",
-      "    args.func(args)\n",
-      "  File \"/opt/miniconda3/lib/python3.12/site-packages/llama_toolchain/cli/model/prompt_format.py\", line 59, in _run_model_template_cmd\n",
-      "    raise argparse.ArgumentTypeError(\n",
-      "argparse.ArgumentTypeError: llama3_1 is not a valid Model. Choose one from --\n",
+      "usage: llama model prompt-format [-h] [-m MODEL_NAME]\n",
+      "llama model prompt-format: error: llama3_1 is not a valid Model. Choose one from --\n",
       "Llama3.1-8B\n",
       "Llama3.1-70B\n",
       "Llama3.1-405B\n",
@@ -359,27 +359,387 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 21,
+   "execution_count": 17,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[m━━━━━━━━━━━━━━━━━━━┓\u001b[m\n",
-      "┃                                    \u001b[1mLlama 3.1 - Prompt Formats\u001b[0m                 \u001b[m\u001b[1m\u001b[0m                   ┃\u001b[m\n",
-      "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[m━━━━━━━━━━━━━━━━━━━┛\u001b[m\n",
-      "\u001b[m\n",
-      "\u001b[m\n",
-      "                                               \u001b[1;4mTokens\u001b[0m                           \u001b[m\u001b[1;4m\u001b[0m                    \u001b[m\n",
-      "\u001b[m\n",
-      "Here is a list of special tokens that are supported by Llama 3.1:               \u001b[m                    \u001b[m\n",
-      "\u001b[m\n",
-      "\u001b[1;33m • \u001b[0m\u001b[1;36;40m<|begin_of_text|>\u001b[0m: Specifies the start of the prompt                         \u001b[m\u001b[1;33m\u001b[0m\u001b[1;36;40m\u001b[0m                    \u001b[m\n",
-      "\u001b[1;33m • \u001b[0m\u001b[1;36;40m<|end_of_text|>\u001b[0m: Model will cease to generate more tokens. This token is gene\u001b[m\u001b[1;33m\u001b[0m\u001b[1;36;40m\u001b[0mrated only by the   \u001b[m\n",
-      "\u001b[1;33m   \u001b[0mbase models.                                                                 \u001b[m\u001b[1;33m\u001b[0m                    \u001b[m\n",
-      "\u001b[1;33m • \u001b[0m\u001b[1;36;40m<|finetune_right_pad_id|>\u001b[0m: This token is used for padding text sequences to t\u001b[m\u001b[1;33m\u001b[0m\u001b[1;36;40m\u001b[0mhe same length in a \u001b[m\n",
-      "\u001b[1;33m   \u001b[0mbatch.                                                                       \u001b[m:\u001b[K"
+      "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n",
+      "┃                                    \u001b[1mLlama 3.1 - Prompt Formats\u001b[0m                                    ┃\n",
+      "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n",
+      "\n",
+      "\n",
+      "                                               \u001b[1;4mTokens\u001b[0m                                               \n",
+      "\n",
+      "Here is a list of special tokens that are supported by Llama 3.1:                                   \n",
+      "\n",
+      "\u001b[1;33m • \u001b[0m\u001b[1;36;40m<|begin_of_text|>\u001b[0m: Specifies the start of the prompt                                             \n",
+      "\u001b[1;33m • \u001b[0m\u001b[1;36;40m<|end_of_text|>\u001b[0m: Model will cease to generate more tokens. This token is generated only by the   \n",
+      "\u001b[1;33m   \u001b[0mbase models.                                                                                     \n",
+      "\u001b[1;33m • \u001b[0m\u001b[1;36;40m<|finetune_right_pad_id|>\u001b[0m: This token is used for padding text sequences to the same length in a \n",
+      "\u001b[1;33m   \u001b[0mbatch.                                                                                           \n",
+      "\u001b[1;33m • \u001b[0m\u001b[1;36;40m<|start_header_id|>\u001b[0m and \u001b[1;36;40m<|end_header_id|>\u001b[0m: These tokens enclose the role for a particular        \n",
+      "\u001b[1;33m   \u001b[0mmessage. The possible roles are: [system, user, assistant and ipython]                           \n",
+      "\u001b[1;33m • \u001b[0m\u001b[1;36;40m<|eom_id|>\u001b[0m: End of message. A message represents a possible stopping point for execution where   \n",
+      "\u001b[1;33m   \u001b[0mthe model can inform the executor that a tool call needs to be made. This is used for multi-step \n",
+      "\u001b[1;33m   \u001b[0minteractions between the model and any available tools. This token is emitted by the model when  \n",
+      "\u001b[1;33m   \u001b[0mthe Environment: ipython instruction is used in the system prompt, or if the model calls for a   \n",
+      "\u001b[1;33m   \u001b[0mbuilt-in tool.                                                                                   \n",
+      "\u001b[1;33m • \u001b[0m\u001b[1;36;40m<|eot_id|>\u001b[0m: End of turn. Represents when the model has determined that it has finished           \n",
+      "\u001b[1;33m   \u001b[0minteracting with the user message that initiated its response. This is used in two scenarios:    \n",
+      "\u001b[1;33m   \u001b[0m\u001b[1;33m • \u001b[0mat the end of a direct interaction between the model and the user                             \n",
+      "\u001b[1;33m   \u001b[0m\u001b[1;33m • \u001b[0mat the end of multiple interactions between the model and any available tools This token      \n",
+      "\u001b[1;33m   \u001b[0m\u001b[1;33m   \u001b[0msignals to the executor that the model has finished generating a response.                    \n",
+      "\u001b[1;33m • \u001b[0m\u001b[1;36;40m<|python_tag|>\u001b[0m: Is a special tag used in the model's response to signify a tool call.            \n",
+      "\n",
+      "There are 4 different roles that are supported by Llama 3.1                                         \n",
+      "\n",
+      "\u001b[1;33m • \u001b[0m\u001b[1;36;40msystem\u001b[0m: Sets the context in which to interact with the AI model. It typically includes rules,    \n",
+      "\u001b[1;33m   \u001b[0mguidelines, or necessary information that helps the model respond effectively.                   \n",
+      "\u001b[1;33m • \u001b[0m\u001b[1;36;40muser\u001b[0m: Represents the human interacting with the model. It includes the inputs, commands, and     \n",
+      "\u001b[1;33m   \u001b[0mquestions to the model.                                                                          \n",
+      "\u001b[1;33m • \u001b[0m\u001b[1;36;40mipython\u001b[0m: A new role introduced in Llama 3.1. Semantically, this role means \"tool\". This role is  \n",
+      "\u001b[1;33m   \u001b[0mused to mark messages with the output of a tool call when sent back to the model from the        \n",
+      "\u001b[1;33m   \u001b[0mexecutor.                                                                                        \n",
+      "\u001b[1;33m • \u001b[0m\u001b[1;36;40massistant\u001b[0m: Represents the response generated by the AI model based on the context provided in the\n",
+      "\u001b[1;33m   \u001b[0m\u001b[1;36;40msystem\u001b[0m, \u001b[1;36;40mipython\u001b[0m and \u001b[1;36;40muser\u001b[0m prompts.                                                                \n",
+      "\n",
+      "\n",
+      "                                        \u001b[1;4mLlama 3.1 Base Model\u001b[0m                                        \n",
+      "\n",
+      "Text completion for Llama 3.1 base model uses this format.                                          \n",
+      "\n",
+      "                                        \u001b[4mInput Prompt Format\u001b[0m                                         \n",
+      "\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m<|begin_of_text|>Color of sky is blue but sometimes can also be\u001b[0m\u001b[40m                                   \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\n",
+      "                                       \u001b[4mModel Response Format\u001b[0m                                        \n",
+      "\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m red, orange, yellow, green, purple, pink, brown, gray, black, white, and even rainbow colors. The\u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mcolor of the sky can change due to various reasons such as time of day, weather conditions, \u001b[0m\u001b[40m      \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mpollution, and atmospheric phenomena.\u001b[0m\u001b[40m                                                             \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mThe color of the sky is primarily blue because of a phenomenon called\u001b[0m\u001b[40m                             \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\n",
+      "Note start special tag                                                                              \n",
+      "\n",
+      "\n",
+      "                                      \u001b[1;4mLlama 3.1 Instruct Model\u001b[0m                                      \n",
+      "\n",
+      "\n",
+      "                                  \u001b[1;4mUser and assistant conversation\u001b[0m                                   \n",
+      "\n",
+      "Here is a regular multi-turn user assistant conversation and how its formatted.                     \n",
+      "\n",
+      "                                        \u001b[4mInput Prompt Format\u001b[0m                                         \n",
+      "\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m<|begin_of_text|><|start_header_id|>system<|end_header_id|>\u001b[0m\u001b[40m                                       \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mYou are a helpful assistant<|eot_id|><|start_header_id|>user<|end_header_id|>\u001b[0m\u001b[40m                     \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mAnswer who are you in the form of jeopardy?<|eot_id|><|start_header_id|>assistant<|end_header_id|>\u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\n",
+      "                                       \u001b[4mModel Response Format\u001b[0m                                        \n",
+      "\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mHere's my response\u001b[0m\u001b[40m                                                                                \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m\"What is a helpful assistant?\"<|eot_id|>\u001b[0m\u001b[40m                                                          \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\n",
+      "\n",
+      "                                        \u001b[1;4mTool Calling Formats\u001b[0m                                        \n",
+      "\n",
+      "The three built-in tools (brave_search, wolfram_alpha, and code interpreter) can be turned on using \n",
+      "the system prompt:                                                                                  \n",
+      "\n",
+      "\u001b[1;33m • \u001b[0mBrave Search: Tool call to perform web searches.                                                 \n",
+      "\u001b[1;33m • \u001b[0mWolfram Alpha: Tool call to perform complex mathematical calculations.                           \n",
+      "\u001b[1;33m • \u001b[0mCode Interpreter: Enables the model to output python code.                                       \n",
+      "\n",
+      "\n",
+      "                                        \u001b[1;4mBuiltin Tool Calling\u001b[0m                                        \n",
+      "\n",
+      "Here is an example of a conversation using brave search                                             \n",
+      "\n",
+      "                                        \u001b[4mInput Prompt Format\u001b[0m                                         \n",
+      "\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m<|begin_of_text|><|start_header_id|>system<|end_header_id|>\u001b[0m\u001b[40m                                       \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mEnvironment: ipython\u001b[0m\u001b[40m                                                                              \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mTools: brave_search, wolfram_alpha\u001b[0m\u001b[40m                                                                \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mCutting Knowledge Date: December 2023\u001b[0m\u001b[40m                                                             \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mToday Date: 21 September 2024\u001b[0m\u001b[40m                                                                     \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mYou are a helpful assistant.\u001b[0m\u001b[40m                                                                      \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m<|eot_id|><|start_header_id|>user<|end_header_id|>\u001b[0m\u001b[40m                                                \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mSearch the web for the latest price of 1oz \u001b[0m\u001b[40m                                                       \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mgold?<|eot_id|><|start_header_id|>assistant<|end_header_id|>\u001b[0m\u001b[40m                                      \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\n",
+      "                                       \u001b[4mModel Response Format\u001b[0m                                        \n",
+      "\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m<|python_tag|>brave_search.call(query=\"latest price of 1oz gold\")<|eom_id|>\u001b[0m\u001b[40m                       \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\n",
+      "\u001b[1;33m • \u001b[0mJust including Environment: ipython turns on code interpreter; therefore, you don't need to      \n",
+      "\u001b[1;33m   \u001b[0mspecify code interpretation on the Tools: line. The model can generate python code which is      \n",
+      "\u001b[1;33m   \u001b[0minterpreted by the executor, with the result provided back to the model.                         \n",
+      "\u001b[1;33m • \u001b[0mThe message body of the assistant response starts with a special tag <|python_tag|>              \n",
+      "\u001b[1;33m • \u001b[0mAs alluded to above, in such an environment, the model can generate <|eom_id|> instead of just   \n",
+      "\u001b[1;33m   \u001b[0mthe standard <|eot_id|> . The latter indicates the turn is finished, while the former indicates  \n",
+      "\u001b[1;33m   \u001b[0mcontinued multi-step reasoning. That is, the model is expecting a continuation message with the  \n",
+      "\u001b[1;33m   \u001b[0moutput of the tool call.                                                                         \n",
+      "\u001b[1;33m • \u001b[0mThe model tool call response is of the form \u001b[1;36;40mtool.call(query=\"...\")\u001b[0m wher tool is \u001b[1;36;40mbrave_search\u001b[0m or  \n",
+      "\u001b[1;33m   \u001b[0m\u001b[1;36;40mwolfram_alpha\u001b[0m                                                                                    \n",
+      "\n",
+      "\n",
+      "                                      \u001b[1;4mBuiltin Code Interpreter\u001b[0m                                      \n",
+      "\n",
+      "Here is an actual example of model responding with code                                             \n",
+      "\n",
+      "                                        \u001b[4mInput Prompt Format\u001b[0m                                         \n",
+      "\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m<|begin_of_text|><|start_header_id|>system<|end_header_id|>\u001b[0m\u001b[40m                                       \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mEnvironment: ipython<|eot_id|><|start_header_id|>user<|end_header_id|>\u001b[0m\u001b[40m                            \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mWrite code to check if number is prime, use that to see if the number 7 is \u001b[0m\u001b[40m                       \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mprime<|eot_id|><|start_header_id|>assistant<|end_header_id|>\u001b[0m\u001b[40m                                      \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\n",
+      "                                       \u001b[4mModel Response Format\u001b[0m                                        \n",
+      "\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m<|python_tag|>def is_prime(n):\u001b[0m\u001b[40m                                                                    \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m    if n <= 1\u001b[0m\u001b[40m                                                                                     \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m        return False\u001b[0m\u001b[40m                                                                              \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m    for i in range(2, int(n**0.5) + 1):\u001b[0m\u001b[40m                                                           \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m        if n % i == 0:\u001b[0m\u001b[40m                                                                            \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m            return False\u001b[0m\u001b[40m                                                                          \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m    return True\u001b[0m\u001b[40m                                                                                   \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mprint(is_prime(7))  # Output: True<|eom_id|>\u001b[0m\u001b[40m                                                      \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\n",
+      "\u001b[1;33m • \u001b[0mModel starts with <|python_tag|> and continues writing python code that it needs to be executed  \n",
+      "\u001b[1;33m • \u001b[0mNo explicit mention of code_interpreter in system prompt. \u001b[1;36;40mEnvironment: ipython\u001b[0m implicitly enables\n",
+      "\u001b[1;33m   \u001b[0mit.                                                                                              \n",
+      "\n",
+      "\n",
+      "                                  \u001b[1;4mBuilt-in tools full interaction\u001b[0m                                   \n",
+      "\n",
+      "Here is a full interaction with the built-in tools including the tool response and the final        \n",
+      "assistant response.                                                                                 \n",
+      "\n",
+      "                                        \u001b[4mInput Prompt Format\u001b[0m                                         \n",
+      "\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m<|begin_of_text|><|start_header_id|>system<|end_header_id|>\u001b[0m\u001b[40m                                       \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mEnvironment: ipython\u001b[0m\u001b[40m                                                                              \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mTools: brave_search, wolfram_alpha\u001b[0m\u001b[40m                                                                \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m<|eot_id|><|start_header_id|>user<|end_header_id|>\u001b[0m\u001b[40m                                                \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mWhat is the 100th decimal of pi?<|eot_id|><|start_header_id|>assistant<|end_header_id|>\u001b[0m\u001b[40m           \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m<|python_tag|>wolfram_alpha.call(query=\"100th decimal of \u001b[0m\u001b[40m                                         \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mpi\")<|eom_id|><|start_header_id|>ipython<|end_header_id|>\u001b[0m\u001b[40m                                         \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m{\u001b[0m\u001b[40m                                                                                                 \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m    \"queryresult\": {\u001b[0m\u001b[40m                                                                              \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m        \"success\": true,\u001b[0m\u001b[40m                                                                          \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m        \"inputstring\": \"100th decimal of pi\",\u001b[0m\u001b[40m                                                     \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m        \"pods\": [\u001b[0m\u001b[40m                                                                                 \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m            {\u001b[0m\u001b[40m                                                                                     \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                \"title\": \"Input interpretation\",\u001b[0m\u001b[40m                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                \"subpods\": [\u001b[0m\u001b[40m                                                                      \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                    {\u001b[0m\u001b[40m                                                                             \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                        \"title\": \"\",\u001b[0m\u001b[40m                                                              \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                        \"plaintext\": \"100th digit | π\"\u001b[0m\u001b[40m                                            \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                    }\u001b[0m\u001b[40m                                                                             \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                ]\u001b[0m\u001b[40m                                                                                 \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m            },\u001b[0m\u001b[40m                                                                                    \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m            {\u001b[0m\u001b[40m                                                                                     \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                \"title\": \"Nearby digits\",\u001b[0m\u001b[40m                                                         \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                \"subpods\": [\u001b[0m\u001b[40m                                                                      \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                    {\u001b[0m\u001b[40m                                                                             \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                        \"title\": \"\",\u001b[0m\u001b[40m                                                              \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                        \"plaintext\": \"...86208998628034825342117067982148086513282306647093...\"\u001b[0m\u001b[40m   \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                    }\u001b[0m\u001b[40m                                                                             \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                ]\u001b[0m\u001b[40m                                                                                 \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m            },\u001b[0m\u001b[40m                                                                                    \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m            {\u001b[0m\u001b[40m                                                                                     \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                \"title\": \"Result\",\u001b[0m\u001b[40m                                                                \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                \"primary\": true,\u001b[0m\u001b[40m                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                \"subpods\": [\u001b[0m\u001b[40m                                                                      \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                    {\u001b[0m\u001b[40m                                                                             \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                        \"title\": \"\",\u001b[0m\u001b[40m                                                              \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                        \"plaintext\": \"7\"\u001b[0m\u001b[40m                                                          \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                    }\u001b[0m\u001b[40m                                                                             \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                ]\u001b[0m\u001b[40m                                                                                 \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m            }\u001b[0m\u001b[40m                                                                                     \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m        ]\u001b[0m\u001b[40m                                                                                         \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m    }\u001b[0m\u001b[40m                                                                                             \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m}\u001b[0m\u001b[40m                                                                                                 \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m<|eot_id|><|start_header_id|>assistant<|end_header_id|>\u001b[0m\u001b[40m                                           \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\n",
+      "                                       \u001b[4mModel Response Format\u001b[0m                                        \n",
+      "\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mThe 100th decimal of pi is 7.<|eot_id|>\u001b[0m\u001b[40m                                                           \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\n",
+      "\u001b[1;33m • \u001b[0mNote the \u001b[1;36;40m<|python_tag|>\u001b[0m in the assistant response.                                               \n",
+      "\u001b[1;33m • \u001b[0mRole is \u001b[1;36;40mipython\u001b[0m for the wolfram alpha response that is passed back to the model.                 \n",
+      "\u001b[1;33m • \u001b[0mFinal message from assistant has <|eot_id|> tag.                                                 \n",
+      "\n",
+      "\n",
+      "                                       \u001b[1;4mZero shot tool calling\u001b[0m                                       \n",
+      "\n",
+      "\n",
+      "                                      \u001b[1;4mJSON based tool calling\u001b[0m                                       \n",
+      "\n",
+      "Llama models can now output custom tool calls from a single message to allow easier tool calling.   \n",
+      "The following prompts provide an example of how custom tools can be called from the output of the   \n",
+      "model. It's important to note that the model itself does not execute the calls; it provides         \n",
+      "structured output to facilitate calling by an executor.                                             \n",
+      "\n",
+      "                                        \u001b[4mInput Prompt Format\u001b[0m                                         \n",
+      "\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m<|begin_of_text|><|start_header_id|>system<|end_header_id|>\u001b[0m\u001b[40m                                       \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mEnvironment: ipython\u001b[0m\u001b[40m                                                                              \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mCutting Knowledge Date: December 2023\u001b[0m\u001b[40m                                                             \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mToday Date: 21 September 2024\u001b[0m\u001b[40m                                                                     \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mYou are a helpful assistant.\u001b[0m\u001b[40m                                                                      \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m<|eot_id|><|start_header_id|>user<|end_header_id|>\u001b[0m\u001b[40m                                                \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mAnswer the user's question by making use of the following functions if needed.\u001b[0m\u001b[40m                    \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mIf none of the function can be used, please say so.\u001b[0m\u001b[40m                                               \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mHere is a list of functions in JSON format:\u001b[0m\u001b[40m                                                       \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m{\u001b[0m\u001b[40m                                                                                                 \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m    \"type\": \"function\",\u001b[0m\u001b[40m                                                                           \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m    \"function\": {\u001b[0m\u001b[40m                                                                                 \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m        \"name\": \"trending_songs\",\u001b[0m\u001b[40m                                                                 \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m        \"description\": \"Returns the trending songs on a Music site\",\u001b[0m\u001b[40m                              \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m        \"parameters\": {\u001b[0m\u001b[40m                                                                           \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m            \"type\": \"object\",\u001b[0m\u001b[40m                                                                     \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m            \"properties\": [\u001b[0m\u001b[40m                                                                       \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                {\u001b[0m\u001b[40m                                                                                 \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                    \"n\": {\u001b[0m\u001b[40m                                                                        \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                        \"type\": \"object\",\u001b[0m\u001b[40m                                                         \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                        \"description\": \"The number of songs to return\"\u001b[0m\u001b[40m                            \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                    }\u001b[0m\u001b[40m                                                                             \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                },\u001b[0m\u001b[40m                                                                                \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                {\u001b[0m\u001b[40m                                                                                 \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                    \"genre\": {\u001b[0m\u001b[40m                                                                    \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                        \"type\": \"object\",\u001b[0m\u001b[40m                                                         \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                        \"description\": \"The genre of the songs to return\"\u001b[0m\u001b[40m                         \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                    }\u001b[0m\u001b[40m                                                                             \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m                }\u001b[0m\u001b[40m                                                                                 \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m            ],\u001b[0m\u001b[40m                                                                                    \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m            \"required\": [\"n\"]\u001b[0m\u001b[40m                                                                     \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m        }\u001b[0m\u001b[40m                                                                                         \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m    }\u001b[0m\u001b[40m                                                                                             \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m}\u001b[0m\u001b[40m                                                                                                 \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mReturn function calls in JSON format.<|eot_id|><|start_header_id|>user<|end_header_id|>\u001b[0m\u001b[40m           \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mUse tools to get latest trending songs<|eot_id|><|start_header_id|>assistant<|end_header_id|>\u001b[0m\u001b[40m     \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\n",
+      "                                       \u001b[4mModel Response Format\u001b[0m                                        \n",
+      "\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m<|python_tag|>{\u001b[0m\u001b[40m                                                                                   \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m    \"type\": \"function\",\u001b[0m\u001b[40m                                                                           \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m    \"name\": \"trending_songs\",\u001b[0m\u001b[40m                                                                     \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m    \"parameters\": {\u001b[0m\u001b[40m                                                                               \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m        \"n\": \"10\",\u001b[0m\u001b[40m                                                                                \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m        \"genre\": \"all\"\u001b[0m\u001b[40m                                                                            \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m    }\u001b[0m\u001b[40m                                                                                             \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m}<|eom_id|>\u001b[0m\u001b[40m                                                                                       \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\n",
+      "\u001b[1;33m • \u001b[0mJSON format for providing tools needs name, description and parameters                           \n",
+      "\u001b[1;33m • \u001b[0mModel responds with \u001b[1;36;40m<|python_tag|>\u001b[0m and \u001b[1;36;40m<|eom_id|>\u001b[0m as \u001b[1;36;40mEnvironment: ipython\u001b[0m was in the system      \n",
+      "\u001b[1;33m   \u001b[0mprompt                                                                                           \n",
+      "\u001b[1;33m • \u001b[0mInstructions for tools added as a user message                                                   \n",
+      "\u001b[1;33m • \u001b[0mOnly single tool calls are supported as of now                                                   \n",
+      "\n",
+      "\n",
+      "                               \u001b[1;4mExample of a user defined tool calling\u001b[0m                               \n",
+      "\n",
+      "\n",
+      "                                   \u001b[1;4;36;40m<function>\u001b[0m\u001b[1;4m based tool calling\u001b[0m                                    \n",
+      "\n",
+      "Here is an example of how you could also write custom instructions for model to do zero shot tool   \n",
+      "calling. In this example, we define a custom tool calling format using the \u001b[1;36;40m<function>\u001b[0m tag.          \n",
+      "\n",
+      "                                        \u001b[4mInput Prompt Format\u001b[0m                                         \n",
+      "\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m<|begin_of_text|><|start_header_id|>system<|end_header_id|>\u001b[0m\u001b[40m                                       \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mEnvironment: ipython\u001b[0m\u001b[40m                                                                              \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mCutting Knowledge Date: December 2023\u001b[0m\u001b[40m                                                             \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mToday Date: 21 September 2024\u001b[0m\u001b[40m                                                                     \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mYou are a helpful assistant.\u001b[0m\u001b[40m                                                                      \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m<|eot_id|><|start_header_id|>user<|end_header_id|>\u001b[0m\u001b[40m                                                \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mYou have access to the following functions:\u001b[0m\u001b[40m                                                       \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mUse the function 'trending_songs' to 'Returns the trending songs on a Music site':\u001b[0m\u001b[40m                \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m{\"name\": \"trending_songs\", \"description\": \"Returns the trending songs on a Music site\", \u001b[0m\u001b[40m          \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m\"parameters\": {\"genre\": {\"description\": \"The genre of the songs to return\", \"param_type\": \"str\", \u001b[0m\u001b[40m \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m\"required\": false}, \"n\": {\"description\": \"The number of songs to return\", \"param_type\": \"int\", \u001b[0m\u001b[40m   \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m\"required\": true}}}\u001b[0m\u001b[40m                                                                               \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mThink very carefully before calling functions.\u001b[0m\u001b[40m                                                    \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mIf you choose to call a function ONLY reply in the following format with no prefix or suffix:\u001b[0m\u001b[40m     \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m<function=example_function_name>{\"example_name\": \"example_value\"}</function>\u001b[0m\u001b[40m                      \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mReminder:\u001b[0m\u001b[40m                                                                                         \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m- If looking for real time information use relevant functions before falling back to brave_search\u001b[0m\u001b[40m \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m- Function calls MUST follow the specified format, start with <function= and end with </function>\u001b[0m\u001b[40m \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m- Required parameters MUST be specified\u001b[0m\u001b[40m                                                           \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m- Only call one function at a time\u001b[0m\u001b[40m                                                                \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m- Put the entire function call reply on one line<|eot_id|><|start_header_id|>user<|end_header_id|>\u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[40m                                                                                                  \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40mUse tools to get latest trending songs<|eot_id|><|start_header_id|>assistant<|end_header_id|>\u001b[0m\u001b[40m     \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\n",
+      "                                       \u001b[4mModel Response Format\u001b[0m                                        \n",
+      "\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\u001b[40m \u001b[0m\u001b[97;40m<function=trending_songs>{\"n\": 10}</function><|eot_id|>\u001b[0m\u001b[40m                                           \u001b[0m\u001b[40m \u001b[0m\n",
+      "\u001b[40m                                                                                                    \u001b[0m\n",
+      "\n",
+      "\u001b[1;33m • \u001b[0mIn this case, model does NOT respond with \u001b[1;36;40m<|python_tag|>\u001b[0m and ends with \u001b[1;36;40m<|eot_id|>\u001b[0m                \n",
+      "\u001b[1;33m • \u001b[0mInstructions for tools added as a user message                                                   \n",
+      "\n",
+      "Thank You!                                                                                          \n",
+      "\n"
      ]
     }
    ],
@@ -393,7 +753,7 @@
    "source": [
     "## Tool Calling: Using the correct Prompt Template\n",
     "\n",
-    "With `llama-cli` we have already learned the right behaviour of the model"
+    "With `llama-stack` we have already learned the right behaviour of the model"
    ]
   },
   {
@@ -409,7 +769,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 95,
+   "execution_count": null,
    "metadata": {},
    "outputs": [
     {
@@ -429,7 +789,7 @@
     "\"\"\"\n",
     "\n",
     "user_input = \"\"\"\n",
-    "When is the next Elden ring game coming out?\n",
+    "When is the next Elden Ring game coming out?\n",
     "\"\"\"\n",
     "\n",
     "print(\"Assistant:\", model_chat(user_input, sys_prompt=SYSTEM_PROMPT))\n"
@@ -460,11 +820,11 @@
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "### Using this knowledge in practise\n",
+    "### Using this knowledge in practice\n",
     "\n",
     "A common misconception about tool calling is: the model can handle the tool call and get your output. \n",
     "\n",
-    "This is NOT TRUE, the actual tool call is something that you have to implement. With this knowledge, let's see how we can utilise brave search to answer our original question"
+    "This is NOT TRUE, the actual tool call is something that you have to implement. With this knowledge, let's see how we can utilize brave search to answer our original question"
    ]
   },
   {
@@ -967,7 +1327,7 @@
  ],
  "metadata": {
   "kernelspec": {
-   "display_name": "Python 3",
+   "display_name": "base",
    "language": "python",
    "name": "python3"
   },
@@ -981,7 +1341,7 @@
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.12.5"
+   "version": "3.12.2"
   }
  },
  "nbformat": 4,

+ 5 - 5
end-to-end-use-cases/agents/Agents_Tutorial/Tool_Calling_201.ipynb

@@ -8,13 +8,13 @@
     "\n",
     "The image below illustrates the demo in this notebook. \n",
     "\n",
-    "**Goal:** Use `Meta-Llama-3.1-70b` model to find the differences between two papers\n",
+    "**Goal:** Use `Meta-Llama-3.3-70b` model to find the differences between two papers\n",
     "\n",
     "- Step 1: Take the user input query \n",
     "\n",
     "- Step 2: Perform an internet search using `tavily` API to fetch the arxiv ID(s) based on the user query\n",
     "\n",
-    "Note: `3.1` models support `brave_search` but this notebook is also aimed at showcasing custom tools. \n",
+    "Note: `3.3` models also support `brave_search` but this notebook is also aimed at showcasing zero-shot custom tools. \n",
     "\n",
     "The above is important because many-times the user-query is different from the paper name and arxiv ID-this will help us with the next step\n",
     "\n",
@@ -26,7 +26,7 @@
     "\n",
     "- Step 5: For ease, we will extract first 80k words from the PDF and write these to a `.txt` file that we can summarise\n",
     "\n",
-    "- Step 6: Use instances of `Meta-Llama-3.1-8b` instances to summaries the two PDF(s)\n",
+    "- Step 6: Use instances of `Meta-Llama-3.3-8b` instances to summaries the two PDF(s)\n",
     "\n",
     "- Step 7: Prompt the `70b` model to get the differences between the two papers being discussed"
    ]
@@ -229,7 +229,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 52,
+   "execution_count": null,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -242,7 +242,7 @@
     "    \n",
     "    #print(\"User: \", user_input)\n",
     "    \n",
-    "    response = client.chat.completions.create(model=\"llama-3.1-70b-versatile\",\n",
+    "    response = client.chat.completions.create(model=\"llama-3.3-70b-versatile\",\n",
     "                                          messages=main_model_chat_history,\n",
     "                                          max_tokens=max_tokens,\n",
     "                                          temperature=temperature)\n",