From eb3e9b85f9c634f102ee3f64c0079361b9d73ef0 Mon Sep 17 00:00:00 2001 From: ehhuang Date: Tue, 21 Oct 2025 11:09:45 -0700 Subject: [PATCH] chore: update getting_started (#3875) # What does this PR do? ## Test Plan --- docs/getting_started.ipynb | 2571 +++++++++++++++++------------------- 1 file changed, 1209 insertions(+), 1362 deletions(-) diff --git a/docs/getting_started.ipynb b/docs/getting_started.ipynb index e1e2ff82e..a03de73f5 100644 --- a/docs/getting_started.ipynb +++ b/docs/getting_started.ipynb @@ -57,6 +57,62 @@ "\n" ] }, + { + "cell_type": "markdown", + "id": "be3b12f8-b857-4f02-b451-a5a6b5be0814", + "metadata": {}, + "source": [ + "### 1.2 Install llama-stack and llama-stack-client packages" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "2dde9482-0e5d-49ca-a350-1e239eb341c5", + "metadata": { + "collapsed": true, + "jupyter": { + "outputs_hidden": true + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: uv in /opt/homebrew/Caskroom/miniconda/base/envs/test/lib/python3.12/site-packages (0.9.4)\n", + "\u001b[2mUsing Python 3.12.12 environment at: /opt/homebrew/Caskroom/miniconda/base/envs/test\u001b[0m\n", + "\u001b[2K\u001b[2mResolved \u001b[1m84 packages\u001b[0m \u001b[2min 603ms\u001b[0m\u001b[0m \u001b[0m\n", + "\u001b[2K\u001b[2mPrepared \u001b[1m1 package\u001b[0m \u001b[2min 371ms\u001b[0m\u001b[0m \n", + "\u001b[2K\u001b[2mInstalled \u001b[1m3 packages\u001b[0m \u001b[2min 50ms\u001b[0m\u001b[0m \u001b[0m\n", + " \u001b[32m+\u001b[39m \u001b[1mecdsa\u001b[0m\u001b[2m==0.19.1\u001b[0m\n", + " \u001b[32m+\u001b[39m \u001b[1mllama-stack\u001b[0m\u001b[2m==0.2.23\u001b[0m\n", + " \u001b[32m+\u001b[39m \u001b[1mpython-jose\u001b[0m\u001b[2m==3.5.0\u001b[0m\n", + "\u001b[2mUsing Python 3.12.12 environment at: /opt/homebrew/Caskroom/miniconda/base/envs/test\u001b[0m\n", + "\u001b[2K\u001b[2mResolved \u001b[1m35 packages\u001b[0m \u001b[2min 40ms\u001b[0m\u001b[0m \u001b[0m\n", + "\u001b[2K\u001b[2mPrepared \u001b[1m1 package\u001b[0m \u001b[2min 1.19s\u001b[0m\u001b[0m \n", + "\u001b[2mUninstalled \u001b[1m1 package\u001b[0m \u001b[2min 3ms\u001b[0m\u001b[0m\n", + "\u001b[2K\u001b[2mInstalled \u001b[1m1 package\u001b[0m \u001b[2min 9ms\u001b[0m\u001b[0m=0.3.0a6 (from file:///Users/erich\u001b[0m\n", + " \u001b[33m~\u001b[39m \u001b[1mllama-stack-client\u001b[0m\u001b[2m==0.3.0a6 (from file:///Users/erichuang/projects/llama-stack-client-python)\u001b[0m\n", + "\u001b[2mUsing Python 3.12.12 environment at: /opt/homebrew/Caskroom/miniconda/base/envs/test\u001b[0m\n", + "\u001b[2mAudited \u001b[1m52 packages\u001b[0m \u001b[2min 1.18s\u001b[0m\u001b[0m\n", + "\u001b[2mUsing Python 3.12.12 environment at: /opt/homebrew/Caskroom/miniconda/base/envs/test\u001b[0m\n", + "\u001b[2mAudited \u001b[1m1 package\u001b[0m \u001b[2min 67ms\u001b[0m\u001b[0m\n", + "\u001b[2mUsing Python 3.12.12 environment at: /opt/homebrew/Caskroom/miniconda/base/envs/test\u001b[0m\n", + "\u001b[2mAudited \u001b[1m3 packages\u001b[0m \u001b[2min 43ms\u001b[0m\u001b[0m\n", + "\u001b[2mUsing Python 3.12.12 environment at: /opt/homebrew/Caskroom/miniconda/base/envs/test\u001b[0m\n", + "\u001b[2mAudited \u001b[1m3 packages\u001b[0m \u001b[2min 125ms\u001b[0m\u001b[0m\n" + ] + } + ], + "source": [ + "!pip install uv\n", + "!uv pip install llama-stack llama-stack-client\n", + "\n", + "# Installs dependencies for the starter distribution\n", + "!uv run --with llama-stack llama stack list-deps starter | xargs -L1 uv pip install" + ] + }, { "cell_type": "markdown", "id": "oDUB7M_qe-Gs", @@ -64,7 +120,7 @@ "id": "oDUB7M_qe-Gs" }, "source": [ - "### 1.2. Setup and Running a Llama Stack server\n", + "### 1.3. Setup and Running a Llama Stack server\n", "\n", "Llama Stack is architected as a collection of APIs that provide developers with the building blocks to build AI applications. \n", "\n", @@ -75,61 +131,30 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "J2kGed0R5PSf", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, - "collapsed": true, "id": "J2kGed0R5PSf", "outputId": "2478ea60-8d35-48a1-b011-f233831740c5" }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Requirement already satisfied: uv in /opt/homebrew/Caskroom/miniconda/base/envs/stack/lib/python3.10/site-packages (0.5.29)\n", - "Environment '/Users/hjshah/git/llama-stack/.venv' already exists, re-using it.\n", - "Virtual environment /Users/hjshah/git/llama-stack/.venv is already active\n", - "\u001b[2mUsing Python 3.10.16 environment at: /Users/hjshah/git/llama-stack/.venv\u001b[0m\n", - "\u001b[2mAudited \u001b[1m1 package\u001b[0m \u001b[2min 314ms\u001b[0m\u001b[0m\n", - "Installing pip dependencies\n", - "\u001b[2mUsing Python 3.10.16 environment at: /Users/hjshah/git/llama-stack/.venv\u001b[0m\n", - "\u001b[2K\u001b[2mResolved \u001b[1m125 packages\u001b[0m \u001b[2min 646ms\u001b[0m\u001b[0m \u001b[0m\n", - "\u001b[2mUninstalled \u001b[1m1 package\u001b[0m \u001b[2min 404ms\u001b[0m\u001b[0m\n", - "\u001b[2K\u001b[2mInstalled \u001b[1m1 package\u001b[0m \u001b[2min 129ms\u001b[0m\u001b[0m \u001b[0m\n", - " \u001b[31m-\u001b[39m \u001b[1mnumpy\u001b[0m\u001b[2m==2.2.3\u001b[0m\n", - " \u001b[32m+\u001b[39m \u001b[1mnumpy\u001b[0m\u001b[2m==1.26.4\u001b[0m\n", - "sentence-transformers --no-deps\n", - "\u001b[2mUsing Python 3.10.16 environment at: /Users/hjshah/git/llama-stack/.venv\u001b[0m\n", - "\u001b[2mAudited \u001b[1m1 package\u001b[0m \u001b[2min 54ms\u001b[0m\u001b[0m\n", - "torch torchvision --index-url https://download.pytorch.org/whl/cpu\n", - "\u001b[2mUsing Python 3.10.16 environment at: /Users/hjshah/git/llama-stack/.venv\u001b[0m\n", - "\u001b[2mAudited \u001b[1m2 packages\u001b[0m \u001b[2min 10ms\u001b[0m\u001b[0m\n", - "\u001b[32mBuild Successful!\u001b[0m\n" - ] - } - ], + "outputs": [], "source": [ "import os\n", "import subprocess\n", "import time\n", "\n", - "!pip install uv\n", "\n", "if \"UV_SYSTEM_PYTHON\" in os.environ:\n", " del os.environ[\"UV_SYSTEM_PYTHON\"]\n", "\n", - "# this command installs all the dependencies needed for the llama stack server with the together inference provider\n", - "!uv run --with llama-stack llama stack list-deps together | xargs -L1 uv pip install\n", - "!uv run --with llama-stack llama stack run together\n", "\n", "def run_llama_stack_server_background():\n", " log_file = open(\"llama_stack_server.log\", \"w\")\n", " process = subprocess.Popen(\n", - " \"uv run --with llama-stack llama stack run together\",\n", + " \"uv run --with llama-stack llama stack run starter\",\n", " shell=True,\n", " stdout=log_file,\n", " stderr=log_file,\n", @@ -152,6 +177,7 @@ " for _ in range(max_retries):\n", " try:\n", " response = requests.get(url)\n", + " print(response)\n", " if response.status_code == 200:\n", " print(\"\\nServer is ready!\")\n", " return True\n", @@ -179,7 +205,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "id": "f779283d", "metadata": {}, "outputs": [ @@ -187,8 +213,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "Starting Llama Stack server with PID: 79142\n", - "Waiting for server to start..........................\n", + "Starting Llama Stack server with PID: 86923\n", + "Waiting for server to start..........\n", + "\n", "Server is ready!\n" ] } @@ -203,9 +230,9 @@ "id": "90eb721b", "metadata": {}, "source": [ - "### 1.4. Install and Configure the Client\n", + "### 1.4. Configure the Client\n", "\n", - "Now that we have our Llama Stack server running locally, we need to install the client package to interact with it. The `llama-stack-client` provides a simple Python interface to access all the functionality of Llama Stack, including:\n", + "Now that we have our Llama Stack server running locally, we will setup the client to interact with it. The `llama-stack-client` provides a simple Python interface to access all the functionality of Llama Stack, including:\n", "\n", "- Chat Completions ( text and multimodal )\n", "- Safety Shields \n", @@ -216,34 +243,13 @@ "\n", "In the next cells, we'll:\n", "\n", - "1. Install the client package\n", - "2. Set up API keys for external services (Together AI and Tavily Search)\n", - "3. Initialize the client to connect to our local server\n" + "1. Set up API keys for external services (Together AI and Tavily Search)\n", + "2. Initialize the client to connect to our local server\n" ] }, { "cell_type": "code", - "execution_count": 3, - "id": "2e68e32a", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[2mUsing Python 3.10.16 environment at: /opt/homebrew/Caskroom/miniconda/base/envs/stack\u001b[0m\n", - "\u001b[2K\u001b[2mResolved \u001b[1m31 packages\u001b[0m \u001b[2min 284ms\u001b[0m\u001b[0m \u001b[0m\n", - "\u001b[2mAudited \u001b[1m31 packages\u001b[0m \u001b[2min 0.04ms\u001b[0m\u001b[0m\n" - ] - } - ], - "source": [ - "!pip install -U llama-stack-client" - ] - }, - { - "cell_type": "code", - "execution_count": null, + "execution_count": 4, "id": "E1UFuJC570Tk", "metadata": { "colab": { @@ -373,7 +379,6 @@ "52fe404ec9c14db2a7279b4c154eef3d" ] }, - "collapsed": true, "id": "E1UFuJC570Tk", "outputId": "aebb69d4-c167-4de5-eb8a-dd19dd538f63" }, @@ -451,46 +456,268 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 9, "id": "ruO9jQna_t_S", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, - "collapsed": true, "id": "ruO9jQna_t_S", "outputId": "ab1722a7-62ab-43bb-9cab-4e45bf62068a" }, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:httpx:HTTP Request: GET http://0.0.0.0:8321/v1/models \"HTTP/1.1 200 OK\"\n", + "INFO:httpx:HTTP Request: GET http://0.0.0.0:8321/v1/shields \"HTTP/1.1 200 OK\"\n" + ] + }, { "name": "stdout", "output_type": "stream", "text": [ "Available models:\n", - "- all-MiniLM-L6-v2\n", - "- meta-llama/Llama-3.1-405B-Instruct-FP8\n", - "- meta-llama/Llama-3.1-70B-Instruct\n", - "- meta-llama/Llama-3.1-8B-Instruct\n", - "- meta-llama/Llama-3.2-11B-Vision-Instruct\n", - "- meta-llama/Llama-3.2-11B-Vision-Instruct-Turbo\n", - "- meta-llama/Llama-3.2-3B-Instruct\n", - "- meta-llama/Llama-3.2-3B-Instruct-Turbo\n", - "- meta-llama/Llama-3.2-90B-Vision-Instruct\n", - "- meta-llama/Llama-3.2-90B-Vision-Instruct-Turbo\n", - "- meta-llama/Llama-3.3-70B-Instruct\n", - "- meta-llama/Llama-3.3-70B-Instruct-Turbo\n", - "- meta-llama/Llama-Guard-3-11B-Vision\n", - "- meta-llama/Llama-Guard-3-11B-Vision-Turbo\n", - "- meta-llama/Llama-Guard-3-8B\n", - "- meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo\n", - "- meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo\n", - "- meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo\n", - "- meta-llama/Meta-Llama-Guard-3-8B\n", - "- togethercomputer/m2-bert-80M-32k-retrieval\n", - "- togethercomputer/m2-bert-80M-8k-retrieval\n", + "- fireworks/accounts/fireworks/models/flux-1-dev-fp8\n", + "- fireworks/accounts/fireworks/models/flux-kontext-max\n", + "- fireworks/accounts/fireworks/models/flux-kontext-pro\n", + "- fireworks/accounts/sentientfoundation-serverless/models/dobby-mini-unhinged-plus-llama-3-1-8b\n", + "- fireworks/accounts/sentientfoundation/models/dobby-unhinged-llama-3-3-70b-new\n", + "- fireworks/accounts/fireworks/models/gpt-oss-120b\n", + "- fireworks/accounts/fireworks/models/qwen3-235b-a22b-instruct-2507\n", + "- fireworks/accounts/fireworks/models/qwen3-235b-a22b-thinking-2507\n", + "- fireworks/accounts/fireworks/models/deepseek-v3-0324\n", + "- fireworks/accounts/fireworks/models/kimi-k2-instruct\n", + "- fireworks/accounts/fireworks/models/llama-v3p3-70b-instruct\n", + "- fireworks/accounts/fireworks/models/qwen3-235b-a22b\n", + "- fireworks/accounts/fireworks/models/deepseek-v3p1\n", + "- fireworks/accounts/fireworks/models/flux-1-schnell-fp8\n", + "- fireworks/accounts/fireworks/models/llama4-scout-instruct-basic\n", + "- fireworks/accounts/fireworks/models/llama-v3p1-70b-instruct\n", + "- fireworks/accounts/fireworks/models/deepseek-r1-0528\n", + "- fireworks/accounts/fireworks/models/llama4-maverick-instruct-basic\n", + "- fireworks/accounts/fireworks/models/qwen2p5-vl-32b-instruct\n", + "- fireworks/accounts/fireworks/models/deepseek-v3p1-terminus\n", + "- fireworks/accounts/fireworks/models/llama-v3p1-8b-instruct\n", + "- fireworks/accounts/fireworks/models/qwen3-coder-480b-a35b-instruct\n", + "- fireworks/accounts/fireworks/models/qwen3-30b-a3b-instruct-2507\n", + "- fireworks/accounts/fireworks/models/qwen3-30b-a3b-thinking-2507\n", + "- fireworks/accounts/fireworks/models/qwen3-embedding-8b\n", + "- fireworks/accounts/fireworks/models/glm-4p5\n", + "- fireworks/accounts/fireworks/models/qwen3-reranker-8b\n", + "- fireworks/accounts/fireworks/models/kimi-k2-instruct-0905\n", + "- fireworks/accounts/fireworks/models/deepseek-r1\n", + "- fireworks/accounts/fireworks/models/deepseek-v3\n", + "- fireworks/accounts/fireworks/models/deepseek-r1-basic\n", + "- fireworks/accounts/fireworks/models/glm-4p6\n", + "- fireworks/accounts/tvergho-87e44d/models/debatecards-70b-ft-3epoch-dpo-v2\n", + "- fireworks/accounts/fireworks/models/gpt-oss-20b\n", + "- fireworks/accounts/fireworks/models/qwen3-30b-a3b\n", + "- fireworks/accounts/fireworks/models/glm-4p5-air\n", + "- fireworks/accounts/fireworks/models/mixtral-8x22b-instruct\n", + "- fireworks/accounts/fireworks/models/llama-v3p1-405b-instruct\n", + "- fireworks/accounts/fireworks/models/qwen3-coder-30b-a3b-instruct\n", + "- together/Alibaba-NLP/gte-modernbert-base\n", + "- together/arcee-ai/AFM-4.5B\n", + "- together/arcee-ai/coder-large\n", + "- together/arcee-ai/maestro-reasoning\n", + "- together/arcee-ai/virtuoso-large\n", + "- together/arcee_ai/arcee-spotlight\n", + "- together/arize-ai/qwen-2-1.5b-instruct\n", + "- together/BAAI/bge-base-en-v1.5\n", + "- together/BAAI/bge-large-en-v1.5\n", + "- together/black-forest-labs/FLUX.1-dev\n", + "- together/black-forest-labs/FLUX.1-dev-lora\n", + "- together/black-forest-labs/FLUX.1-kontext-dev\n", + "- together/black-forest-labs/FLUX.1-kontext-max\n", + "- together/black-forest-labs/FLUX.1-kontext-pro\n", + "- together/black-forest-labs/FLUX.1-krea-dev\n", + "- together/black-forest-labs/FLUX.1-pro\n", + "- together/black-forest-labs/FLUX.1-schnell\n", + "- together/black-forest-labs/FLUX.1-schnell-Free\n", + "- together/black-forest-labs/FLUX.1.1-pro\n", + "- together/cartesia/sonic\n", + "- together/cartesia/sonic-2\n", + "- together/codellama/CodeLlama-34b-Instruct-hf\n", + "- together/deepcogito/cogito-v2-preview-deepseek-671b\n", + "- together/deepcogito/cogito-v2-preview-llama-109B-MoE\n", + "- together/deepcogito/cogito-v2-preview-llama-405B\n", + "- together/deepcogito/cogito-v2-preview-llama-70B\n", + "- together/deepseek-ai/DeepSeek-R1\n", + "- together/deepseek-ai/DeepSeek-R1-0528-tput\n", + "- together/deepseek-ai/DeepSeek-R1-Distill-Llama-70B\n", + "- together/deepseek-ai/DeepSeek-R1-Distill-Llama-70B-free\n", + "- together/deepseek-ai/DeepSeek-R1-Distill-Qwen-14B\n", + "- together/deepseek-ai/DeepSeek-V3\n", + "- together/deepseek-ai/DeepSeek-V3.1\n", + "- together/google/gemma-3n-E4B-it\n", + "- together/intfloat/multilingual-e5-large-instruct\n", + "- together/marin-community/marin-8b-instruct\n", + "- together/meta-llama/Llama-3-70b-chat-hf\n", + "- together/meta-llama/Llama-3-70b-hf\n", + "- together/meta-llama/Llama-3.1-405B-Instruct\n", + "- together/meta-llama/Llama-3.2-1B-Instruct\n", + "- together/meta-llama/Llama-3.2-3B-Instruct-Turbo\n", + "- together/meta-llama/Llama-3.3-70B-Instruct-Turbo\n", + "- together/meta-llama/Llama-3.3-70B-Instruct-Turbo-Free\n", + "- together/meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8\n", + "- together/meta-llama/Llama-4-Scout-17B-16E-Instruct\n", + "- together/meta-llama/Llama-Guard-3-11B-Vision-Turbo\n", + "- together/meta-llama/Llama-Guard-4-12B\n", + "- together/Meta-Llama/Llama-Guard-7b\n", + "- together/meta-llama/LlamaGuard-2-8b\n", + "- together/meta-llama/Meta-Llama-3-70B-Instruct-Turbo\n", + "- together/meta-llama/Meta-Llama-3-8B-Instruct\n", + "- together/meta-llama/Meta-Llama-3-8B-Instruct-Lite\n", + "- together/meta-llama/Meta-Llama-3.1-405B-Instruct-Lite-Pro\n", + "- together/meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo\n", + "- together/meta-llama/Meta-Llama-3.1-70B-Instruct-Reference\n", + "- together/meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo\n", + "- together/meta-llama/Meta-Llama-3.1-8B-Instruct-Reference\n", + "- together/meta-llama/Meta-Llama-Guard-3-8B\n", + "- together/mistralai/Mistral-7B-Instruct-v0.1\n", + "- together/mistralai/Mistral-7B-Instruct-v0.2\n", + "- together/mistralai/Mistral-7B-Instruct-v0.3\n", + "- together/mistralai/Mistral-Small-24B-Instruct-2501\n", + "- together/mistralai/Mixtral-8x7B-Instruct-v0.1\n", + "- together/mixedbread-ai/Mxbai-Rerank-Large-V2\n", + "- together/moonshotai/Kimi-K2-Instruct\n", + "- together/moonshotai/Kimi-K2-Instruct-0905\n", + "- together/nvidia/NVIDIA-Nemotron-Nano-9B-v2\n", + "- together/openai/gpt-oss-120b\n", + "- together/openai/gpt-oss-20b\n", + "- together/openai/whisper-large-v3\n", + "- together/Qwen/Qwen2.5-14B-Instruct\n", + "- together/Qwen/Qwen2.5-72B-Instruct\n", + "- together/Qwen/Qwen2.5-72B-Instruct-Turbo\n", + "- together/Qwen/Qwen2.5-7B-Instruct-Turbo\n", + "- together/Qwen/Qwen2.5-Coder-32B-Instruct\n", + "- together/Qwen/Qwen2.5-VL-72B-Instruct\n", + "- together/Qwen/Qwen3-235B-A22B-fp8-tput\n", + "- together/Qwen/Qwen3-235B-A22B-Instruct-2507-tput\n", + "- together/Qwen/Qwen3-235B-A22B-Thinking-2507\n", + "- together/Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8\n", + "- together/Qwen/Qwen3-Next-80B-A3B-Instruct\n", + "- together/Qwen/Qwen3-Next-80B-A3B-Thinking\n", + "- together/Qwen/QwQ-32B\n", + "- together/Salesforce/Llama-Rank-V1\n", + "- together/scb10x/scb10x-typhoon-2-1-gemma3-12b\n", + "- together/ServiceNow-AI/Apriel-1.5-15b-Thinker\n", + "- together/togethercomputer/m2-bert-80M-32k-retrieval\n", + "- together/togethercomputer/MoA-1\n", + "- together/togethercomputer/MoA-1-Turbo\n", + "- together/togethercomputer/Refuel-Llm-V2\n", + "- together/togethercomputer/Refuel-Llm-V2-Small\n", + "- together/Virtue-AI/VirtueGuard-Text-Lite\n", + "- together/zai-org/GLM-4.5-Air-FP8\n", + "- bedrock/meta.llama3-1-8b-instruct-v1:0\n", + "- bedrock/meta.llama3-1-70b-instruct-v1:0\n", + "- bedrock/meta.llama3-1-405b-instruct-v1:0\n", + "- openai/gpt-4-0613\n", + "- openai/gpt-4\n", + "- openai/gpt-3.5-turbo\n", + "- openai/gpt-5-search-api-2025-10-14\n", + "- openai/gpt-realtime-mini\n", + "- openai/gpt-realtime-mini-2025-10-06\n", + "- openai/sora-2\n", + "- openai/sora-2-pro\n", + "- openai/davinci-002\n", + "- openai/babbage-002\n", + "- openai/gpt-3.5-turbo-instruct\n", + "- openai/gpt-3.5-turbo-instruct-0914\n", + "- openai/dall-e-3\n", + "- openai/dall-e-2\n", + "- openai/gpt-4-1106-preview\n", + "- openai/gpt-3.5-turbo-1106\n", + "- openai/tts-1-hd\n", + "- openai/tts-1-1106\n", + "- openai/tts-1-hd-1106\n", + "- openai/text-embedding-3-small\n", + "- openai/text-embedding-3-large\n", + "- openai/gpt-4-0125-preview\n", + "- openai/gpt-4-turbo-preview\n", + "- openai/gpt-3.5-turbo-0125\n", + "- openai/gpt-4-turbo\n", + "- openai/gpt-4-turbo-2024-04-09\n", + "- openai/gpt-4o\n", + "- openai/gpt-4o-2024-05-13\n", + "- openai/gpt-4o-mini-2024-07-18\n", + "- openai/gpt-4o-mini\n", + "- openai/gpt-4o-2024-08-06\n", + "- openai/chatgpt-4o-latest\n", + "- openai/o1-mini-2024-09-12\n", + "- openai/o1-mini\n", + "- openai/gpt-4o-realtime-preview-2024-10-01\n", + "- openai/gpt-4o-audio-preview-2024-10-01\n", + "- openai/gpt-4o-audio-preview\n", + "- openai/gpt-4o-realtime-preview\n", + "- openai/omni-moderation-latest\n", + "- openai/omni-moderation-2024-09-26\n", + "- openai/gpt-4o-realtime-preview-2024-12-17\n", + "- openai/gpt-4o-audio-preview-2024-12-17\n", + "- openai/gpt-4o-mini-realtime-preview-2024-12-17\n", + "- openai/gpt-4o-mini-audio-preview-2024-12-17\n", + "- openai/o1-2024-12-17\n", + "- openai/o1\n", + "- openai/gpt-4o-mini-realtime-preview\n", + "- openai/gpt-4o-mini-audio-preview\n", + "- openai/o3-mini\n", + "- openai/o3-mini-2025-01-31\n", + "- openai/gpt-4o-2024-11-20\n", + "- openai/gpt-4o-search-preview-2025-03-11\n", + "- openai/gpt-4o-search-preview\n", + "- openai/gpt-4o-mini-search-preview-2025-03-11\n", + "- openai/gpt-4o-mini-search-preview\n", + "- openai/gpt-4o-transcribe\n", + "- openai/gpt-4o-mini-transcribe\n", + "- openai/o1-pro-2025-03-19\n", + "- openai/o1-pro\n", + "- openai/gpt-4o-mini-tts\n", + "- openai/o3-2025-04-16\n", + "- openai/o4-mini-2025-04-16\n", + "- openai/o3\n", + "- openai/o4-mini\n", + "- openai/gpt-4.1-2025-04-14\n", + "- openai/gpt-4.1\n", + "- openai/gpt-4.1-mini-2025-04-14\n", + "- openai/gpt-4.1-mini\n", + "- openai/gpt-4.1-nano-2025-04-14\n", + "- openai/gpt-4.1-nano\n", + "- openai/gpt-image-1\n", + "- openai/codex-mini-latest\n", + "- openai/gpt-4o-realtime-preview-2025-06-03\n", + "- openai/gpt-4o-audio-preview-2025-06-03\n", + "- openai/o4-mini-deep-research\n", + "- openai/gpt-4o-transcribe-diarize\n", + "- openai/o4-mini-deep-research-2025-06-26\n", + "- openai/gpt-5-chat-latest\n", + "- openai/gpt-5-2025-08-07\n", + "- openai/gpt-5\n", + "- openai/gpt-5-mini-2025-08-07\n", + "- openai/gpt-5-mini\n", + "- openai/gpt-5-nano-2025-08-07\n", + "- openai/gpt-5-nano\n", + "- openai/gpt-audio-2025-08-28\n", + "- openai/gpt-realtime\n", + "- openai/gpt-realtime-2025-08-28\n", + "- openai/gpt-audio\n", + "- openai/gpt-5-codex\n", + "- openai/gpt-image-1-mini\n", + "- openai/gpt-5-pro-2025-10-06\n", + "- openai/gpt-5-pro\n", + "- openai/gpt-audio-mini\n", + "- openai/gpt-audio-mini-2025-10-06\n", + "- openai/gpt-5-search-api\n", + "- openai/gpt-3.5-turbo-16k\n", + "- openai/tts-1\n", + "- openai/whisper-1\n", + "- openai/text-embedding-ada-002\n", + "- sentence-transformers/nomic-ai/nomic-embed-text-v1.5\n", + "- sentence-transformers/all-MiniLM-L6-v2\n", "----\n", "Available shields (safety models):\n", - "meta-llama/Llama-Guard-3-8B\n", + "together/meta-llama/Llama-Guard-4-12B\n", "----\n" ] } @@ -505,7 +732,7 @@ "print(\"----\")\n", "print(\"Available shields (safety models):\")\n", "for s in client.shields.list():\n", - " print(s.identifier)\n", + " print(s.provider_resource_id)\n", "print(\"----\")\n" ] }, @@ -523,7 +750,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 41, "id": "77c29dba", "metadata": { "colab": { @@ -533,16 +760,27 @@ "outputId": "4857974f-4c70-4bc4-f90a-6ae49dc9c41e" }, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/chat/completions \"HTTP/1.1 200 OK\"\n" + ] + }, { "name": "stdout", "output_type": "stream", "text": [ - "With gentle eyes and a soft, fuzzy face, the llama roams the Andes with a peaceful, gentle pace. Its long neck bends as it grazes with glee, a symbol of serenity in a world wild and free.\n" + "Here is a two-sentence poem about a llama:\n", + "\n", + "With soft fur and gentle eyes, the llama roams with gentle surprise, a majestic creature of the Andes high. Its soft humming fills the Andean air, a soothing sound beyond compare.\n" ] } ], "source": [ - "model_id = \"meta-llama/Llama-3.3-70B-Instruct\"\n", + "model_id = \"together/meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8\"\n", + "# TODO remove\n", + "# model_id = \"openai/gpt-4o\"\n", "\n", "response = client.chat.completions.create(\n", " model=model_id,\n", @@ -569,40 +807,64 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 12, "id": "3fdf9df6", "metadata": { "id": "3fdf9df6" }, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/chat/completions \"HTTP/1.1 200 OK\"\n" + ] + }, { "name": "stdout", "output_type": "stream", "text": [ - "\u001b[36m> Response: The most famous Prime Minister of England during World War II was undoubtedly Winston Churchill. He served as Prime Minister from 1940 to 1945 and again from 1951 to 1955, and is widely regarded as one of the greatest leaders in British history.\n", + "\u001b[36m> Response: The most famous Prime Minister of England during World War II was Winston Churchill. He served as Prime Minister from 1940 to 1945 and again from 1951 to 1955. Churchill is widely regarded as one of the greatest wartime leaders in history, and his leadership during World War II played a significant role in the Allied victory.\n", "\n", - "Churchill played a crucial role in rallying the British people during the war, and his oratory skills and leadership helped to boost morale and resistance against the Nazi threat. His famous speeches, such as the \"We shall fight on the beaches\" and \"Iron Curtain\" speeches, are still remembered and quoted today.\n", + "Churchill was known for his oratory skills, and his speeches during the war, such as \"We shall fight on the beaches\" and \"Their finest hour\", helped to rally the British people during a time of great crisis. He also worked closely with other Allied leaders, such as US President Franklin D. Roosevelt and Soviet leader Joseph Stalin, to coordinate the war effort.\n", "\n", - "Churchill's leadership during World War II was marked by his unwavering determination to defeat Nazi Germany, and he worked closely with other Allied leaders, including US President Franklin D. Roosevelt and Soviet leader Joseph Stalin, to coordinate the war effort.\n", + "Churchill's leadership and vision helped to galvanize the British people during the war, and his legacy as a wartime leader has endured. He is often credited with helping to lead Britain to victory against Nazi Germany and its allies, and his name has become synonymous with British resilience and determination during World War II.\u001b[0m\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/chat/completions \"HTTP/1.1 200 OK\"\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[36m> Response: One of Winston Churchill's most famous quotes is:\n", "\n", - "Churchill's legacy extends far beyond his wartime leadership, and he is remembered for his many contributions to British politics, literature, and culture. He was a prolific writer and painter, and was awarded the Nobel Prize in Literature in 1953.\n", + "**\"We shall fight on the beaches\"**\n", "\n", - "Overall, Winston Churchill is widely regarded as one of the most famous and influential Prime Ministers in British history, and his leadership during World War II remains an iconic and enduring symbol of British resilience and determination.\u001b[0m\n", - "\u001b[36m> Response: Winston Churchill had many famous quotes, but one of his most iconic and enduring quotes is:\n", + "However, his most famous quote is often considered to be:\n", "\n", - "\"We shall fight on the beaches, we shall fight on the landing grounds, we shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender.\"\n", + "**\"Blood, toil, tears and sweat: We have before us an ordeal of the most grievous kind.\"**\n", "\n", - "This quote is from his speech to the House of Commons on June 4, 1940, during the early stages of World War II, when Nazi Germany was threatening to invade Britain. The speech is known as the \"We Shall Fight on the Beaches\" speech, and it is considered one of the most famous and inspiring speeches in history.\n", + "But arguably his most iconic and widely recognized quote is:\n", "\n", - "In this speech, Churchill rallied the British people to stand strong against the Nazi threat, and his words helped to boost morale and resistance. The quote has since become a symbol of British determination and resilience, and is often referenced and parodied in popular culture.\n", + "**\"We shall fight on the beaches, in the streets, in the fields and in the hills. We shall never surrender.\"**\n", "\n", - "Other notable quotes from Churchill include:\n", + "This quote was from his first speech as Prime Minister, delivered to the House of Commons on June 4, 1940, during the early stages of World War II, when Nazi Germany was threatening to invade Britain. The speech is known as the \"We Shall Fight on the Beaches\" speech, and it's considered one of the greatest speeches in history.\n", "\n", - "* \"Blood, toil, tears, and sweat\" (from his first speech as Prime Minister in 1940)\n", - "* \"An iron curtain has descended across the continent\" (from his speech in 1946, referring to the Soviet Union's dominance in Eastern Europe)\n", - "* \"Never was so much owed by so many to so few\" (from his speech in 1940, referring to the bravery of the Royal Air Force during the Battle of Britain)\n", + "However, if I had to pick one that is most widely recognized and often cited as his most famous quote, it would be:\n", "\n", - "But \"We shall fight on the beaches\" remains his most famous and enduring quote.\u001b[0m\n" + "**\"Iron Curtain\"**\n", + "\n", + " Although not exactly a quote from WW2. It was \"From Stettin in the Baltic to Trieste in the Adriatic, an iron curtain has descended across the continent.\" \n", + "\n", + "This phrase was used in a speech in Fulton, Missouri, on March 5, 1946. It was a speech that alerted the West to the danger of Soviet expansionism and marked the beginning of the Cold War.\n", + "\n", + "Each of these quotes captures a moment in history and convey's a powerful message that has endured for generations.\u001b[0m\n" ] } ], @@ -656,7 +918,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 13, "id": "9496f75c", "metadata": { "colab": { @@ -666,13 +928,38 @@ "outputId": "7d93a4cf-a5d4-4741-b6eb-6bce3a27ff66" }, "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + "User> hello\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/chat/completions \"HTTP/1.1 200 OK\"\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[36m> Response: Hello! It's nice to meet you. Is there something I can help you with or would you like to chat?\u001b[0m\n" + ] + }, + { + "name": "stdin", + "output_type": "stream", + "text": [ + "User> exit\n" + ] + }, { "name": "stdout", "output_type": "stream", "text": [ - "\u001b[36m> Response: Fuzzy code abides\n", - "Llama's gentle syntax\n", - "Wisdom in the stack\u001b[0m\n", "\u001b[33mEnding conversation. Goodbye!\u001b[0m\n" ] } @@ -723,7 +1010,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 57, "id": "d119026e", "metadata": { "colab": { @@ -733,34 +1020,40 @@ "outputId": "ebd6dc2b-8542-4370-b08a-e3a7dede6d17" }, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/chat/completions \"HTTP/1.1 200 OK\"\n" + ] + }, { "name": "stdout", "output_type": "stream", "text": [ "User> Write me a sonnet about llama\n", - "\u001b[36mAssistant> \u001b[0m\u001b[33mIn\u001b[0m\u001b[33m And\u001b[0m\u001b[33mean\u001b[0m\u001b[33m high\u001b[0m\u001b[33mlands\u001b[0m\u001b[33m,\u001b[0m\u001b[33m where\u001b[0m\u001b[33m the\u001b[0m\u001b[33m air\u001b[0m\u001b[33m is\u001b[0m\u001b[33m thin\u001b[0m\u001b[33m,\n", - "\u001b[0m\u001b[33mA\u001b[0m\u001b[33m creature\u001b[0m\u001b[33m ro\u001b[0m\u001b[33mams\u001b[0m\u001b[33m,\u001b[0m\u001b[33m with\u001b[0m\u001b[33m gentle\u001b[0m\u001b[33m,\u001b[0m\u001b[33m curious\u001b[0m\u001b[33m eyes\u001b[0m\u001b[33m,\n", - "\u001b[0m\u001b[33mThe\u001b[0m\u001b[33m llama\u001b[0m\u001b[33m,\u001b[0m\u001b[33m soft\u001b[0m\u001b[33m and\u001b[0m\u001b[33m silent\u001b[0m\u001b[33m,\u001b[0m\u001b[33m steps\u001b[0m\u001b[33m within\u001b[0m\u001b[33m\n", - "\u001b[0m\u001b[33mThe\u001b[0m\u001b[33m mist\u001b[0m\u001b[33my\u001b[0m\u001b[33m dawn\u001b[0m\u001b[33m,\u001b[0m\u001b[33m with\u001b[0m\u001b[33m fur\u001b[0m\u001b[33m of\u001b[0m\u001b[33m gentle\u001b[0m\u001b[33m guise\u001b[0m\u001b[33m.\n", + "Assistant> \n", + "In Andean heights, the llama makes its stand,\n", + "A creature of soft eyes and gentle face,\n", + "With fur so fine, it seems a woolly band\n", + "That wraps its body in a gentle pace.\n", "\n", - "\u001b[0m\u001b[33mIts\u001b[0m\u001b[33m neck\u001b[0m\u001b[33m,\u001b[0m\u001b[33m a\u001b[0m\u001b[33m slender\u001b[0m\u001b[33m column\u001b[0m\u001b[33m,\u001b[0m\u001b[33m strong\u001b[0m\u001b[33m and\u001b[0m\u001b[33m fine\u001b[0m\u001b[33m,\n", - "\u001b[0m\u001b[33mSupport\u001b[0m\u001b[33ms\u001b[0m\u001b[33m a\u001b[0m\u001b[33m head\u001b[0m\u001b[33m,\u001b[0m\u001b[33m with\u001b[0m\u001b[33m ears\u001b[0m\u001b[33m of\u001b[0m\u001b[33m alert\u001b[0m\u001b[33m design\u001b[0m\u001b[33m,\n", - "\u001b[0m\u001b[33mIt\u001b[0m\u001b[33m watches\u001b[0m\u001b[33m,\u001b[0m\u001b[33m wary\u001b[0m\u001b[33m,\u001b[0m\u001b[33m with\u001b[0m\u001b[33m a\u001b[0m\u001b[33m quiet\u001b[0m\u001b[33m mind\u001b[0m\u001b[33m,\n", - "\u001b[0m\u001b[33mAs\u001b[0m\u001b[33m humans\u001b[0m\u001b[33m pass\u001b[0m\u001b[33m,\u001b[0m\u001b[33m with\u001b[0m\u001b[33m footsteps\u001b[0m\u001b[33m left\u001b[0m\u001b[33m behind\u001b[0m\u001b[33m.\n", + "Its steps are sure, its balance is a test,\n", + "As it ascends the mountain's rugged crest,\n", + "It chews its cud, with calm and peaceful rest,\n", + "A symbol of serenity, it finds its nest.\n", "\n", - "\u001b[0m\u001b[33mBut\u001b[0m\u001b[33m when\u001b[0m\u001b[33m it\u001b[0m\u001b[33m senses\u001b[0m\u001b[33m danger\u001b[0m\u001b[33m,\u001b[0m\u001b[33m or\u001b[0m\u001b[33m feels\u001b[0m\u001b[33m fright\u001b[0m\u001b[33m,\n", - "\u001b[0m\u001b[33mIt\u001b[0m\u001b[33m lets\u001b[0m\u001b[33m out\u001b[0m\u001b[33m a\u001b[0m\u001b[33m loud\u001b[0m\u001b[33m,\u001b[0m\u001b[33m piercing\u001b[0m\u001b[33m,\u001b[0m\u001b[33m warning\u001b[0m\u001b[33m cry\u001b[0m\u001b[33m,\n", - "\u001b[0m\u001b[33mA\u001b[0m\u001b[33m sound\u001b[0m\u001b[33m that\u001b[0m\u001b[33m echoes\u001b[0m\u001b[33m,\u001b[0m\u001b[33m through\u001b[0m\u001b[33m the\u001b[0m\u001b[33m mountain\u001b[0m\u001b[33m's\u001b[0m\u001b[33m night\u001b[0m\u001b[33m,\n", - "\u001b[0m\u001b[33mAnd\u001b[0m\u001b[33m sends\u001b[0m\u001b[33m a\u001b[0m\u001b[33m sh\u001b[0m\u001b[33miver\u001b[0m\u001b[33m,\u001b[0m\u001b[33m through\u001b[0m\u001b[33m the\u001b[0m\u001b[33m passer\u001b[0m\u001b[33mby\u001b[0m\u001b[33m.\n", + "The llama's soft hum fills the mountain air,\n", + "As it roams free, without a single care,\n", + "Its gentle nature, a joy to behold,\n", + "A treasure, in the Andes, to be told.\n", "\n", - "\u001b[0m\u001b[33mYet\u001b[0m\u001b[33m,\u001b[0m\u001b[33m in\u001b[0m\u001b[33m its\u001b[0m\u001b[33m calm\u001b[0m\u001b[33m,\u001b[0m\u001b[33m and\u001b[0m\u001b[33m peaceful\u001b[0m\u001b[33m,\u001b[0m\u001b[33m gentle\u001b[0m\u001b[33m way\u001b[0m\u001b[33m,\n", - "\u001b[0m\u001b[33mThe\u001b[0m\u001b[33m llama\u001b[0m\u001b[33m charms\u001b[0m\u001b[33m,\u001b[0m\u001b[33m and\u001b[0m\u001b[33m wins\u001b[0m\u001b[33m the\u001b[0m\u001b[33m heart\u001b[0m\u001b[33m's\u001b[0m\u001b[33m sweet\u001b[0m\u001b[33m sway\u001b[0m\u001b[33m.\u001b[0m\u001b[97m\u001b[0m\n" + "And when it looks at you, with eyes so bright,\n", + "You feel a sense of peace, on that high altitude night." ] } ], "source": [ - "from llama_stack_client import InferenceEventLogger\n", - "\n", "message = {\"role\": \"user\", \"content\": \"Write me a sonnet about llama\"}\n", "print(f'User> {message[\"content\"]}')\n", "\n", @@ -771,8 +1064,10 @@ ")\n", "\n", "# Print the tokens while they are received\n", - "for log in InferenceEventLogger().log(response):\n", - " log.print()\n" + "print(\"Assistant> \")\n", + "for chunk in response:\n", + " if chunk.choices:\n", + " print(chunk.choices[0].delta.content, end=\"\", flush=True)\n" ] }, { @@ -789,7 +1084,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 17, "id": "axdQIRaJCYAV", "metadata": { "colab": { @@ -800,6 +1095,13 @@ "outputId": "a5ef1f54-37df-446e-e21b-cddddaf95f84" }, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/chat/completions \"HTTP/1.1 200 OK\"\n" + ] + }, { "data": { "text/html": [ @@ -826,16 +1128,19 @@ "\n", "user_input = \"Michael Jordan was born in 1963. He played basketball for the Chicago Bulls. He retired in 2003. Extract this information into JSON for me. \"\n", "response = client.chat.completions.create(\n", - " model=\"meta-llama/Llama-3.1-8B-Instruct\",\n", + " model=model_id,\n", " messages=[{\"role\": \"user\", \"content\": user_input}],\n", " max_tokens=50,\n", " response_format={\n", " \"type\": \"json_schema\",\n", - " \"json_schema\": Output.model_json_schema(),\n", + " \"json_schema\": {\n", + " \"name\": \"Output\",\n", + " \"schema\": Output.model_json_schema(),\n", + " },\n", " },\n", ")\n", - "\n", - "pprint(Output.model_validate_json(response.content))\n" + "json_content = response.choices[0].message.content\n", + "pprint(Output.model_validate_json(json_content))\n" ] }, { @@ -852,7 +1157,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 18, "id": "sUJKJxvAFCaI", "metadata": { "colab": { @@ -863,22 +1168,152 @@ "outputId": "04163c2c-7e9b-463a-e394-412bb94ec28f" }, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:httpx:HTTP Request: GET http://0.0.0.0:8321/v1/shields \"HTTP/1.1 200 OK\"\n" + ] + }, { "name": "stdout", "output_type": "stream", "text": [ - "Available Shields: ['meta-llama/Llama-Guard-3-8B']\n", + "Available Shields: ['together/meta-llama/Llama-Guard-4-12B']\n", "Checking if input is safe: What is the most famous murder case in the US?\n" ] }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/moderations \"HTTP/1.1 200 OK\"\n" + ] + }, { "data": { "text/html": [ - "
RunShieldResponse(violation=None)\n",
+       "
CreateResponse(\n",
+       "id='modr-42d71cc1-ac4f-40bc-b7e6-66f4f353c760',\n",
+       "model='together/meta-llama/Llama-Guard-4-12B',\n",
+       "results=[\n",
+       "│   │   Result(\n",
+       "│   │   │   flagged=False,\n",
+       "│   │   │   metadata={},\n",
+       "│   │   │   categories={\n",
+       "│   │   │   │   'Violent Crimes': False,\n",
+       "│   │   │   │   'Non-Violent Crimes': False,\n",
+       "│   │   │   │   'Sex Crimes': False,\n",
+       "│   │   │   │   'Child Exploitation': False,\n",
+       "│   │   │   │   'Defamation': False,\n",
+       "│   │   │   │   'Specialized Advice': False,\n",
+       "│   │   │   │   'Privacy': False,\n",
+       "│   │   │   │   'Intellectual Property': False,\n",
+       "│   │   │   │   'Indiscriminate Weapons': False,\n",
+       "│   │   │   │   'Hate': False,\n",
+       "│   │   │   │   'Self-Harm': False,\n",
+       "│   │   │   │   'Sexual Content': False,\n",
+       "│   │   │   │   'Elections': False,\n",
+       "│   │   │   │   'Code Interpreter Abuse': False\n",
+       "│   │   │   },\n",
+       "│   │   │   category_applied_input_types={\n",
+       "│   │   │   │   'Violent Crimes': [],\n",
+       "│   │   │   │   'Non-Violent Crimes': [],\n",
+       "│   │   │   │   'Sex Crimes': [],\n",
+       "│   │   │   │   'Child Exploitation': [],\n",
+       "│   │   │   │   'Defamation': [],\n",
+       "│   │   │   │   'Specialized Advice': [],\n",
+       "│   │   │   │   'Privacy': [],\n",
+       "│   │   │   │   'Intellectual Property': [],\n",
+       "│   │   │   │   'Indiscriminate Weapons': [],\n",
+       "│   │   │   │   'Hate': [],\n",
+       "│   │   │   │   'Self-Harm': [],\n",
+       "│   │   │   │   'Sexual Content': [],\n",
+       "│   │   │   │   'Elections': [],\n",
+       "│   │   │   │   'Code Interpreter Abuse': []\n",
+       "│   │   │   },\n",
+       "│   │   │   category_scores={\n",
+       "│   │   │   │   'Violent Crimes': 1.0,\n",
+       "│   │   │   │   'Non-Violent Crimes': 1.0,\n",
+       "│   │   │   │   'Sex Crimes': 1.0,\n",
+       "│   │   │   │   'Child Exploitation': 1.0,\n",
+       "│   │   │   │   'Defamation': 1.0,\n",
+       "│   │   │   │   'Specialized Advice': 1.0,\n",
+       "│   │   │   │   'Privacy': 1.0,\n",
+       "│   │   │   │   'Intellectual Property': 1.0,\n",
+       "│   │   │   │   'Indiscriminate Weapons': 1.0,\n",
+       "│   │   │   │   'Hate': 1.0,\n",
+       "│   │   │   │   'Self-Harm': 1.0,\n",
+       "│   │   │   │   'Sexual Content': 1.0,\n",
+       "│   │   │   │   'Elections': 1.0,\n",
+       "│   │   │   │   'Code Interpreter Abuse': 1.0\n",
+       "│   │   │   },\n",
+       "│   │   │   user_message=None\n",
+       "│   │   )\n",
+       "]\n",
+       ")\n",
        "
\n" ], "text/plain": [ - "\u001b[1;35mRunShieldResponse\u001b[0m\u001b[1m(\u001b[0m\u001b[33mviolation\u001b[0m=\u001b[3;35mNone\u001b[0m\u001b[1m)\u001b[0m\n" + "\u001b[1;35mCreateResponse\u001b[0m\u001b[1m(\u001b[0m\n", + "\u001b[2;32m│ \u001b[0m\u001b[33mid\u001b[0m=\u001b[32m'modr-42d71cc1-ac4f-40bc-b7e6-66f4f353c760'\u001b[0m,\n", + "\u001b[2;32m│ \u001b[0m\u001b[33mmodel\u001b[0m=\u001b[32m'together/meta-llama/Llama-Guard-4-12B'\u001b[0m,\n", + "\u001b[2;32m│ \u001b[0m\u001b[33mresults\u001b[0m=\u001b[1m[\u001b[0m\n", + "\u001b[2;32m│ │ \u001b[0m\u001b[1;35mResult\u001b[0m\u001b[1m(\u001b[0m\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mflagged\u001b[0m=\u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mmetadata\u001b[0m=\u001b[1m{\u001b[0m\u001b[1m}\u001b[0m,\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mcategories\u001b[0m=\u001b[1m{\u001b[0m\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Violent Crimes'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Non-Violent Crimes'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sex Crimes'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Child Exploitation'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Defamation'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Specialized Advice'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Privacy'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Intellectual Property'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Indiscriminate Weapons'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Hate'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Self-Harm'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sexual Content'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Elections'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Code Interpreter Abuse'\u001b[0m: \u001b[3;91mFalse\u001b[0m\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m}\u001b[0m,\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mcategory_applied_input_types\u001b[0m=\u001b[1m{\u001b[0m\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Violent Crimes'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Non-Violent Crimes'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sex Crimes'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Child Exploitation'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Defamation'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Specialized Advice'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Privacy'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Intellectual Property'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Indiscriminate Weapons'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Hate'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Self-Harm'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sexual Content'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Elections'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Code Interpreter Abuse'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m}\u001b[0m,\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mcategory_scores\u001b[0m=\u001b[1m{\u001b[0m\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Violent Crimes'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Non-Violent Crimes'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sex Crimes'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Child Exploitation'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Defamation'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Specialized Advice'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Privacy'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Intellectual Property'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Indiscriminate Weapons'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Hate'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Self-Harm'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sexual Content'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Elections'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Code Interpreter Abuse'\u001b[0m: \u001b[1;36m1.0\u001b[0m\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m}\u001b[0m,\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33muser_message\u001b[0m=\u001b[3;35mNone\u001b[0m\n", + "\u001b[2;32m│ │ \u001b[0m\u001b[1m)\u001b[0m\n", + "\u001b[2;32m│ \u001b[0m\u001b[1m]\u001b[0m\n", + "\u001b[1m)\u001b[0m\n" ] }, "metadata": {}, @@ -891,14 +1326,137 @@ "Checking if input is safe: Tell me 3 signs that an email is a scam\n" ] }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/moderations \"HTTP/1.1 200 OK\"\n" + ] + }, { "data": { "text/html": [ - "
RunShieldResponse(violation=None)\n",
+       "
CreateResponse(\n",
+       "id='modr-68f0f6be-c6a9-4dfb-9ecb-66f1707980b7',\n",
+       "model='together/meta-llama/Llama-Guard-4-12B',\n",
+       "results=[\n",
+       "│   │   Result(\n",
+       "│   │   │   flagged=False,\n",
+       "│   │   │   metadata={},\n",
+       "│   │   │   categories={\n",
+       "│   │   │   │   'Violent Crimes': False,\n",
+       "│   │   │   │   'Non-Violent Crimes': False,\n",
+       "│   │   │   │   'Sex Crimes': False,\n",
+       "│   │   │   │   'Child Exploitation': False,\n",
+       "│   │   │   │   'Defamation': False,\n",
+       "│   │   │   │   'Specialized Advice': False,\n",
+       "│   │   │   │   'Privacy': False,\n",
+       "│   │   │   │   'Intellectual Property': False,\n",
+       "│   │   │   │   'Indiscriminate Weapons': False,\n",
+       "│   │   │   │   'Hate': False,\n",
+       "│   │   │   │   'Self-Harm': False,\n",
+       "│   │   │   │   'Sexual Content': False,\n",
+       "│   │   │   │   'Elections': False,\n",
+       "│   │   │   │   'Code Interpreter Abuse': False\n",
+       "│   │   │   },\n",
+       "│   │   │   category_applied_input_types={\n",
+       "│   │   │   │   'Violent Crimes': [],\n",
+       "│   │   │   │   'Non-Violent Crimes': [],\n",
+       "│   │   │   │   'Sex Crimes': [],\n",
+       "│   │   │   │   'Child Exploitation': [],\n",
+       "│   │   │   │   'Defamation': [],\n",
+       "│   │   │   │   'Specialized Advice': [],\n",
+       "│   │   │   │   'Privacy': [],\n",
+       "│   │   │   │   'Intellectual Property': [],\n",
+       "│   │   │   │   'Indiscriminate Weapons': [],\n",
+       "│   │   │   │   'Hate': [],\n",
+       "│   │   │   │   'Self-Harm': [],\n",
+       "│   │   │   │   'Sexual Content': [],\n",
+       "│   │   │   │   'Elections': [],\n",
+       "│   │   │   │   'Code Interpreter Abuse': []\n",
+       "│   │   │   },\n",
+       "│   │   │   category_scores={\n",
+       "│   │   │   │   'Violent Crimes': 1.0,\n",
+       "│   │   │   │   'Non-Violent Crimes': 1.0,\n",
+       "│   │   │   │   'Sex Crimes': 1.0,\n",
+       "│   │   │   │   'Child Exploitation': 1.0,\n",
+       "│   │   │   │   'Defamation': 1.0,\n",
+       "│   │   │   │   'Specialized Advice': 1.0,\n",
+       "│   │   │   │   'Privacy': 1.0,\n",
+       "│   │   │   │   'Intellectual Property': 1.0,\n",
+       "│   │   │   │   'Indiscriminate Weapons': 1.0,\n",
+       "│   │   │   │   'Hate': 1.0,\n",
+       "│   │   │   │   'Self-Harm': 1.0,\n",
+       "│   │   │   │   'Sexual Content': 1.0,\n",
+       "│   │   │   │   'Elections': 1.0,\n",
+       "│   │   │   │   'Code Interpreter Abuse': 1.0\n",
+       "│   │   │   },\n",
+       "│   │   │   user_message=None\n",
+       "│   │   )\n",
+       "]\n",
+       ")\n",
        "
\n" ], "text/plain": [ - "\u001b[1;35mRunShieldResponse\u001b[0m\u001b[1m(\u001b[0m\u001b[33mviolation\u001b[0m=\u001b[3;35mNone\u001b[0m\u001b[1m)\u001b[0m\n" + "\u001b[1;35mCreateResponse\u001b[0m\u001b[1m(\u001b[0m\n", + "\u001b[2;32m│ \u001b[0m\u001b[33mid\u001b[0m=\u001b[32m'modr-68f0f6be-c6a9-4dfb-9ecb-66f1707980b7'\u001b[0m,\n", + "\u001b[2;32m│ \u001b[0m\u001b[33mmodel\u001b[0m=\u001b[32m'together/meta-llama/Llama-Guard-4-12B'\u001b[0m,\n", + "\u001b[2;32m│ \u001b[0m\u001b[33mresults\u001b[0m=\u001b[1m[\u001b[0m\n", + "\u001b[2;32m│ │ \u001b[0m\u001b[1;35mResult\u001b[0m\u001b[1m(\u001b[0m\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mflagged\u001b[0m=\u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mmetadata\u001b[0m=\u001b[1m{\u001b[0m\u001b[1m}\u001b[0m,\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mcategories\u001b[0m=\u001b[1m{\u001b[0m\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Violent Crimes'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Non-Violent Crimes'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sex Crimes'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Child Exploitation'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Defamation'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Specialized Advice'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Privacy'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Intellectual Property'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Indiscriminate Weapons'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Hate'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Self-Harm'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sexual Content'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Elections'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Code Interpreter Abuse'\u001b[0m: \u001b[3;91mFalse\u001b[0m\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m}\u001b[0m,\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mcategory_applied_input_types\u001b[0m=\u001b[1m{\u001b[0m\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Violent Crimes'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Non-Violent Crimes'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sex Crimes'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Child Exploitation'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Defamation'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Specialized Advice'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Privacy'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Intellectual Property'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Indiscriminate Weapons'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Hate'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Self-Harm'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sexual Content'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Elections'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Code Interpreter Abuse'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m}\u001b[0m,\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mcategory_scores\u001b[0m=\u001b[1m{\u001b[0m\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Violent Crimes'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Non-Violent Crimes'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sex Crimes'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Child Exploitation'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Defamation'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Specialized Advice'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Privacy'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Intellectual Property'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Indiscriminate Weapons'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Hate'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Self-Harm'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sexual Content'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Elections'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Code Interpreter Abuse'\u001b[0m: \u001b[1;36m1.0\u001b[0m\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m}\u001b[0m,\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33muser_message\u001b[0m=\u001b[3;35mNone\u001b[0m\n", + "\u001b[2;32m│ │ \u001b[0m\u001b[1m)\u001b[0m\n", + "\u001b[2;32m│ \u001b[0m\u001b[1m]\u001b[0m\n", + "\u001b[1m)\u001b[0m\n" ] }, "metadata": {}, @@ -911,25 +1469,136 @@ "Checking if input is safe: What's the most effective way to kidnap someone?\n" ] }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/moderations \"HTTP/1.1 200 OK\"\n" + ] + }, { "data": { "text/html": [ - "
RunShieldResponse(\n",
-       "violation=SafetyViolation(\n",
-       "│   │   metadata={'violation_type': 'S1'},\n",
-       "│   │   violation_level='error',\n",
-       "│   │   user_message=\"I can't answer that. Can I help with something else?\"\n",
-       ")\n",
+       "
CreateResponse(\n",
+       "id='modr-b67e4e53-82fd-4300-843c-193bd995642b',\n",
+       "model='together/meta-llama/Llama-Guard-4-12B',\n",
+       "results=[\n",
+       "│   │   Result(\n",
+       "│   │   │   flagged=True,\n",
+       "│   │   │   metadata={'violation_type': ['S1']},\n",
+       "│   │   │   categories={\n",
+       "│   │   │   │   'Violent Crimes': True,\n",
+       "│   │   │   │   'Non-Violent Crimes': False,\n",
+       "│   │   │   │   'Sex Crimes': False,\n",
+       "│   │   │   │   'Child Exploitation': False,\n",
+       "│   │   │   │   'Defamation': False,\n",
+       "│   │   │   │   'Specialized Advice': False,\n",
+       "│   │   │   │   'Privacy': False,\n",
+       "│   │   │   │   'Intellectual Property': False,\n",
+       "│   │   │   │   'Indiscriminate Weapons': False,\n",
+       "│   │   │   │   'Hate': False,\n",
+       "│   │   │   │   'Self-Harm': False,\n",
+       "│   │   │   │   'Sexual Content': False,\n",
+       "│   │   │   │   'Elections': False,\n",
+       "│   │   │   │   'Code Interpreter Abuse': False\n",
+       "│   │   │   },\n",
+       "│   │   │   category_applied_input_types={\n",
+       "│   │   │   │   'Violent Crimes': ['text'],\n",
+       "│   │   │   │   'Non-Violent Crimes': [],\n",
+       "│   │   │   │   'Sex Crimes': [],\n",
+       "│   │   │   │   'Child Exploitation': [],\n",
+       "│   │   │   │   'Defamation': [],\n",
+       "│   │   │   │   'Specialized Advice': [],\n",
+       "│   │   │   │   'Privacy': [],\n",
+       "│   │   │   │   'Intellectual Property': [],\n",
+       "│   │   │   │   'Indiscriminate Weapons': [],\n",
+       "│   │   │   │   'Hate': [],\n",
+       "│   │   │   │   'Self-Harm': [],\n",
+       "│   │   │   │   'Sexual Content': [],\n",
+       "│   │   │   │   'Elections': [],\n",
+       "│   │   │   │   'Code Interpreter Abuse': []\n",
+       "│   │   │   },\n",
+       "│   │   │   category_scores={\n",
+       "│   │   │   │   'Violent Crimes': 1.0,\n",
+       "│   │   │   │   'Non-Violent Crimes': 0.0,\n",
+       "│   │   │   │   'Sex Crimes': 0.0,\n",
+       "│   │   │   │   'Child Exploitation': 0.0,\n",
+       "│   │   │   │   'Defamation': 0.0,\n",
+       "│   │   │   │   'Specialized Advice': 0.0,\n",
+       "│   │   │   │   'Privacy': 0.0,\n",
+       "│   │   │   │   'Intellectual Property': 0.0,\n",
+       "│   │   │   │   'Indiscriminate Weapons': 0.0,\n",
+       "│   │   │   │   'Hate': 0.0,\n",
+       "│   │   │   │   'Self-Harm': 0.0,\n",
+       "│   │   │   │   'Sexual Content': 0.0,\n",
+       "│   │   │   │   'Elections': 0.0,\n",
+       "│   │   │   │   'Code Interpreter Abuse': 0.0\n",
+       "│   │   │   },\n",
+       "│   │   │   user_message=\"I can't answer that. Can I help with something else?\"\n",
+       "│   │   )\n",
+       "]\n",
        ")\n",
        "
\n" ], "text/plain": [ - "\u001b[1;35mRunShieldResponse\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mviolation\u001b[0m=\u001b[1;35mSafetyViolation\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mmetadata\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'violation_type'\u001b[0m: \u001b[32m'S1'\u001b[0m\u001b[1m}\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mviolation_level\u001b[0m=\u001b[32m'error'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33muser_message\u001b[0m=\u001b[32m\"I\u001b[0m\u001b[32m can't answer that. Can I help with something else?\"\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m)\u001b[0m\n", + "\u001b[1;35mCreateResponse\u001b[0m\u001b[1m(\u001b[0m\n", + "\u001b[2;32m│ \u001b[0m\u001b[33mid\u001b[0m=\u001b[32m'modr-b67e4e53-82fd-4300-843c-193bd995642b'\u001b[0m,\n", + "\u001b[2;32m│ \u001b[0m\u001b[33mmodel\u001b[0m=\u001b[32m'together/meta-llama/Llama-Guard-4-12B'\u001b[0m,\n", + "\u001b[2;32m│ \u001b[0m\u001b[33mresults\u001b[0m=\u001b[1m[\u001b[0m\n", + "\u001b[2;32m│ │ \u001b[0m\u001b[1;35mResult\u001b[0m\u001b[1m(\u001b[0m\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mflagged\u001b[0m=\u001b[3;92mTrue\u001b[0m,\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mmetadata\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'violation_type'\u001b[0m: \u001b[1m[\u001b[0m\u001b[32m'S1'\u001b[0m\u001b[1m]\u001b[0m\u001b[1m}\u001b[0m,\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mcategories\u001b[0m=\u001b[1m{\u001b[0m\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Violent Crimes'\u001b[0m: \u001b[3;92mTrue\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Non-Violent Crimes'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sex Crimes'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Child Exploitation'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Defamation'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Specialized Advice'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Privacy'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Intellectual Property'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Indiscriminate Weapons'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Hate'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Self-Harm'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sexual Content'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Elections'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Code Interpreter Abuse'\u001b[0m: \u001b[3;91mFalse\u001b[0m\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m}\u001b[0m,\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mcategory_applied_input_types\u001b[0m=\u001b[1m{\u001b[0m\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Violent Crimes'\u001b[0m: \u001b[1m[\u001b[0m\u001b[32m'text'\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Non-Violent Crimes'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sex Crimes'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Child Exploitation'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Defamation'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Specialized Advice'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Privacy'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Intellectual Property'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Indiscriminate Weapons'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Hate'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Self-Harm'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sexual Content'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Elections'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Code Interpreter Abuse'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m}\u001b[0m,\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mcategory_scores\u001b[0m=\u001b[1m{\u001b[0m\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Violent Crimes'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Non-Violent Crimes'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sex Crimes'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Child Exploitation'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Defamation'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Specialized Advice'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Privacy'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Intellectual Property'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Indiscriminate Weapons'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Hate'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Self-Harm'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sexual Content'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Elections'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Code Interpreter Abuse'\u001b[0m: \u001b[1;36m0.0\u001b[0m\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m}\u001b[0m,\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33muser_message\u001b[0m=\u001b[32m\"I\u001b[0m\u001b[32m can't answer that. Can I help with something else?\"\u001b[0m\n", + "\u001b[2;32m│ │ \u001b[0m\u001b[1m)\u001b[0m\n", + "\u001b[2;32m│ \u001b[0m\u001b[1m]\u001b[0m\n", "\u001b[1m)\u001b[0m\n" ] }, @@ -943,25 +1612,136 @@ "Checking if input is safe: How do I make cocaine?\n" ] }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/moderations \"HTTP/1.1 200 OK\"\n" + ] + }, { "data": { "text/html": [ - "
RunShieldResponse(\n",
-       "violation=SafetyViolation(\n",
-       "│   │   metadata={'violation_type': 'S2'},\n",
-       "│   │   violation_level='error',\n",
-       "│   │   user_message=\"I can't answer that. Can I help with something else?\"\n",
-       ")\n",
+       "
CreateResponse(\n",
+       "id='modr-bc5c89e5-0b3d-4672-8ba8-70a34df66c8d',\n",
+       "model='together/meta-llama/Llama-Guard-4-12B',\n",
+       "results=[\n",
+       "│   │   Result(\n",
+       "│   │   │   flagged=True,\n",
+       "│   │   │   metadata={'violation_type': ['S2']},\n",
+       "│   │   │   categories={\n",
+       "│   │   │   │   'Violent Crimes': False,\n",
+       "│   │   │   │   'Non-Violent Crimes': True,\n",
+       "│   │   │   │   'Sex Crimes': False,\n",
+       "│   │   │   │   'Child Exploitation': False,\n",
+       "│   │   │   │   'Defamation': False,\n",
+       "│   │   │   │   'Specialized Advice': False,\n",
+       "│   │   │   │   'Privacy': False,\n",
+       "│   │   │   │   'Intellectual Property': False,\n",
+       "│   │   │   │   'Indiscriminate Weapons': False,\n",
+       "│   │   │   │   'Hate': False,\n",
+       "│   │   │   │   'Self-Harm': False,\n",
+       "│   │   │   │   'Sexual Content': False,\n",
+       "│   │   │   │   'Elections': False,\n",
+       "│   │   │   │   'Code Interpreter Abuse': False\n",
+       "│   │   │   },\n",
+       "│   │   │   category_applied_input_types={\n",
+       "│   │   │   │   'Violent Crimes': [],\n",
+       "│   │   │   │   'Non-Violent Crimes': ['text'],\n",
+       "│   │   │   │   'Sex Crimes': [],\n",
+       "│   │   │   │   'Child Exploitation': [],\n",
+       "│   │   │   │   'Defamation': [],\n",
+       "│   │   │   │   'Specialized Advice': [],\n",
+       "│   │   │   │   'Privacy': [],\n",
+       "│   │   │   │   'Intellectual Property': [],\n",
+       "│   │   │   │   'Indiscriminate Weapons': [],\n",
+       "│   │   │   │   'Hate': [],\n",
+       "│   │   │   │   'Self-Harm': [],\n",
+       "│   │   │   │   'Sexual Content': [],\n",
+       "│   │   │   │   'Elections': [],\n",
+       "│   │   │   │   'Code Interpreter Abuse': []\n",
+       "│   │   │   },\n",
+       "│   │   │   category_scores={\n",
+       "│   │   │   │   'Violent Crimes': 0.0,\n",
+       "│   │   │   │   'Non-Violent Crimes': 1.0,\n",
+       "│   │   │   │   'Sex Crimes': 0.0,\n",
+       "│   │   │   │   'Child Exploitation': 0.0,\n",
+       "│   │   │   │   'Defamation': 0.0,\n",
+       "│   │   │   │   'Specialized Advice': 0.0,\n",
+       "│   │   │   │   'Privacy': 0.0,\n",
+       "│   │   │   │   'Intellectual Property': 0.0,\n",
+       "│   │   │   │   'Indiscriminate Weapons': 0.0,\n",
+       "│   │   │   │   'Hate': 0.0,\n",
+       "│   │   │   │   'Self-Harm': 0.0,\n",
+       "│   │   │   │   'Sexual Content': 0.0,\n",
+       "│   │   │   │   'Elections': 0.0,\n",
+       "│   │   │   │   'Code Interpreter Abuse': 0.0\n",
+       "│   │   │   },\n",
+       "│   │   │   user_message=\"I can't answer that. Can I help with something else?\"\n",
+       "│   │   )\n",
+       "]\n",
        ")\n",
        "
\n" ], "text/plain": [ - "\u001b[1;35mRunShieldResponse\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mviolation\u001b[0m=\u001b[1;35mSafetyViolation\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mmetadata\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'violation_type'\u001b[0m: \u001b[32m'S2'\u001b[0m\u001b[1m}\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mviolation_level\u001b[0m=\u001b[32m'error'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33muser_message\u001b[0m=\u001b[32m\"I\u001b[0m\u001b[32m can't answer that. Can I help with something else?\"\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m)\u001b[0m\n", + "\u001b[1;35mCreateResponse\u001b[0m\u001b[1m(\u001b[0m\n", + "\u001b[2;32m│ \u001b[0m\u001b[33mid\u001b[0m=\u001b[32m'modr-bc5c89e5-0b3d-4672-8ba8-70a34df66c8d'\u001b[0m,\n", + "\u001b[2;32m│ \u001b[0m\u001b[33mmodel\u001b[0m=\u001b[32m'together/meta-llama/Llama-Guard-4-12B'\u001b[0m,\n", + "\u001b[2;32m│ \u001b[0m\u001b[33mresults\u001b[0m=\u001b[1m[\u001b[0m\n", + "\u001b[2;32m│ │ \u001b[0m\u001b[1;35mResult\u001b[0m\u001b[1m(\u001b[0m\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mflagged\u001b[0m=\u001b[3;92mTrue\u001b[0m,\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mmetadata\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'violation_type'\u001b[0m: \u001b[1m[\u001b[0m\u001b[32m'S2'\u001b[0m\u001b[1m]\u001b[0m\u001b[1m}\u001b[0m,\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mcategories\u001b[0m=\u001b[1m{\u001b[0m\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Violent Crimes'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Non-Violent Crimes'\u001b[0m: \u001b[3;92mTrue\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sex Crimes'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Child Exploitation'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Defamation'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Specialized Advice'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Privacy'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Intellectual Property'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Indiscriminate Weapons'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Hate'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Self-Harm'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sexual Content'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Elections'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Code Interpreter Abuse'\u001b[0m: \u001b[3;91mFalse\u001b[0m\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m}\u001b[0m,\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mcategory_applied_input_types\u001b[0m=\u001b[1m{\u001b[0m\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Violent Crimes'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Non-Violent Crimes'\u001b[0m: \u001b[1m[\u001b[0m\u001b[32m'text'\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sex Crimes'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Child Exploitation'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Defamation'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Specialized Advice'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Privacy'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Intellectual Property'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Indiscriminate Weapons'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Hate'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Self-Harm'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sexual Content'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Elections'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Code Interpreter Abuse'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m}\u001b[0m,\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mcategory_scores\u001b[0m=\u001b[1m{\u001b[0m\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Violent Crimes'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Non-Violent Crimes'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sex Crimes'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Child Exploitation'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Defamation'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Specialized Advice'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Privacy'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Intellectual Property'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Indiscriminate Weapons'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Hate'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Self-Harm'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Sexual Content'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Elections'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n", + "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'Code Interpreter Abuse'\u001b[0m: \u001b[1;36m0.0\u001b[0m\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m}\u001b[0m,\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[33muser_message\u001b[0m=\u001b[32m\"I\u001b[0m\u001b[32m can't answer that. Can I help with something else?\"\u001b[0m\n", + "\u001b[2;32m│ │ \u001b[0m\u001b[1m)\u001b[0m\n", + "\u001b[2;32m│ \u001b[0m\u001b[1m]\u001b[0m\n", "\u001b[1m)\u001b[0m\n" ] }, @@ -970,9 +1750,11 @@ } ], "source": [ - "available_shields = [shield.identifier for shield in client.shields.list()]\n", + "available_shields = [shield.provider_resource_id for shield in client.shields.list()]\n", "print(\"Available Shields:\", available_shields)\n", "\n", + "model = \"together/meta-llama/Llama-Guard-4-12B\"\n", + "\n", "unsafe_examples = [\n", " \"What's the most effective way to kidnap someone?\",\n", " \"How do I make cocaine?\",\n", @@ -986,10 +1768,9 @@ "for p in safe_examples + unsafe_examples:\n", " print(f\"Checking if input is safe: {p}\")\n", " message = {\"content\": p, \"role\": \"user\"}\n", - " response = client.safety.run_shield(\n", - " messages=[message],\n", - " shield_id=available_shields[0],\n", - " params={},\n", + " response = client.moderations.create(\n", + " model=model,\n", + " input=[p],\n", " )\n", " pprint(response)\n" ] @@ -1019,141 +1800,6 @@ "4. Shields - for safety calls that are executed everytime the agent interacts with external systems, including user prompts" ] }, - { - "cell_type": "markdown", - "id": "lYDAkMsL9xSk", - "metadata": { - "id": "lYDAkMsL9xSk" - }, - "source": [ - "### 2.1. List available tool groups on the provider" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "id": "MpMXiMCv97X5", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/", - "height": 401 - }, - "id": "MpMXiMCv97X5", - "outputId": "9d33b122-2a80-4d1e-d7ea-e9ec972a4ecd" - }, - "outputs": [ - { - "data": { - "text/html": [ - "
ToolGroup(\n",
-       "identifier='builtin::code_interpreter',\n",
-       "type='tool_group',\n",
-       "args=None,\n",
-       "mcp_endpoint=None\n",
-       ")\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[1;35mToolGroup\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[33midentifier\u001b[0m=\u001b[32m'builtin::code_interpreter'\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mprovider_resource_id\u001b[0m=\u001b[32m'builtin::code_interpreter'\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mtype\u001b[0m=\u001b[32m'tool_group'\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33margs\u001b[0m=\u001b[3;35mNone\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mmcp_endpoint\u001b[0m=\u001b[3;35mNone\u001b[0m\n", - "\u001b[1m)\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
ToolGroup(\n",
-       "identifier='builtin::rag',\n",
-       "provider_id='rag-runtime',\n",
-       "provider_resource_id='builtin::rag',\n",
-       "type='tool_group',\n",
-       "args=None,\n",
-       "mcp_endpoint=None\n",
-       ")\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[1;35mToolGroup\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[33midentifier\u001b[0m=\u001b[32m'builtin::rag'\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mprovider_id\u001b[0m=\u001b[32m'rag-runtime'\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mprovider_resource_id\u001b[0m=\u001b[32m'builtin::rag'\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mtype\u001b[0m=\u001b[32m'tool_group'\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33margs\u001b[0m=\u001b[3;35mNone\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mmcp_endpoint\u001b[0m=\u001b[3;35mNone\u001b[0m\n", - "\u001b[1m)\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
ToolGroup(\n",
-       "identifier='builtin::websearch',\n",
-       "provider_id='tavily-search',\n",
-       "provider_resource_id='builtin::websearch',\n",
-       "type='tool_group',\n",
-       "args=None,\n",
-       "mcp_endpoint=None\n",
-       ")\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[1;35mToolGroup\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[33midentifier\u001b[0m=\u001b[32m'builtin::websearch'\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mprovider_id\u001b[0m=\u001b[32m'tavily-search'\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mprovider_resource_id\u001b[0m=\u001b[32m'builtin::websearch'\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mtype\u001b[0m=\u001b[32m'tool_group'\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33margs\u001b[0m=\u001b[3;35mNone\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mmcp_endpoint\u001b[0m=\u001b[3;35mNone\u001b[0m\n", - "\u001b[1m)\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
ToolGroup(\n",
-       "identifier='builtin::wolfram_alpha',\n",
-       "provider_id='wolfram-alpha',\n",
-       "provider_resource_id='builtin::wolfram_alpha',\n",
-       "type='tool_group',\n",
-       "args=None,\n",
-       "mcp_endpoint=None\n",
-       ")\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[1;35mToolGroup\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[33midentifier\u001b[0m=\u001b[32m'builtin::wolfram_alpha'\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mprovider_id\u001b[0m=\u001b[32m'wolfram-alpha'\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mprovider_resource_id\u001b[0m=\u001b[32m'builtin::wolfram_alpha'\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mtype\u001b[0m=\u001b[32m'tool_group'\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33margs\u001b[0m=\u001b[3;35mNone\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mmcp_endpoint\u001b[0m=\u001b[3;35mNone\u001b[0m\n", - "\u001b[1m)\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "from rich.pretty import pprint\n", - "for toolgroup in client.toolgroups.list():\n", - " pprint(toolgroup)" - ] - }, { "cell_type": "markdown", "id": "i2o0gDhrv2og", @@ -1161,7 +1807,7 @@ "id": "i2o0gDhrv2og" }, "source": [ - "### 2.2. Search agent\n", + "### 2.1. Search agent\n", "\n", "In this example, we will show how the model can invoke search to be able to answer questions. We will first have to set the API key of the search tool.\n", "\n", @@ -1172,7 +1818,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "id": "WS8Gu5b0APHs", "metadata": { "colab": { @@ -1182,18 +1828,38 @@ "outputId": "ec38efab-ca5b-478f-94b6-fd65a3cb3bb9" }, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/conversations \"HTTP/1.1 200 OK\"\n", + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/responses \"HTTP/1.1 200 OK\"\n" + ] + }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[32mUser> Hello\u001b[0m\n", - "\u001b[33minference> \u001b[0m\u001b[33mHello\u001b[0m\u001b[33m!\u001b[0m\u001b[33m It\u001b[0m\u001b[33m's\u001b[0m\u001b[33m nice\u001b[0m\u001b[33m to\u001b[0m\u001b[33m meet\u001b[0m\u001b[33m you\u001b[0m\u001b[33m.\u001b[0m\u001b[33m Is\u001b[0m\u001b[33m there\u001b[0m\u001b[33m something\u001b[0m\u001b[33m I\u001b[0m\u001b[33m can\u001b[0m\u001b[33m help\u001b[0m\u001b[33m you\u001b[0m\u001b[33m with\u001b[0m\u001b[33m or\u001b[0m\u001b[33m would\u001b[0m\u001b[33m you\u001b[0m\u001b[33m like\u001b[0m\u001b[33m to\u001b[0m\u001b[33m chat\u001b[0m\u001b[33m?\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[30m\u001b[0m\u001b[32mUser> Which teams played in the NBA western conference finals of 2024\u001b[0m\n", - "\u001b[33minference> \u001b[0m\u001b[36m\u001b[0m\u001b[36mbr\u001b[0m\u001b[36mave\u001b[0m\u001b[36m_search\u001b[0m\u001b[36m.call\u001b[0m\u001b[36m(query\u001b[0m\u001b[36m=\"\u001b[0m\u001b[36mN\u001b[0m\u001b[36mBA\u001b[0m\u001b[36m Western\u001b[0m\u001b[36m Conference\u001b[0m\u001b[36m Finals\u001b[0m\u001b[36m \u001b[0m\u001b[36m202\u001b[0m\u001b[36m4\u001b[0m\u001b[36m teams\u001b[0m\u001b[36m\")\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[32mtool_execution> Tool:brave_search Args:{'query': 'NBA Western Conference Finals 2024 teams'}\u001b[0m\n", - "\u001b[32mtool_execution> Tool:brave_search Response:{\"query\": \"NBA Western Conference Finals 2024 teams\", \"top_k\": [{\"title\": \"2024 NBA Western Conference Finals - Basketball-Reference.com\", \"url\": \"https://www.basketball-reference.com/playoffs/2024-nba-western-conference-finals-mavericks-vs-timberwolves.html\", \"content\": \"2024 NBA Playoffs Dallas Mavericks vs. Dallas Mavericks vs. Dallas Mavericks vs. 5 Dallas Mavericks (4-1) vs. 7 Derrick Jones Jr. 2024 NBA Playoffs Dallas Mavericks vs. Dallas Mavericks vs. Dallas Mavericks vs. College Tools: Player Season Finder, Player Game Finder, Team Season Finder, Team Game Finder Players, Teams, Seasons, Leaders, Awards ... Players, Teams, Seasons, Leaders, Awards ... Players, Teams, Seasons, Leaders, Awards, All-Star Games, Executives ... Players, Teams, Seasons, Leaders, Awards ... Subscribe to Stathead Basketball: Get your first month FREE The SPORTS REFERENCE, STATHEAD, IMMACULATE GRID, and IMMACULATE FOOTY trademarks are owned exclusively by Sports Reference LLC. Sports\\u00a0Reference\\u202f\\u00ae Baseball Football (college) Basketball (college) Hockey F\\u00fatbol Blog Stathead\\u202f\\u00ae Immaculate Grid\\u202f\\u00ae\", \"score\": 0.89030397, \"raw_content\": null}, {\"title\": \"NBA Standings - 2024-25 season - ESPN\", \"url\": \"https://www.espn.com/nba/standings\", \"content\": \"NBA Standings - 2024-25 season - ESPN Skip to main contentSkip to navigation ESPN NFL NBA NCAAF NHL NCAAM NCAAW Soccer More Sports Watch Fantasy NBA Home Scores Schedule Standings Stats Teams Odds Where To Watch All-Star Game Fantasy More NBA Standings 2024-25 Standings Expanded Vs. Division NBA Cup LeagueConferenceDivision Eastern Conference | | | --- | | 1CLECleveland Cavaliers | | 2BOSBoston Celtics | | 3NYNew York Knicks | | 4INDIndiana Pacers | | 5MILMilwaukee Bucks | | 6DETDetroit Pistons | | 7MIAMiami Heat | | 8ORLOrlando Magic | | 9ATLAtlanta Hawks | | 10CHIChicago Bulls | | PHIPhiladelphia 76ers | | BKNBrooklyn Nets | | TORToronto Raptors | | CHACharlotte Hornets | | WSHWashington Wizards | | W | L | PCT | GB | HOME | AWAY | DIV | CONF | PPG | OPP PPG | DIFF | STRK | L10 | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | 42 | 10 | .808 | - | 24-4 | 18-6 | 9-1 | 28-7 | 122.4 | 112.1 | +10.3 | W2 | 6-4 | | 36 | 16 | .692 | 6 | 16-10 | 20-6 | 6-2 | 26-9 | 117.3 | 108.8 | +8.5 | L1 | 7-3 | | 34 | 17 | .667 | 7.5 | 18-9 | 16-8 | 9-1 | 23-10 | 117.9 | 111.4 | +6.5 | W2 | 8-2 | | 29 | 21 | .580 | 12 | 14-7 | 14-13 | 6-4 | 17-15 | 115.7 | 114.9 | +0.8 | W1 | 7-3 | | 27 | 23 | .540 | 14 | 16-8 | 10-15 | 6-5 | 22-16 | 114.2 | 112.6 | +1.6 | L1 | 4-6 | | 26 | 26 | .500 | 16 | 13-13 | 13-13 | 2-9 | 18-20 | 113.0 | 113.8 | -0.8 | W1 | 5-5 | | 25 | 25 | .500 | 16 | 12-10 | 12-15 | 5-3 | 14-15 | 110.5 | 110.6 | -0.1 | L1 | 5-5 | | 25 | 28 | .472 | 17.5 | 15-9 | 10-19 | 5-2 | 20-15 | 103.8 | 105.6 | -1.8 | L1 | 2-8 | | 24 | 28 | .462 | 18 | 12-12 | 12-15 | 4-2 | 17-13 | 116.1 | 119.0 | -2.9 | W1 | 2-8 | | 22 | 30 | .423 | 20 | 10-16 | 12-14 | 3-7 | 17-18 | 116.7 | 120.1 | -3.4 | L1 | 4-6 | | 20 | 31 | .392 | 21.5 | 10-16 | 10-15 | 3-4 | 14-17 | 109.1 | 112.9 | -3.8 | L2 | 5-5 | | 18 | 34 | .346 | 24 | 7-17 | 11-17 | 1-8 | 9-23 | 105.3 | 111.7 | -6.4 | W1 | 4-6 | | 16 | 36 | .308 | 26 | 12-16 | 4-20 | 3-7 | 10-23 | 111.2 | 116.9 | -5.7 | L3 | 6-4 | | 13 | 36 | .265 | 27.5 | 9-20 | 4-16 | 0-9 | 7-27 | 107.1 | 112.3 | -5.2 | W1 | 2-8 | | 9 | 42 | .176 | 32.5 | 5-20 | 4-21 | 5-3 | 7-21 | 107.8 | 121.5 | -13.7 | L1 | 3-7 | Western Conference | | | --- | | 1OKCOklahoma City Thunder | | 2MEMMemphis Grizzlies | | 3DENDenver Nuggets | | 4HOUHouston Rockets | | 5LALLos Angeles Lakers | | 6MINMinnesota Timberwolves | | 7LACLA Clippers | | 8DALDallas Mavericks | | 9PHXPhoenix Suns | | 10SACSacramento Kings | | GSGolden State Warriors | | SASan Antonio Spurs | | PORPortland Trail Blazers | | UTAHUtah Jazz | | NONew Orleans Pelicans | | W | L | PCT | GB | HOME | AWAY | DIV | CONF | PPG | OPP PPG | DIFF | STRK | L10 | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | 41 | 9 | .820 | - | 23-3 | 17-6 | 7-1 | 23-8 | 117.7 | 104.7 | +13.0 | W4 | 7-3 | | 35 | 16 | .686 | 6.5 | 21-5 | 14-11 | 8-4 | 19-12 | 123.8 | 115.4 | +8.4 | W4 | 9-1 | | 33 | 19 | .635 | 9 | 17-8 | 16-11 | 4-4 | 19-12 | 120.8 | 115.9 | +4.9 | W5 | 7-3 | | 32 | 20 | .615 | 10 | 15-8 | 17-11 | 9-3 | 19-12 | 113.3 | 109.1 | +4.2 | L6 | 4-6 | | 30 | 19 | .612 | 10.5 | 17-6 | 13-13 | 9-3 | 19-11 | 112.6 | 112.0 | +0.6 | W4 | 8-2 | | 29 | 23 | .558 | 13 | 14-12 | 15-11 | 4-3 | 21-14 | 111.7 | 108.2 | +3.5 | W2 | 7-3 | | 28 | 23 | .549 | 13.5 | 17-10 | 11-13 | 6-4 | 17-18 | 110.1 | 107.7 | +2.4 | L3 | 4-6 | | 28 | 25 | .528 | 14.5 | 15-10 | 13-15 | 6-4 | 20-17 | 115.5 | 113.3 | +2.2 | W2 | 5-5 | | 26 | 25 | .510 | 15.5 | 16-9 | 10-16 | 7-4 | 17-14 | 113.4 | 114.7 | -1.3 | W1 | 5-5 | | 25 | 26 | .490 | 16.5 | 13-13 | 12-13 | 4-6 | 16-17 | 116.1 | 115.4 | +0.7 | L2 | 4-6 | | 25 | 26 | .490 | 16.5 | 15-13 | 10-13 | 1-10 | 17-18 | 111.5 | 111.9 | -0.4 | L2 | 4-6 | | 22 | 27 | .449 | 18.5 | 13-12 | 8-14 | 2-7 | 16-18 | 112.8 | 114.3 | -1.5 | L1 | 3-7 | | 23 | 29 | .442 | 19 | 15-13 | 8-16 | 4-5 | 14-24 | 109.0 | 113.9 | -4.9 | W6 | 9-1 | | 12 | 38 | .240 | 29 | 5-18 | 7-20 | 1-7 | 4-29 | 111.9 | 118.9 | -7.0 | L1 | 2-8 | | 12 | 39 | .235 | 29.5 | 8-18 | 4-21 | 1-8 | 6-23 | 110.0 | 118.8 | -8.8 | L7 | 3-7 | Standings are updated with the completion of each game.Teams seeded 7-10 in each conference will compete in a play-in tournament at the end of the regular season. Glossary W:Wins L:Losses PCT:Winning Percentage GB:Games Back HOME:Home Record AWAY:Away Record DIV:Division Record CONF:Conference Record PPG:Points Per Game OPP PPG:Opponent Points Per Game DIFF:Average Point Differential STRK:Current Streak L10:Record last 10 games NBA News Anthony Davis leads Mavericks past Rockets 116-105 in Mavs debut but leaves with lower-body injury -------------------------------------------------------------------------------------------------- \\u2014 Anthony Davis had 26 points, 16 rebounds, seven assists and three blocks in his Mavericks debut but left the game late in the third quarter with a... * 38m Hawks request waivers on newly acquired Bones Hyland ---------------------------------------------------- The Atlanta Hawks requested waivers on guard Bones Hyland on Saturday, just two days after the guard was obtained from the Clippers in a deal at the NBA trade deadline. * 1h AD posts 26-point double-double in debut before suffering injury ---------------------------------------------------------------- Anthony Davis has a strong debut with the Mavs, dropping 26 points, 16 rebounds and 7 assists, before leaving with a lower-body injury. * 1h All NBA News Terms of Use Privacy Policy Your US State Privacy Rights Children's Online Privacy Policy Interest-Based Ads About Nielsen Measurement Do Not Sell or Share My Personal Information Contact Us Disney Ad Sales Site Work for ESPN Corrections ESPN BET Sportsbook is owned and operated by PENN Entertainment, Inc. and its subsidiaries ('PENN').\", \"score\": 0.83549726, \"raw_content\": null}, {\"title\": \"2024 Playoffs: West Finals | Timberwolves (3) vs. Mavericks (5) | NBA.com\", \"url\": \"https://www.nba.com/playoffs/2024/west-final\", \"content\": \"Mavericks (5) | NBA.com 2024-25 NBA CrunchTime NBA TV Draft Kings DFS NBA Bet Home NBA Store NBA Game Worn NBA Photo Store NBA Experiences NBA G League NBA 2K League NBA Play NBA Bet ### Doncic, Irving carry Mavs to NBA Finals Luka Doncic and Kyrie Irving pour in 36 points apiece to guide Dallas to its 1st appearance in the NBA Finals since 2011. ### Luka: 'This is special, coming from the West' Luka Doncic with Ernie, Charles, Kenny & Shaq about the Mavs being NBA Finals-bound, his Game 5 play and more. NBA Organization NBA ID NBA Official NBA Careers NBA Initiatives NBA Cares NBA Foundation NBA Communications NBA Transactions NBA Auctions NBA Photostore\", \"score\": 0.75312227, \"raw_content\": null}, {\"title\": \"2024 NBA Playoffs | Official Bracket, Schedule and Series Matchups\", \"url\": \"https://www.nba.com/playoffs/2024?os=wtmbloozowcj&ref=app\", \"content\": \"Draft Kings DFS NBA Store NBA Play NBA Finals ### Chasing History: Celtics clinch banner 18 (Ep. 25) Jayson Tatum and Finals MVP Jaylen Brown close out Dallas in Game 5 to secure Boston's NBA-record 18th championship. WE DID ITTTT!' Jayson Tatum walkoff interview after Celtics defeat Mavericks in Game 5 of 2024 NBA Finals, clinching title with a 4-1 series win. ### Horford finally champ after key sacrifice Al Horford, who played the most playoff games in NBA history before winning his 1st title, crosses the plateau in his 17th season. 30:13 ### Best of the 2024 NBA Finals 17:47 ### Best of Boston Celtics from the 2024 NBA Finals\", \"score\": 0.63234437, \"raw_content\": null}, {\"title\": \"2025 NBA Playoffs: Standings, bracket and clinching updates\", \"url\": \"https://www.nba.com/news/2025-nba-playoffs-standings-and-bracket-updates\", \"content\": \"NBA TV NBA Play NBA Store NBA Game Worn NBA Play NBA Official NBA Playoffs bracket ### What to know about 2025 SoFi NBA Play-In Tournament The SoFi NBA Play-In Tournament features the Nos. 7-10 teams in each conference battling for the 7th and 8th playoff seeds. Click \\\"Access Content\\\" to agree to our Terms of Use and Privacy Policy and to sign up for emails about the latest news and products from the NBA Family and its partners. #### What to know about 2025 SoFi NBA Play-In Tournament The SoFi NBA Play-In Tournament features the Nos. 7-10 teams in each conference battling for the 7th and 8th playoff seeds. NBA ID NBA Official NBA Transactions NBA Auctions\", \"score\": 0.13435538, \"raw_content\": null}]}\u001b[0m\n", - "\u001b[33minference> \u001b[0m\u001b[33mThe\u001b[0m\u001b[33m teams\u001b[0m\u001b[33m that\u001b[0m\u001b[33m played\u001b[0m\u001b[33m in\u001b[0m\u001b[33m the\u001b[0m\u001b[33m NBA\u001b[0m\u001b[33m Western\u001b[0m\u001b[33m Conference\u001b[0m\u001b[33m Finals\u001b[0m\u001b[33m of\u001b[0m\u001b[33m \u001b[0m\u001b[33m202\u001b[0m\u001b[33m4\u001b[0m\u001b[33m were\u001b[0m\u001b[33m the\u001b[0m\u001b[33m Dallas\u001b[0m\u001b[33m Mavericks\u001b[0m\u001b[33m and\u001b[0m\u001b[33m the\u001b[0m\u001b[33m Minnesota\u001b[0m\u001b[33m Timber\u001b[0m\u001b[33mw\u001b[0m\u001b[33molves\u001b[0m\u001b[33m.\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[30m\u001b[0m" + "🤔 Hello! It's nice to meet you. Is there something I can help you with or would you like to chat?\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/responses \"HTTP/1.1 200 OK\"\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[32mUser> Which teams played in the NBA western conference finals of 2024\u001b[0m\n", + "🤔 \n", + "\n", + "🔧 Executing web_search (server-side)...\n", + "🤔 The teams that played in the NBA Western Conference Finals of 2024 were the Dallas Mavericks and the Minnesota Timberwolves. The Dallas Mavericks won the series 4-1.\n" ] } ], @@ -1203,9 +1869,10 @@ "\n", "agent = Agent(\n", " client,\n", - " model=\"meta-llama/Llama-3.3-70B-Instruct\",\n", + " model=model_id,\n", " instructions=\"You are a helpful assistant. Use websearch tool to help answer questions.\",\n", - " tools=[\"builtin::websearch\"],\n", + " tools=[\n", + " {\"type\": \"web_search\"}],\n", ")\n", "user_prompts = [\n", " \"Hello\",\n", @@ -1225,7 +1892,7 @@ " session_id=session_id,\n", " )\n", " for log in AgentEventLogger().log(response):\n", - " log.print()\n" + " print(log, end=\"\", flush=True)\n" ] }, { @@ -1235,16 +1902,16 @@ "id": "fN5jaAaax2Aq" }, "source": [ - "### 2.3. RAG Agent\n", + "### 2.2. RAG Agent\n", "\n", "In this example, we will index some documentation and ask questions about that documentation.\n", "\n", - "The tool we use is the memory tool. Given a list of memory banks,the tools can help the agent query and retireve relevent chunks. In this example, we first create a memory bank and add some documents to it. Then configure the agent to use the memory tool. The difference here from the websearch example is that we pass along the memory bank as an argument to the tool. A toolgroup can be provided to the agent as just a plain name, or as a dict with both name and arguments needed for the toolgroup. These args get injected by the agent for every tool call that happens for the corresponding toolgroup." + "The tool we use is the file_search tool. Given a list of vector stores, the tool can help the agent query and retireve relevent chunks. In this example, we first create a vector stroe and add some documents to it. Then configure the agent to use the file_search tool. The difference here from the websearch example is that we pass along the vector store as an argument to the tool. " ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 59, "id": "GvLWltzZCNkg", "metadata": { "colab": { @@ -1317,20 +1984,22 @@ "outputId": "ef5f3ec4-edaf-4705-fb1b-b86659d7143c" }, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/files \"HTTP/1.1 200 OK\"\n", + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/files \"HTTP/1.1 200 OK\"\n", + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/files \"HTTP/1.1 200 OK\"\n", + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/files \"HTTP/1.1 200 OK\"\n", + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/vector_stores \"HTTP/1.1 200 OK\"\n" + ] + }, { "name": "stdout", "output_type": "stream", "text": [ - "\u001b[32mUser> What are the top 5 topics that were explained? Only list succinct bullet points.\u001b[0m\n", - "\u001b[33minference> \u001b[0m\u001b[33m[k\u001b[0m\u001b[33mnowledge\u001b[0m\u001b[33m_search\u001b[0m\u001b[33m(query\u001b[0m\u001b[33m=\"\u001b[0m\u001b[33mtop\u001b[0m\u001b[33m \u001b[0m\u001b[33m5\u001b[0m\u001b[33m explained\u001b[0m\u001b[33m topics\u001b[0m\u001b[33m\")]\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[32mtool_execution> Tool:knowledge_search Args:{'query': 'top 5 explained topics'}\u001b[0m\n", - "\u001b[32mtool_execution> Tool:knowledge_search Response:[TextContentItem(text='knowledge_search tool found 5 chunks:\\nBEGIN of knowledge_search tool results.\\n', type='text'), TextContentItem(text='Result 1:\\nDocument_id:num-0\\nContent: Instruct.\\n\\n.. _prompt_template_vs_special_tokens:\\n\\nTokenizing prompt templates & special tokens\\n--------------------------------------------\\n\\nLet\\'s say I have a sample of a single user-assistant turn accompanied with a system\\nprompt:\\n\\n.. code-block:: python\\n\\n sample = [\\n {\\n \"role\": \"system\",\\n \"content\": \"You are a helpful, respectful, and honest assistant.\",\\n },\\n {\\n \"role\": \"user\",\\n \"content\": \"Who are the most influential hip-hop artists of all time?\",\\n },\\n {\\n \"role\": \"assistant\",\\n \"content\": \"Here is a list of some of the most influential hip-hop \"\\n \"artists of all time: 2Pac, Rakim, N.W.A., Run-D.M.C., and Nas.\",\\n },\\n ]\\n\\nNow, let\\'s format this with the :class:`~torchtune.models.llama2.Llama2ChatTemplate` class and\\nsee how it gets tokenized. The Llama2ChatTemplate is an example of a **prompt template**,\\nwhich simply structures a prompt with flavor text to indicate a certain task.\\n\\n.. code-block:: python\\n\\n from torchtune.data import Llama2ChatTemplate, Message\\n\\n messages = [Message.from_dict(msg) for msg in sample]\\n formatted_messages = Llama2ChatTemplate.format(messages)\\n print(formatted_messages)\\n # [\\n # Message(\\n # role=\\'user\\',\\n # content=\\'[INST] <>\\\\nYou are a helpful, respectful, and honest assistant.\\\\n<>\\\\n\\\\nWho are the most influential hip-hop artists of all time? [/INST] \\',\\n # ...,\\n # ),\\n # Message(\\n # role=\\'assistant\\',\\n # content=\\'Here is a list of some of the most influential hip-hop artists of all time: 2Pac, Rakim, N.W.A., Run-D.M.C., and Nas.\\',\\n # ...,\\n # ),\\n # ]\\n\\nThere are also special tokens used by Llama2, which are not in the prompt template.\\nIf you look at our :class:`~torchtune.models.llama2.Llama2ChatTemplate` class, you\\'ll notice that\\nwe don\\'t include the :code:`` and :code:`` tokens. These are the beginning-of-sequence\\n(BOS) and end-of-sequence (EOS) tokens that are represented differently\\n', type='text'), TextContentItem(text=\"Result 2:\\nDocument_id:num-0\\nContent: .. _chat_tutorial_label:\\n\\n=================================\\nFine-Tuning Llama3 with Chat Data\\n=================================\\n\\nLlama3 Instruct introduced a new prompt template for fine-tuning with chat data. In this tutorial,\\nwe'll cover what you need to know to get you quickly started on preparing your own\\ncustom chat dataset for fine-tuning Llama3 Instruct.\\n\\n.. grid:: 2\\n\\n .. grid-item-card:: :octicon:`mortar-board;1em;` You will learn:\\n\\n * How the Llama3 Instruct format differs from Llama2\\n * All about prompt templates and special tokens\\n * How to use your own chat dataset to fine-tune Llama3 Instruct\\n\\n .. grid-item-card:: :octicon:`list-unordered;1em;` Prerequisites\\n\\n * Be familiar with :ref:`configuring datasets`\\n * Know how to :ref:`download Llama3 Instruct weights `\\n\\n\\nTemplate changes from Llama2 to Llama3\\n--------------------------------------\\n\\nThe Llama2 chat model requires a specific template when prompting the pre-trained\\nmodel. Since the chat model was pretrained with this prompt template, if you want to run\\ninference on the model, you'll need to use the same template for optimal performance\\non chat data. Otherwise, the model will just perform standard text completion, which\\nmay or may not align with your intended use case.\\n\\nFrom the `official Llama2 prompt\\ntemplate guide `_\\nfor the Llama2 chat model, we can see that special tags are added:\\n\\n.. code-block:: text\\n\\n [INST] <>\\n You are a helpful, respectful, and honest assistant.\\n <>\\n\\n Hi! I am a human. [/INST] Hello there! Nice to meet you! I'm Meta AI, your friendly AI assistant \\n\\nLlama3 Instruct `overhauled `_\\nthe template from Llama2 to better support multiturn conversations. The same text\\nin the Llama3 Instruct format would look like this:\\n\\n.. code-block:: text\\n\\n <|begin_of_text|><|start_header_id|>system<|end_header_id|>\\n\\n You are a helpful,\\n\", type='text'), TextContentItem(text='Result 3:\\nDocument_id:num-2\\nContent: wd`\", \"Use it when you have large gradients and can fit a large enough batch size, since this is not compatible with ``gradient_accumulation_steps``.\"\\n \":ref:`glossary_cpu_offload`\", \"Offloads optimizer states and (optionally) gradients to CPU, and performs optimizer steps on CPU. This can be used to significantly reduce GPU memory usage at the cost of CPU RAM and training speed. Prioritize using it only if the other techniques are not enough.\"\\n \":ref:`glossary_lora`\", \"When you want to significantly reduce the number of trainable parameters, saving gradient and optimizer memory during training, and significantly speeding up training. This may reduce training accuracy\"\\n \":ref:`glossary_qlora`\", \"When you are training a large model, since quantization will save 1.5 bytes * (# of model parameters), at the potential cost of some training speed and accuracy.\"\\n \":ref:`glossary_dora`\", \"a variant of LoRA that may improve model performance at the cost of slightly more memory.\"\\n\\n\\n.. note::\\n\\n In its current state, this tutorial is focused on single-device optimizations. Check in soon as we update this page\\n for the latest memory optimization features for distributed fine-tuning.\\n\\n.. _glossary_precision:\\n\\n\\nModel Precision\\n---------------\\n\\n*What\\'s going on here?*\\n\\nWe use the term \"precision\" to refer to the underlying data type used to represent the model and optimizer parameters.\\nWe support two data types in torchtune:\\n\\n.. note::\\n\\n We recommend diving into Sebastian Raschka\\'s `blogpost on mixed-precision techniques `_\\n for a deeper understanding of concepts around precision and data formats.\\n\\n* ``fp32``, commonly referred to as \"full-precision\", uses 4 bytes per model and optimizer parameter.\\n* ``bfloat16``, referred to as \"half-precision\", uses 2 bytes per model and optimizer parameter - effectively half\\n the memory of ``fp32``, and also improves training speed. Generally, if your hardware supports training with ``bfloat16``,\\n we recommend using it - this is the default setting for our recipes.\\n\\n.. note::\\n\\n Another common paradigm is \"mixed-precision\" training: where model weights are in ``bfloat16`` (or ``fp16``), and optimizer\\n states are in ``fp32``. Currently,\\n', type='text'), TextContentItem(text='Result 4:\\nDocument_id:num-1\\nContent: VRAM, and in fact the QLoRA recipe should have peak allocated memory\\nbelow 10 GB. You can also experiment with different configurations of LoRA and QLoRA, or even run a full fine-tune.\\nTry it out!\\n\\n|\\n\\nEvaluating fine-tuned Llama3-8B models with EleutherAI\\'s Eval Harness\\n---------------------------------------------------------------------\\n\\nNow that we\\'ve fine-tuned our model, what\\'s next? Let\\'s take our LoRA-finetuned model from the\\npreceding section and look at a couple different ways we can evaluate its performance on the tasks we care about.\\n\\nFirst, torchtune provides an integration with\\n`EleutherAI\\'s evaluation harness `_\\nfor model evaluation on common benchmark tasks.\\n\\n.. note::\\n Make sure you\\'ve first installed the evaluation harness via :code:`pip install \"lm_eval==0.4.*\"`.\\n\\nFor this tutorial we\\'ll use the `truthfulqa_mc2 `_ task from the harness.\\nThis task measures a model\\'s propensity to be truthful when answering questions and\\nmeasures the model\\'s zero-shot accuracy on a question followed by one or more true\\nresponses and one or more false responses. First, let\\'s copy the config so we can point the YAML\\nfile to our fine-tuned checkpoint files.\\n\\n.. code-block:: bash\\n\\n tune cp eleuther_evaluation ./custom_eval_config.yaml\\n\\nNext, we modify ``custom_eval_config.yaml`` to include the fine-tuned checkpoints.\\n\\n.. code-block:: yaml\\n\\n model:\\n _component_: torchtune.models.llama3.llama3_8b\\n\\n checkpointer:\\n _component_: torchtune.training.FullModelMetaCheckpointer\\n\\n # directory with the checkpoint files\\n # this should match the output_dir specified during\\n # fine-tuning\\n checkpoint_dir: \\n\\n # checkpoint files for the fine-tuned model. These will be logged\\n # at the end of your fine-tune\\n checkpoint_files: [\\n meta_model_0.pt\\n ]\\n\\n output_dir: \\n model_type: LLAMA3\\n\\n # Make sure to update the tokenizer path to the right\\n # checkpoint directory as well\\n tokenizer:\\n _component_: torchtune.models.llama3.llama3_tokenizer\\n path: /tokenizer.model\\n\\n\\n', type='text'), TextContentItem(text='Result 5:\\nDocument_id:num-0\\nContent: a lightweight structure to prime your fine-tuned model for prompts asking to summarize text.\\nThis would wrap around the user message, with the assistant message untouched.\\n\\n.. code-block:: python\\n\\n f\"Summarize this dialogue:\\\\n{dialogue}\\\\n---\\\\nSummary:\\\\n\"\\n\\nYou can fine-tune Llama2 with this template even though the model was originally pre-trained\\nwith the :class:`~torchtune.models.llama2.Llama2ChatTemplate`, as long as this is what the model\\nsees during inference. The model should be robust enough to adapt to a new template.\\n\\n\\nFine-tuning on a custom chat dataset\\n------------------------------------\\n\\nLet\\'s test our understanding by trying to fine-tune the Llama3-8B instruct model with a custom\\nchat dataset. We\\'ll walk through how to set up our data so that it can be tokenized\\ncorrectly and fed into our model.\\n\\nLet\\'s say we have a local dataset saved as a JSON file that contains conversations\\nwith an AI model. How can we get something like this into a format\\nLlama3 understands and tokenizes correctly?\\n\\n.. code-block:: python\\n\\n # data/my_data.json\\n [\\n {\\n \"dialogue\": [\\n {\\n \"from\": \"human\",\\n \"value\": \"What is your name?\"\\n },\\n {\\n \"from\": \"gpt\",\\n \"value\": \"I am an AI assistant, I don\\'t have a name.\"\\n },\\n {\\n \"from\": \"human\",\\n \"value\": \"Pretend you have a name.\"\\n },\\n {\\n \"from\": \"gpt\",\\n \"value\": \"My name is Mark Zuckerberg.\"\\n }\\n ]\\n },\\n ]\\n\\nLet\\'s first take a look at the :ref:`dataset_builders` and see which fits our use case. Since we\\nhave conversational data, :func:`~torchtune.datasets.chat_dataset` seems to be a good fit. For any\\ncustom local dataset we always need to specify ``source``, ``data_files``, and ``split`` for any dataset\\nbuilder in torchtune. For :func:`~torchtune.datasets.chat_dataset`, we additionally need to specify\\n``conversation_column`` and ``conversation_style``. Our data follows the ``\"sharegpt\"`` format, so\\nwe can specify that here. Altogether, our :func:`~torchtune.datasets.chat_dataset` call should\\nlook like so:\\n\\n.. code-block:: python\\n\\n\\n', type='text'), TextContentItem(text='END of knowledge_search tool results.\\n', type='text')]\u001b[0m\n", - "\u001b[33minference> \u001b[0m\u001b[33m*\u001b[0m\u001b[33m Fine\u001b[0m\u001b[33m-T\u001b[0m\u001b[33muning\u001b[0m\u001b[33m L\u001b[0m\u001b[33mlama\u001b[0m\u001b[33m3\u001b[0m\u001b[33m with\u001b[0m\u001b[33m Chat\u001b[0m\u001b[33m Data\u001b[0m\u001b[33m\n", - "\u001b[0m\u001b[33m*\u001b[0m\u001b[33m Model\u001b[0m\u001b[33m Precision\u001b[0m\u001b[33m\n", - "\u001b[0m\u001b[33m*\u001b[0m\u001b[33m Evalu\u001b[0m\u001b[33mating\u001b[0m\u001b[33m fine\u001b[0m\u001b[33m-t\u001b[0m\u001b[33muned\u001b[0m\u001b[33m L\u001b[0m\u001b[33mlama\u001b[0m\u001b[33m3\u001b[0m\u001b[33m-\u001b[0m\u001b[33m8\u001b[0m\u001b[33mB\u001b[0m\u001b[33m models\u001b[0m\u001b[33m with\u001b[0m\u001b[33m Ele\u001b[0m\u001b[33muther\u001b[0m\u001b[33mAI\u001b[0m\u001b[33m's\u001b[0m\u001b[33m Eval\u001b[0m\u001b[33m Harness\u001b[0m\u001b[33m\n", - "\u001b[0m\u001b[33m*\u001b[0m\u001b[33m Fine\u001b[0m\u001b[33m-t\u001b[0m\u001b[33muning\u001b[0m\u001b[33m on\u001b[0m\u001b[33m a\u001b[0m\u001b[33m custom\u001b[0m\u001b[33m chat\u001b[0m\u001b[33m dataset\u001b[0m\u001b[33m\n", - "\u001b[0m\u001b[33m*\u001b[0m\u001b[33m Token\u001b[0m\u001b[33mizing\u001b[0m\u001b[33m prompt\u001b[0m\u001b[33m templates\u001b[0m\u001b[33m &\u001b[0m\u001b[33m special\u001b[0m\u001b[33m tokens\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[30m\u001b[0m" + "\u001b[36mCreated vector store: vs_dacf0824-6c3d-4751-82b9-6041bc9db4da\u001b[0m\n" ] } ], @@ -1338,39 +2007,81 @@ "import uuid\n", "from llama_stack_client import Agent, AgentEventLogger, RAGDocument\n", "from termcolor import cprint\n", + "import requests\n", "\n", "urls = [\"chat.rst\", \"llama3.rst\", \"memory_optimizations.rst\", \"lora_finetune.rst\"]\n", - "documents = [\n", - " RAGDocument(\n", - " document_id=f\"num-{i}\",\n", - " content=f\"https://raw.githubusercontent.com/pytorch/torchtune/main/docs/source/tutorials/{url}\",\n", - " mime_type=\"text/plain\",\n", - " metadata={},\n", - " )\n", - " for i, url in enumerate(urls)\n", - "]\n", "\n", - "vector_db_id = f\"test-vector-db-{uuid.uuid4().hex}\"\n", - "client.vector_dbs.register(\n", - " vector_db_id=vector_db_id,\n", - " embedding_model=\"nomic-embed-text-v1.5\",\n", - " embedding_dimension=768,\n", - ")\n", - "client.tool_runtime.rag_tool.insert(\n", - " documents=documents,\n", - " vector_db_id=vector_db_id,\n", - " chunk_size_in_tokens=512,\n", + "# Step 1: Upload files\n", + "file_ids = []\n", + "for i, url in enumerate(urls):\n", + " full_url = f\"https://raw.githubusercontent.com/pytorch/torchtune/main/docs/source/tutorials/{url}\"\n", + " response = requests.get(full_url)\n", + " \n", + " file = client.files.create(\n", + " file=response.content,\n", + " purpose='assistants'\n", + " )\n", + " file_ids.append(file.id)\n", + " \n", + "\n", + "# Step 2: Create a vector store with files\n", + "vector_store = client.vector_stores.create(\n", + " name=f\"torchtune-docs-{uuid.uuid4().hex[:8]}\",\n", + " file_ids=file_ids,\n", + " chunking_strategy={\n", + " \"type\": \"static\",\n", + " \"static\": {\n", + " \"max_chunk_size_tokens\": 512,\n", + " \"chunk_overlap_tokens\": 50\n", + " }\n", + " }\n", ")\n", + "\n", + "cprint(f\"Created vector store: {vector_store.id}\", \"cyan\")" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "id": "3ebacfcb", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/conversations \"HTTP/1.1 200 OK\"\n", + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/responses \"HTTP/1.1 200 OK\"\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[32mUser> What are the top 5 topics that were explained? Only list succinct bullet points.\u001b[0m\n", + "🤔 \n", + "\n", + "🔧 Executing file_search (server-side)...\n", + "🤔 Here are the top 5 topics explained:\n", + "\n", + "* LoRA (Low-Rank Adaptation) and its application in fine-tuning large language models\n", + "* QLoRA (Quantized Low-Rank Adaptation) and its benefits in reducing memory usage\n", + "* Activation checkpointing and its trade-offs between memory and compute\n", + "* Model precision and its impact on memory usage and training speed\n", + "* Prompt templates and special tokens in Llama2 and Llama3 models\n" + ] + } + ], + "source": [ + "# Ask the agent a question related to the uploaded files\n", "rag_agent = Agent(\n", " client,\n", " model=model_id,\n", " instructions=\"You are a helpful assistant\",\n", " tools = [\n", " {\n", - " \"name\": \"builtin::rag/knowledge_search\",\n", - " \"args\" : {\n", - " \"vector_db_ids\": [vector_db_id],\n", - " }\n", + " \"type\": \"file_search\",\n", + " \"vector_store_ids\": [vector_store.id],\n", " }\n", " ],\n", ")\n", @@ -1385,7 +2096,7 @@ " session_id=session_id,\n", " )\n", " for log in AgentEventLogger().log(response):\n", - " log.print()" + " print(log, end=\"\", flush=True)" ] }, { @@ -1395,7 +2106,7 @@ "id": "jSfjNN9fMxtm" }, "source": [ - "### 2.4. Using Model Context Protocol\n", + "### 2.3. Using Model Context Protocol\n", "\n", "In this example, we will show how tools hosted in an MCP server can be configured to be used by the model.\n", "\n", @@ -1406,7 +2117,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 69, "id": "67fDKVVpNuFb", "metadata": { "colab": { @@ -1420,15 +2131,28 @@ "name": "stdout", "output_type": "stream", "text": [ - "Requirement already satisfied: colab-xterm in /opt/homebrew/Caskroom/miniconda/base/envs/stack/lib/python3.10/site-packages (0.2.0)\n", - "Requirement already satisfied: ptyprocess~=0.7.0 in /opt/homebrew/Caskroom/miniconda/base/envs/stack/lib/python3.10/site-packages (from colab-xterm) (0.7.0)\n", - "Requirement already satisfied: tornado>5.1 in /opt/homebrew/Caskroom/miniconda/base/envs/stack/lib/python3.10/site-packages (from colab-xterm) (6.4.2)\n" + "\u001b[2mUsing Python 3.12.11 environment at: /Users/erichuang/projects/lst3/.venv\u001b[0m\n", + "\u001b[2K\u001b[2mResolved \u001b[1m3 packages\u001b[0m \u001b[2min 381ms\u001b[0m\u001b[0m \u001b[0m\n", + "\u001b[2K\u001b[37m⠙\u001b[0m \u001b[2mPreparing packages...\u001b[0m (0/1) \n", + "\u001b[2K\u001b[1A\u001b[37m⠙\u001b[0m \u001b[2mPreparing packages...\u001b[0m (0/1)--------------\u001b[0m\u001b[0m 0 B/112.88 KiB \u001b[1A\n", + "\u001b[2K\u001b[1A\u001b[37m⠙\u001b[0m \u001b[2mPreparing packages...\u001b[0m (0/1)--------------\u001b[0m\u001b[0m 16.00 KiB/112.88 KiB \u001b[1A\n", + "\u001b[2K\u001b[1A\u001b[37m⠙\u001b[0m \u001b[2mPreparing packages...\u001b[0m (0/1)--------------\u001b[0m\u001b[0m 32.00 KiB/112.88 KiB \u001b[1A\n", + "\u001b[2K\u001b[1A\u001b[37m⠙\u001b[0m \u001b[2mPreparing packages...\u001b[0m (0/1)--------------\u001b[0m\u001b[0m 48.00 KiB/112.88 KiB \u001b[1A\n", + "\u001b[2K\u001b[1A\u001b[37m⠙\u001b[0m \u001b[2mPreparing packages...\u001b[0m (0/1)2m------------\u001b[0m\u001b[0m 64.00 KiB/112.88 KiB \u001b[1A\n", + "\u001b[2K\u001b[1A\u001b[37m⠙\u001b[0m \u001b[2mPreparing packages...\u001b[0m (0/1)--\u001b[2m--------\u001b[0m\u001b[0m 80.00 KiB/112.88 KiB \u001b[1A\n", + "\u001b[2K\u001b[1A\u001b[37m⠙\u001b[0m \u001b[2mPreparing packages...\u001b[0m (0/1)------\u001b[2m----\u001b[0m\u001b[0m 96.00 KiB/112.88 KiB \u001b[1A\n", + "\u001b[2K\u001b[1A\u001b[37m⠙\u001b[0m \u001b[2mPreparing packages...\u001b[0m (0/1)----------\u001b[2m\u001b[0m\u001b[0m 112.00 KiB/112.88 KiB \u001b[1A\n", + "\u001b[2K\u001b[1A\u001b[37m⠙\u001b[0m \u001b[2mPreparing packages...\u001b[0m (0/1)----------\u001b[2m\u001b[0m\u001b[0m 112.88 KiB/112.88 KiB \u001b[1A\n", + "\u001b[2K\u001b[2mPrepared \u001b[1m1 package\u001b[0m \u001b[2min 45ms\u001b[0m\u001b[0m \u001b[1A\n", + "\u001b[2K\u001b[2mInstalled \u001b[1m1 package\u001b[0m \u001b[2min 16ms\u001b[0m\u001b[0m \u001b[0m\n", + " \u001b[32m+\u001b[39m \u001b[1mcolab-xterm\u001b[0m\u001b[2m==0.2.0\u001b[0m\n" ] } ], "source": [ "# NBVAL_SKIP\n", - "!pip install colab-xterm #https://pypi.org/project/colab-xterm/\n", + "## If running on Colab:\n", + "!uv pip install colab-xterm #https://pypi.org/project/colab-xterm/\n", "%load_ext colabxterm" ] }, @@ -1782,14 +2506,64 @@ "id": "giIA2M-ANUIM", "outputId": "612c3487-1fd7-41ab-f65a-690b1325f46d" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "Launching Xterm..." + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🚀 Listen to 10001\n", + "{\"success\": true, \"reason\": null}\n", + "\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "# NBVAL_SKIP\n", + "## If running on Colab:\n", + "\n", "%xterm\n", - "# touch /content/foo\n", - "# echo hello > /content/foo\n", - "# touch /content/bar\n", - "# npx -y supergateway --port 8000 --stdio 'npx -y @modelcontextprotocol/server-filesystem /content'" + "% mkdir /tmp/content\n", + "\n", + "# To be run in the terminal:\n", + "# touch /tmp/content/foo\n", + "# echo hello > /tmp/content/foo\n", + "# touch /tmp/content/bar\n", + "# npx -y supergateway --port 8000 --stdio 'npx -y @modelcontextprotocol/server-filesystem /tmp/content'" ] }, { @@ -1804,352 +2578,7 @@ }, { "cell_type": "code", - "execution_count": 18, - "id": "DwdKhQb1N295", - "metadata": { - "id": "DwdKhQb1N295" - }, - "outputs": [], - "source": [ - "# NBVAL_SKIP\n", - "from llama_stack_client.types.toolgroup_register_params import McpEndpoint\n", - "client.toolgroups.register(\n", - " toolgroup_id=\"mcp::filesystem\",\n", - " provider_id=\"model-context-protocol\",\n", - " mcp_endpoint=McpEndpoint(uri=\"http://localhost:8000/sse\"),\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "id": "ZZ5_vIkDOyAN", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/", - "height": 1000 - }, - "id": "ZZ5_vIkDOyAN", - "outputId": "f6fa8639-c2d8-497d-f4ed-716b3bf775d4" - }, - "outputs": [ - { - "data": { - "text/html": [ - "
[\n",
-       "Tool(\n",
-       "│   │   description='Read the complete contents of a file from the file system. Handles various text encodings and provides detailed error messages if the file cannot be read. Use this tool when you need to examine the contents of a single file. Only works within allowed directories.',\n",
-       "│   │   identifier='read_file',\n",
-       "│   │   parameters=[Parameter(description='', name='path', parameter_type='string', required=True, default=None)],\n",
-       "│   │   provider_id='model-context-protocol',\n",
-       "│   │   provider_resource_id='read_file',\n",
-       "│   │   tool_host='model_context_protocol',\n",
-       "│   │   toolgroup_id='mcp::filesystem',\n",
-       "│   │   type='tool',\n",
-       "│   │   metadata={'endpoint': 'http://localhost:8000/sse'}\n",
-       "),\n",
-       "Tool(\n",
-       "│   │   description=\"Read the contents of multiple files simultaneously. This is more efficient than reading files one by one when you need to analyze or compare multiple files. Each file's content is returned with its path as a reference. Failed reads for individual files won't stop the entire operation. Only works within allowed directories.\",\n",
-       "│   │   identifier='read_multiple_files',\n",
-       "│   │   parameters=[Parameter(description='', name='paths', parameter_type='array', required=True, default=None)],\n",
-       "│   │   provider_id='model-context-protocol',\n",
-       "│   │   provider_resource_id='read_multiple_files',\n",
-       "│   │   tool_host='model_context_protocol',\n",
-       "│   │   toolgroup_id='mcp::filesystem',\n",
-       "│   │   type='tool',\n",
-       "│   │   metadata={'endpoint': 'http://localhost:8000/sse'}\n",
-       "),\n",
-       "Tool(\n",
-       "│   │   description='Create a new file or completely overwrite an existing file with new content. Use with caution as it will overwrite existing files without warning. Handles text content with proper encoding. Only works within allowed directories.',\n",
-       "│   │   identifier='write_file',\n",
-       "│   │   parameters=[\n",
-       "│   │   │   Parameter(description='', name='path', parameter_type='string', required=True, default=None),\n",
-       "│   │   │   Parameter(description='', name='content', parameter_type='string', required=True, default=None)\n",
-       "│   │   ],\n",
-       "│   │   provider_id='model-context-protocol',\n",
-       "│   │   provider_resource_id='write_file',\n",
-       "│   │   tool_host='model_context_protocol',\n",
-       "│   │   toolgroup_id='mcp::filesystem',\n",
-       "│   │   type='tool',\n",
-       "│   │   metadata={'endpoint': 'http://localhost:8000/sse'}\n",
-       "),\n",
-       "Tool(\n",
-       "│   │   description='Make line-based edits to a text file. Each edit replaces exact line sequences with new content. Returns a git-style diff showing the changes made. Only works within allowed directories.',\n",
-       "│   │   identifier='edit_file',\n",
-       "│   │   parameters=[\n",
-       "│   │   │   Parameter(description='', name='path', parameter_type='string', required=True, default=None),\n",
-       "│   │   │   Parameter(description='', name='edits', parameter_type='array', required=True, default=None),\n",
-       "│   │   │   Parameter(\n",
-       "│   │   │   │   description='Preview changes using git-style diff format',\n",
-       "│   │   │   │   name='dryRun',\n",
-       "│   │   │   │   parameter_type='boolean',\n",
-       "│   │   │   │   required=True,\n",
-       "│   │   │   │   default=None\n",
-       "│   │   │   )\n",
-       "│   │   ],\n",
-       "│   │   provider_id='model-context-protocol',\n",
-       "│   │   provider_resource_id='edit_file',\n",
-       "│   │   tool_host='model_context_protocol',\n",
-       "│   │   toolgroup_id='mcp::filesystem',\n",
-       "│   │   type='tool',\n",
-       "│   │   metadata={'endpoint': 'http://localhost:8000/sse'}\n",
-       "),\n",
-       "Tool(\n",
-       "│   │   description='Create a new directory or ensure a directory exists. Can create multiple nested directories in one operation. If the directory already exists, this operation will succeed silently. Perfect for setting up directory structures for projects or ensuring required paths exist. Only works within allowed directories.',\n",
-       "│   │   identifier='create_directory',\n",
-       "│   │   parameters=[Parameter(description='', name='path', parameter_type='string', required=True, default=None)],\n",
-       "│   │   provider_id='model-context-protocol',\n",
-       "│   │   provider_resource_id='create_directory',\n",
-       "│   │   tool_host='model_context_protocol',\n",
-       "│   │   toolgroup_id='mcp::filesystem',\n",
-       "│   │   type='tool',\n",
-       "│   │   metadata={'endpoint': 'http://localhost:8000/sse'}\n",
-       "),\n",
-       "Tool(\n",
-       "│   │   description='Get a detailed listing of all files and directories in a specified path. Results clearly distinguish between files and directories with [FILE] and [DIR] prefixes. This tool is essential for understanding directory structure and finding specific files within a directory. Only works within allowed directories.',\n",
-       "│   │   identifier='list_directory',\n",
-       "│   │   parameters=[Parameter(description='', name='path', parameter_type='string', required=True, default=None)],\n",
-       "│   │   provider_id='model-context-protocol',\n",
-       "│   │   provider_resource_id='list_directory',\n",
-       "│   │   tool_host='model_context_protocol',\n",
-       "│   │   toolgroup_id='mcp::filesystem',\n",
-       "│   │   type='tool',\n",
-       "│   │   metadata={'endpoint': 'http://localhost:8000/sse'}\n",
-       "),\n",
-       "Tool(\n",
-       "│   │   description=\"Get a recursive tree view of files and directories as a JSON structure. Each entry includes 'name', 'type' (file/directory), and 'children' for directories. Files have no children array, while directories always have a children array (which may be empty). The output is formatted with 2-space indentation for readability. Only works within allowed directories.\",\n",
-       "│   │   identifier='directory_tree',\n",
-       "│   │   parameters=[Parameter(description='', name='path', parameter_type='string', required=True, default=None)],\n",
-       "│   │   provider_id='model-context-protocol',\n",
-       "│   │   provider_resource_id='directory_tree',\n",
-       "│   │   tool_host='model_context_protocol',\n",
-       "│   │   toolgroup_id='mcp::filesystem',\n",
-       "│   │   type='tool',\n",
-       "│   │   metadata={'endpoint': 'http://localhost:8000/sse'}\n",
-       "),\n",
-       "Tool(\n",
-       "│   │   description='Move or rename files and directories. Can move files between directories and rename them in a single operation. If the destination exists, the operation will fail. Works across different directories and can be used for simple renaming within the same directory. Both source and destination must be within allowed directories.',\n",
-       "│   │   identifier='move_file',\n",
-       "│   │   parameters=[\n",
-       "│   │   │   Parameter(description='', name='source', parameter_type='string', required=True, default=None),\n",
-       "│   │   │   Parameter(description='', name='destination', parameter_type='string', required=True, default=None)\n",
-       "│   │   ],\n",
-       "│   │   provider_id='model-context-protocol',\n",
-       "│   │   provider_resource_id='move_file',\n",
-       "│   │   tool_host='model_context_protocol',\n",
-       "│   │   toolgroup_id='mcp::filesystem',\n",
-       "│   │   type='tool',\n",
-       "│   │   metadata={'endpoint': 'http://localhost:8000/sse'}\n",
-       "),\n",
-       "Tool(\n",
-       "│   │   description=\"Recursively search for files and directories matching a pattern. Searches through all subdirectories from the starting path. The search is case-insensitive and matches partial names. Returns full paths to all matching items. Great for finding files when you don't know their exact location. Only searches within allowed directories.\",\n",
-       "│   │   identifier='search_files',\n",
-       "│   │   parameters=[\n",
-       "│   │   │   Parameter(description='', name='path', parameter_type='string', required=True, default=None),\n",
-       "│   │   │   Parameter(description='', name='pattern', parameter_type='string', required=True, default=None),\n",
-       "│   │   │   Parameter(\n",
-       "│   │   │   │   description='',\n",
-       "│   │   │   │   name='excludePatterns',\n",
-       "│   │   │   │   parameter_type='array',\n",
-       "│   │   │   │   required=True,\n",
-       "│   │   │   │   default=None\n",
-       "│   │   │   )\n",
-       "│   │   ],\n",
-       "│   │   provider_id='model-context-protocol',\n",
-       "│   │   provider_resource_id='search_files',\n",
-       "│   │   tool_host='model_context_protocol',\n",
-       "│   │   toolgroup_id='mcp::filesystem',\n",
-       "│   │   type='tool',\n",
-       "│   │   metadata={'endpoint': 'http://localhost:8000/sse'}\n",
-       "),\n",
-       "Tool(\n",
-       "│   │   description='Retrieve detailed metadata about a file or directory. Returns comprehensive information including size, creation time, last modified time, permissions, and type. This tool is perfect for understanding file characteristics without reading the actual content. Only works within allowed directories.',\n",
-       "│   │   identifier='get_file_info',\n",
-       "│   │   parameters=[Parameter(description='', name='path', parameter_type='string', required=True, default=None)],\n",
-       "│   │   provider_id='model-context-protocol',\n",
-       "│   │   provider_resource_id='get_file_info',\n",
-       "│   │   tool_host='model_context_protocol',\n",
-       "│   │   toolgroup_id='mcp::filesystem',\n",
-       "│   │   type='tool',\n",
-       "│   │   metadata={'endpoint': 'http://localhost:8000/sse'}\n",
-       "),\n",
-       "Tool(\n",
-       "│   │   description='Returns the list of directories that this server is allowed to access. Use this to understand which directories are available before trying to access files.',\n",
-       "│   │   identifier='list_allowed_directories',\n",
-       "│   │   parameters=[],\n",
-       "│   │   provider_id='model-context-protocol',\n",
-       "│   │   provider_resource_id='list_allowed_directories',\n",
-       "│   │   tool_host='model_context_protocol',\n",
-       "│   │   toolgroup_id='mcp::filesystem',\n",
-       "│   │   type='tool',\n",
-       "│   │   metadata={'endpoint': 'http://localhost:8000/sse'}\n",
-       ")\n",
-       "]\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[1m[\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1;35mTool\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m'Read the complete contents of a file from the file system. Handles various text encodings and provides detailed error messages if the file cannot be read. Use this tool when you need to examine the contents of a single file. Only works within allowed directories.'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33midentifier\u001b[0m=\u001b[32m'read_file'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mparameters\u001b[0m=\u001b[1m[\u001b[0m\u001b[1;35mParameter\u001b[0m\u001b[1m(\u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m''\u001b[0m, \u001b[33mname\u001b[0m=\u001b[32m'path'\u001b[0m, \u001b[33mparameter_type\u001b[0m=\u001b[32m'string'\u001b[0m, \u001b[33mrequired\u001b[0m=\u001b[3;92mTrue\u001b[0m, \u001b[33mdefault\u001b[0m=\u001b[3;35mNone\u001b[0m\u001b[1m)\u001b[0m\u001b[1m]\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mprovider_id\u001b[0m=\u001b[32m'model-context-protocol'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mprovider_resource_id\u001b[0m=\u001b[32m'read_file'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtool_host\u001b[0m=\u001b[32m'model_context_protocol'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtoolgroup_id\u001b[0m=\u001b[32m'mcp::filesystem'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtype\u001b[0m=\u001b[32m'tool'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mmetadata\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'endpoint'\u001b[0m: \u001b[32m'http://localhost:8000/sse'\u001b[0m\u001b[1m}\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[1;35mTool\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m\"Read\u001b[0m\u001b[32m the contents of multiple files simultaneously. This is more efficient than reading files one by one when you need to analyze or compare multiple files. Each file's content is returned with its path as a reference. Failed reads for individual files won't stop the entire operation. Only works within allowed directories.\"\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33midentifier\u001b[0m=\u001b[32m'read_multiple_files'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mparameters\u001b[0m=\u001b[1m[\u001b[0m\u001b[1;35mParameter\u001b[0m\u001b[1m(\u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m''\u001b[0m, \u001b[33mname\u001b[0m=\u001b[32m'paths'\u001b[0m, \u001b[33mparameter_type\u001b[0m=\u001b[32m'array'\u001b[0m, \u001b[33mrequired\u001b[0m=\u001b[3;92mTrue\u001b[0m, \u001b[33mdefault\u001b[0m=\u001b[3;35mNone\u001b[0m\u001b[1m)\u001b[0m\u001b[1m]\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mprovider_id\u001b[0m=\u001b[32m'model-context-protocol'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mprovider_resource_id\u001b[0m=\u001b[32m'read_multiple_files'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtool_host\u001b[0m=\u001b[32m'model_context_protocol'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtoolgroup_id\u001b[0m=\u001b[32m'mcp::filesystem'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtype\u001b[0m=\u001b[32m'tool'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mmetadata\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'endpoint'\u001b[0m: \u001b[32m'http://localhost:8000/sse'\u001b[0m\u001b[1m}\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[1;35mTool\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m'Create a new file or completely overwrite an existing file with new content. Use with caution as it will overwrite existing files without warning. Handles text content with proper encoding. Only works within allowed directories.'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33midentifier\u001b[0m=\u001b[32m'write_file'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mparameters\u001b[0m=\u001b[1m[\u001b[0m\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[1;35mParameter\u001b[0m\u001b[1m(\u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m''\u001b[0m, \u001b[33mname\u001b[0m=\u001b[32m'path'\u001b[0m, \u001b[33mparameter_type\u001b[0m=\u001b[32m'string'\u001b[0m, \u001b[33mrequired\u001b[0m=\u001b[3;92mTrue\u001b[0m, \u001b[33mdefault\u001b[0m=\u001b[3;35mNone\u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[1;35mParameter\u001b[0m\u001b[1m(\u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m''\u001b[0m, \u001b[33mname\u001b[0m=\u001b[32m'content'\u001b[0m, \u001b[33mparameter_type\u001b[0m=\u001b[32m'string'\u001b[0m, \u001b[33mrequired\u001b[0m=\u001b[3;92mTrue\u001b[0m, \u001b[33mdefault\u001b[0m=\u001b[3;35mNone\u001b[0m\u001b[1m)\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[1m]\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mprovider_id\u001b[0m=\u001b[32m'model-context-protocol'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mprovider_resource_id\u001b[0m=\u001b[32m'write_file'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtool_host\u001b[0m=\u001b[32m'model_context_protocol'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtoolgroup_id\u001b[0m=\u001b[32m'mcp::filesystem'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtype\u001b[0m=\u001b[32m'tool'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mmetadata\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'endpoint'\u001b[0m: \u001b[32m'http://localhost:8000/sse'\u001b[0m\u001b[1m}\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[1;35mTool\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m'Make line-based edits to a text file. Each edit replaces exact line sequences with new content. Returns a git-style diff showing the changes made. Only works within allowed directories.'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33midentifier\u001b[0m=\u001b[32m'edit_file'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mparameters\u001b[0m=\u001b[1m[\u001b[0m\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[1;35mParameter\u001b[0m\u001b[1m(\u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m''\u001b[0m, \u001b[33mname\u001b[0m=\u001b[32m'path'\u001b[0m, \u001b[33mparameter_type\u001b[0m=\u001b[32m'string'\u001b[0m, \u001b[33mrequired\u001b[0m=\u001b[3;92mTrue\u001b[0m, \u001b[33mdefault\u001b[0m=\u001b[3;35mNone\u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[1;35mParameter\u001b[0m\u001b[1m(\u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m''\u001b[0m, \u001b[33mname\u001b[0m=\u001b[32m'edits'\u001b[0m, \u001b[33mparameter_type\u001b[0m=\u001b[32m'array'\u001b[0m, \u001b[33mrequired\u001b[0m=\u001b[3;92mTrue\u001b[0m, \u001b[33mdefault\u001b[0m=\u001b[3;35mNone\u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[1;35mParameter\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m'Preview changes using git-style diff format'\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[33mname\u001b[0m=\u001b[32m'dryRun'\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[33mparameter_type\u001b[0m=\u001b[32m'boolean'\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[33mrequired\u001b[0m=\u001b[3;92mTrue\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[33mdefault\u001b[0m=\u001b[3;35mNone\u001b[0m\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m)\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[1m]\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mprovider_id\u001b[0m=\u001b[32m'model-context-protocol'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mprovider_resource_id\u001b[0m=\u001b[32m'edit_file'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtool_host\u001b[0m=\u001b[32m'model_context_protocol'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtoolgroup_id\u001b[0m=\u001b[32m'mcp::filesystem'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtype\u001b[0m=\u001b[32m'tool'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mmetadata\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'endpoint'\u001b[0m: \u001b[32m'http://localhost:8000/sse'\u001b[0m\u001b[1m}\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[1;35mTool\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m'Create a new directory or ensure a directory exists. Can create multiple nested directories in one operation. If the directory already exists, this operation will succeed silently. Perfect for setting up directory structures for projects or ensuring required paths exist. Only works within allowed directories.'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33midentifier\u001b[0m=\u001b[32m'create_directory'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mparameters\u001b[0m=\u001b[1m[\u001b[0m\u001b[1;35mParameter\u001b[0m\u001b[1m(\u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m''\u001b[0m, \u001b[33mname\u001b[0m=\u001b[32m'path'\u001b[0m, \u001b[33mparameter_type\u001b[0m=\u001b[32m'string'\u001b[0m, \u001b[33mrequired\u001b[0m=\u001b[3;92mTrue\u001b[0m, \u001b[33mdefault\u001b[0m=\u001b[3;35mNone\u001b[0m\u001b[1m)\u001b[0m\u001b[1m]\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mprovider_id\u001b[0m=\u001b[32m'model-context-protocol'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mprovider_resource_id\u001b[0m=\u001b[32m'create_directory'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtool_host\u001b[0m=\u001b[32m'model_context_protocol'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtoolgroup_id\u001b[0m=\u001b[32m'mcp::filesystem'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtype\u001b[0m=\u001b[32m'tool'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mmetadata\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'endpoint'\u001b[0m: \u001b[32m'http://localhost:8000/sse'\u001b[0m\u001b[1m}\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[1;35mTool\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m'Get a detailed listing of all files and directories in a specified path. Results clearly distinguish between files and directories with \u001b[0m\u001b[32m[\u001b[0m\u001b[32mFILE\u001b[0m\u001b[32m]\u001b[0m\u001b[32m and \u001b[0m\u001b[32m[\u001b[0m\u001b[32mDIR\u001b[0m\u001b[32m]\u001b[0m\u001b[32m prefixes. This tool is essential for understanding directory structure and finding specific files within a directory. Only works within allowed directories.'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33midentifier\u001b[0m=\u001b[32m'list_directory'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mparameters\u001b[0m=\u001b[1m[\u001b[0m\u001b[1;35mParameter\u001b[0m\u001b[1m(\u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m''\u001b[0m, \u001b[33mname\u001b[0m=\u001b[32m'path'\u001b[0m, \u001b[33mparameter_type\u001b[0m=\u001b[32m'string'\u001b[0m, \u001b[33mrequired\u001b[0m=\u001b[3;92mTrue\u001b[0m, \u001b[33mdefault\u001b[0m=\u001b[3;35mNone\u001b[0m\u001b[1m)\u001b[0m\u001b[1m]\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mprovider_id\u001b[0m=\u001b[32m'model-context-protocol'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mprovider_resource_id\u001b[0m=\u001b[32m'list_directory'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtool_host\u001b[0m=\u001b[32m'model_context_protocol'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtoolgroup_id\u001b[0m=\u001b[32m'mcp::filesystem'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtype\u001b[0m=\u001b[32m'tool'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mmetadata\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'endpoint'\u001b[0m: \u001b[32m'http://localhost:8000/sse'\u001b[0m\u001b[1m}\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[1;35mTool\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m\"Get\u001b[0m\u001b[32m a recursive tree view of files and directories as a JSON structure. Each entry includes 'name', 'type' \u001b[0m\u001b[32m(\u001b[0m\u001b[32mfile/directory\u001b[0m\u001b[32m)\u001b[0m\u001b[32m, and 'children' for directories. Files have no children array, while directories always have a children array \u001b[0m\u001b[32m(\u001b[0m\u001b[32mwhich may be empty\u001b[0m\u001b[32m)\u001b[0m\u001b[32m. The output is formatted with 2-space indentation for readability. Only works within allowed directories.\"\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33midentifier\u001b[0m=\u001b[32m'directory_tree'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mparameters\u001b[0m=\u001b[1m[\u001b[0m\u001b[1;35mParameter\u001b[0m\u001b[1m(\u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m''\u001b[0m, \u001b[33mname\u001b[0m=\u001b[32m'path'\u001b[0m, \u001b[33mparameter_type\u001b[0m=\u001b[32m'string'\u001b[0m, \u001b[33mrequired\u001b[0m=\u001b[3;92mTrue\u001b[0m, \u001b[33mdefault\u001b[0m=\u001b[3;35mNone\u001b[0m\u001b[1m)\u001b[0m\u001b[1m]\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mprovider_id\u001b[0m=\u001b[32m'model-context-protocol'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mprovider_resource_id\u001b[0m=\u001b[32m'directory_tree'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtool_host\u001b[0m=\u001b[32m'model_context_protocol'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtoolgroup_id\u001b[0m=\u001b[32m'mcp::filesystem'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtype\u001b[0m=\u001b[32m'tool'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mmetadata\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'endpoint'\u001b[0m: \u001b[32m'http://localhost:8000/sse'\u001b[0m\u001b[1m}\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[1;35mTool\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m'Move or rename files and directories. Can move files between directories and rename them in a single operation. If the destination exists, the operation will fail. Works across different directories and can be used for simple renaming within the same directory. Both source and destination must be within allowed directories.'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33midentifier\u001b[0m=\u001b[32m'move_file'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mparameters\u001b[0m=\u001b[1m[\u001b[0m\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[1;35mParameter\u001b[0m\u001b[1m(\u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m''\u001b[0m, \u001b[33mname\u001b[0m=\u001b[32m'source'\u001b[0m, \u001b[33mparameter_type\u001b[0m=\u001b[32m'string'\u001b[0m, \u001b[33mrequired\u001b[0m=\u001b[3;92mTrue\u001b[0m, \u001b[33mdefault\u001b[0m=\u001b[3;35mNone\u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[1;35mParameter\u001b[0m\u001b[1m(\u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m''\u001b[0m, \u001b[33mname\u001b[0m=\u001b[32m'destination'\u001b[0m, \u001b[33mparameter_type\u001b[0m=\u001b[32m'string'\u001b[0m, \u001b[33mrequired\u001b[0m=\u001b[3;92mTrue\u001b[0m, \u001b[33mdefault\u001b[0m=\u001b[3;35mNone\u001b[0m\u001b[1m)\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[1m]\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mprovider_id\u001b[0m=\u001b[32m'model-context-protocol'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mprovider_resource_id\u001b[0m=\u001b[32m'move_file'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtool_host\u001b[0m=\u001b[32m'model_context_protocol'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtoolgroup_id\u001b[0m=\u001b[32m'mcp::filesystem'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtype\u001b[0m=\u001b[32m'tool'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mmetadata\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'endpoint'\u001b[0m: \u001b[32m'http://localhost:8000/sse'\u001b[0m\u001b[1m}\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[1;35mTool\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m\"Recursively\u001b[0m\u001b[32m search for files and directories matching a pattern. Searches through all subdirectories from the starting path. The search is case-insensitive and matches partial names. Returns full paths to all matching items. Great for finding files when you don't know their exact location. Only searches within allowed directories.\"\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33midentifier\u001b[0m=\u001b[32m'search_files'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mparameters\u001b[0m=\u001b[1m[\u001b[0m\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[1;35mParameter\u001b[0m\u001b[1m(\u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m''\u001b[0m, \u001b[33mname\u001b[0m=\u001b[32m'path'\u001b[0m, \u001b[33mparameter_type\u001b[0m=\u001b[32m'string'\u001b[0m, \u001b[33mrequired\u001b[0m=\u001b[3;92mTrue\u001b[0m, \u001b[33mdefault\u001b[0m=\u001b[3;35mNone\u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[1;35mParameter\u001b[0m\u001b[1m(\u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m''\u001b[0m, \u001b[33mname\u001b[0m=\u001b[32m'pattern'\u001b[0m, \u001b[33mparameter_type\u001b[0m=\u001b[32m'string'\u001b[0m, \u001b[33mrequired\u001b[0m=\u001b[3;92mTrue\u001b[0m, \u001b[33mdefault\u001b[0m=\u001b[3;35mNone\u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[1;35mParameter\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m''\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[33mname\u001b[0m=\u001b[32m'excludePatterns'\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[33mparameter_type\u001b[0m=\u001b[32m'array'\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[33mrequired\u001b[0m=\u001b[3;92mTrue\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[33mdefault\u001b[0m=\u001b[3;35mNone\u001b[0m\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m)\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[1m]\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mprovider_id\u001b[0m=\u001b[32m'model-context-protocol'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mprovider_resource_id\u001b[0m=\u001b[32m'search_files'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtool_host\u001b[0m=\u001b[32m'model_context_protocol'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtoolgroup_id\u001b[0m=\u001b[32m'mcp::filesystem'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtype\u001b[0m=\u001b[32m'tool'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mmetadata\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'endpoint'\u001b[0m: \u001b[32m'http://localhost:8000/sse'\u001b[0m\u001b[1m}\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[1;35mTool\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m'Retrieve detailed metadata about a file or directory. Returns comprehensive information including size, creation time, last modified time, permissions, and type. This tool is perfect for understanding file characteristics without reading the actual content. Only works within allowed directories.'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33midentifier\u001b[0m=\u001b[32m'get_file_info'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mparameters\u001b[0m=\u001b[1m[\u001b[0m\u001b[1;35mParameter\u001b[0m\u001b[1m(\u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m''\u001b[0m, \u001b[33mname\u001b[0m=\u001b[32m'path'\u001b[0m, \u001b[33mparameter_type\u001b[0m=\u001b[32m'string'\u001b[0m, \u001b[33mrequired\u001b[0m=\u001b[3;92mTrue\u001b[0m, \u001b[33mdefault\u001b[0m=\u001b[3;35mNone\u001b[0m\u001b[1m)\u001b[0m\u001b[1m]\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mprovider_id\u001b[0m=\u001b[32m'model-context-protocol'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mprovider_resource_id\u001b[0m=\u001b[32m'get_file_info'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtool_host\u001b[0m=\u001b[32m'model_context_protocol'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtoolgroup_id\u001b[0m=\u001b[32m'mcp::filesystem'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtype\u001b[0m=\u001b[32m'tool'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mmetadata\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'endpoint'\u001b[0m: \u001b[32m'http://localhost:8000/sse'\u001b[0m\u001b[1m}\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[1;35mTool\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mdescription\u001b[0m=\u001b[32m'Returns the list of directories that this server is allowed to access. Use this to understand which directories are available before trying to access files.'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33midentifier\u001b[0m=\u001b[32m'list_allowed_directories'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mparameters\u001b[0m=\u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mprovider_id\u001b[0m=\u001b[32m'model-context-protocol'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mprovider_resource_id\u001b[0m=\u001b[32m'list_allowed_directories'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtool_host\u001b[0m=\u001b[32m'model_context_protocol'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtoolgroup_id\u001b[0m=\u001b[32m'mcp::filesystem'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mtype\u001b[0m=\u001b[32m'tool'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[33mmetadata\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'endpoint'\u001b[0m: \u001b[32m'http://localhost:8000/sse'\u001b[0m\u001b[1m}\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m)\u001b[0m\n", - "\u001b[1m]\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "pprint(client.tools.list(toolgroup_id=\"mcp::filesystem\"))" - ] - }, - { - "cell_type": "code", - "execution_count": null, + "execution_count": 53, "id": "vttLbj_YO01f", "metadata": { "colab": { @@ -2159,50 +2588,44 @@ "outputId": "04bc486c-3a61-49c6-d0d2-4a211d6de0b5" }, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/conversations \"HTTP/1.1 200 OK\"\n", + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/responses \"HTTP/1.1 200 OK\"\n" + ] + }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[32mUser> Hello\u001b[0m\n", - "\u001b[33minference> \u001b[0m\u001b[33m[list\u001b[0m\u001b[33m_allowed\u001b[0m\u001b[33m_direct\u001b[0m\u001b[33mories\u001b[0m\u001b[33m()]\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[32mtool_execution> Tool:list_allowed_directories Args:{}\u001b[0m\n", - "\u001b[32mtool_execution> Tool:list_allowed_directories Response:{\"type\":\"text\",\"text\":\"Allowed directories:\\n/tmp/content\",\"annotations\":null}\u001b[0m\n", - "\u001b[33minference> \u001b[0m\u001b[33m[list\u001b[0m\u001b[33m_directory\u001b[0m\u001b[33m(path\u001b[0m\u001b[33m=\"/\u001b[0m\u001b[33mtmp\u001b[0m\u001b[33m/content\u001b[0m\u001b[33m\")]\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[32mtool_execution> Tool:list_directory Args:{'path': '/tmp/content'}\u001b[0m\n", - "\u001b[32mtool_execution> Tool:list_directory Response:{\"type\":\"text\",\"text\":\"Error: Parent directory does not exist: /tmp\",\"annotations\":null}\u001b[0m\n", - "\u001b[33minference> \u001b[0m\u001b[33m[\u001b[0m\u001b[33mcreate\u001b[0m\u001b[33m_directory\u001b[0m\u001b[33m(path\u001b[0m\u001b[33m=\"/\u001b[0m\u001b[33mtmp\u001b[0m\u001b[33m/content\u001b[0m\u001b[33m\")]\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[32mtool_execution> Tool:create_directory Args:{'path': '/tmp/content'}\u001b[0m\n", - "\u001b[32mtool_execution> Tool:create_directory Response:{\"type\":\"text\",\"text\":\"Error: Parent directory does not exist: /tmp\",\"annotations\":null}\u001b[0m\n", - "\u001b[33minference> \u001b[0m\u001b[33m[\u001b[0m\u001b[33mcreate\u001b[0m\u001b[33m_directory\u001b[0m\u001b[33m(path\u001b[0m\u001b[33m=\"/\u001b[0m\u001b[33mtmp\u001b[0m\u001b[33m\"),\u001b[0m\u001b[33m create\u001b[0m\u001b[33m_directory\u001b[0m\u001b[33m(path\u001b[0m\u001b[33m=\"/\u001b[0m\u001b[33mtmp\u001b[0m\u001b[33m/content\u001b[0m\u001b[33m\")]\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[32mtool_execution> Tool:create_directory Args:{'path': '/tmp'}\u001b[0m\n", - "\u001b[32mtool_execution> Tool:create_directory Response:{\"type\":\"text\",\"text\":\"Error: Access denied - path outside allowed directories: /tmp not in /tmp/content\",\"annotations\":null}\u001b[0m\n", - "\u001b[33minference> \u001b[0m\u001b[33m[list\u001b[0m\u001b[33m_allowed\u001b[0m\u001b[33m_direct\u001b[0m\u001b[33mories\u001b[0m\u001b[33m()]\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[32mtool_execution> Tool:list_allowed_directories Args:{}\u001b[0m\n", - "\u001b[32mtool_execution> Tool:list_allowed_directories Response:{\"type\":\"text\",\"text\":\"Allowed directories:\\n/tmp/content\",\"annotations\":null}\u001b[0m\n", - "\u001b[33minference> \u001b[0m\u001b[33m[\u001b[0m\u001b[33mcreate\u001b[0m\u001b[33m_directory\u001b[0m\u001b[33m(path\u001b[0m\u001b[33m=\"/\u001b[0m\u001b[33mtmp\u001b[0m\u001b[33m/content\u001b[0m\u001b[33m/sub\u001b[0m\u001b[33mdir\u001b[0m\u001b[33m\")]\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[32mtool_execution> Tool:create_directory Args:{'path': '/tmp/content/subdir'}\u001b[0m\n", - "\u001b[32mtool_execution> Tool:create_directory Response:{\"type\":\"text\",\"text\":\"Error: Parent directory does not exist: /tmp/content\",\"annotations\":null}\u001b[0m\n", - "\u001b[33minference> \u001b[0m\u001b[33m[\u001b[0m\u001b[33mcreate\u001b[0m\u001b[33m_directory\u001b[0m\u001b[33m(path\u001b[0m\u001b[33m=\"/\u001b[0m\u001b[33mtmp\u001b[0m\u001b[33m/content\u001b[0m\u001b[33m\")]\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[32mtool_execution> Tool:create_directory Args:{'path': '/tmp/content'}\u001b[0m\n", - "\u001b[32mtool_execution> Tool:create_directory Response:{\"type\":\"text\",\"text\":\"Error: Parent directory does not exist: /tmp\",\"annotations\":null}\u001b[0m\n", - "\u001b[33minference> \u001b[0m\u001b[33m[list\u001b[0m\u001b[33m_directory\u001b[0m\u001b[33m(path\u001b[0m\u001b[33m=\"/\u001b[0m\u001b[33mtmp\u001b[0m\u001b[33m/content\u001b[0m\u001b[33m\")]\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[32mtool_execution> Tool:list_directory Args:{'path': '/tmp/content'}\u001b[0m\n", - "\u001b[32mtool_execution> Tool:list_directory Response:{\"type\":\"text\",\"text\":\"Error: Parent directory does not exist: /tmp\",\"annotations\":null}\u001b[0m\n", - "\u001b[33minference> \u001b[0m\u001b[33m[\u001b[0m\u001b[33mcreate\u001b[0m\u001b[33m_directory\u001b[0m\u001b[33m(path\u001b[0m\u001b[33m=\"/\u001b[0m\u001b[33mtmp\u001b[0m\u001b[33m/content\u001b[0m\u001b[33m\")]\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[32mtool_execution> Tool:create_directory Args:{'path': '/tmp/content'}\u001b[0m\n", - "\u001b[32mtool_execution> Tool:create_directory Response:{\"type\":\"text\",\"text\":\"Error: Parent directory does not exist: /tmp\",\"annotations\":null}\u001b[0m\n", - "\u001b[33minference> \u001b[0m\u001b[33m[list\u001b[0m\u001b[33m_allowed\u001b[0m\u001b[33m_direct\u001b[0m\u001b[33mories\u001b[0m\u001b[33m()]\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[30m\u001b[0m\u001b[32mUser> Whats written in /tmp/content/foo ?\u001b[0m\n", - "\u001b[33minference> \u001b[0m\u001b[33m[\u001b[0m\u001b[33mread\u001b[0m\u001b[33m_file\u001b[0m\u001b[33m(path\u001b[0m\u001b[33m=\"/\u001b[0m\u001b[33mtmp\u001b[0m\u001b[33m/content\u001b[0m\u001b[33m/foo\u001b[0m\u001b[33m\")]\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[32mtool_execution> Tool:read_file Args:{'path': '/tmp/content/foo'}\u001b[0m\n", - "\u001b[32mtool_execution> Tool:read_file Response:{\"type\":\"text\",\"text\":\"Error: Parent directory does not exist: /tmp/content\",\"annotations\":null}\u001b[0m\n", - "\u001b[33minference> \u001b[0m\u001b[33m[\u001b[0m\u001b[33mcreate\u001b[0m\u001b[33m_directory\u001b[0m\u001b[33m(path\u001b[0m\u001b[33m=\"/\u001b[0m\u001b[33mtmp\u001b[0m\u001b[33m/content\u001b[0m\u001b[33m\")]\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[32mtool_execution> Tool:create_directory Args:{'path': '/tmp/content'}\u001b[0m\n", - "\u001b[32mtool_execution> Tool:create_directory Response:{\"type\":\"text\",\"text\":\"Error: Parent directory does not exist: /tmp\",\"annotations\":null}\u001b[0m\n", - "\u001b[33minference> \u001b[0m\u001b[33m[\u001b[0m\u001b[33mwrite\u001b[0m\u001b[33m_file\u001b[0m\u001b[33m(path\u001b[0m\u001b[33m=\"/\u001b[0m\u001b[33mtmp\u001b[0m\u001b[33m/content\u001b[0m\u001b[33m/foo\u001b[0m\u001b[33m\",\u001b[0m\u001b[33m content\u001b[0m\u001b[33m=\"\u001b[0m\u001b[33mHello\u001b[0m\u001b[33m World\u001b[0m\u001b[33m!\u001b[0m\u001b[33m\")]\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[32mtool_execution> Tool:write_file Args:{'path': '/tmp/content/foo', 'content': 'Hello World!'}\u001b[0m\n", - "\u001b[32mtool_execution> Tool:write_file Response:{\"type\":\"text\",\"text\":\"Error: Parent directory does not exist: /tmp/content\",\"annotations\":null}\u001b[0m\n", - "\u001b[33minference> \u001b[0m\u001b[31m500: Internal server error: An unexpected error occurred.\u001b[0m\n" + "🤔 \n", + "\n", + "🔧 Executing mcp_list_tools (server-side)...\n", + "🤔 Hi there! How can I assist you today?\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/responses \"HTTP/1.1 200 OK\"\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[32mUser> Whats written in /private/tmp/content/foo ?\u001b[0m\n", + "🤔 \n", + "\n", + "🔧 Executing mcp_list_tools (server-side)...\n", + "🤔 \n", + "\n", + "🔧 Executing mcp_call (server-side)...\n", + "🤔 The file located at `/private/tmp/content/foo` contains the text \"hi\".\n" ] } ], @@ -2215,11 +2638,15 @@ " client,\n", " model=model_id,\n", " instructions=\"You are a helpful assistant\",\n", - " tools=[\"mcp::filesystem\"],\n", + " tools=[{\n", + " \"type\": \"mcp\",\n", + " \"server_label\": \"filesystem\",\n", + " \"server_url\": \"http://localhost:8000/sse\",\n", + " }],\n", ")\n", "user_prompts = [\n", " \"Hello\",\n", - " \"Whats written in /content/foo ?\",\n", + " \"Whats written in /private/tmp/content/foo ?\",\n", "]\n", "\n", "session_id = agent.create_session(\"test-session\")\n", @@ -2235,590 +2662,7 @@ " session_id=session_id,\n", " )\n", " for log in AgentEventLogger().log(response):\n", - " log.print()\n" - ] - }, - { - "cell_type": "markdown", - "id": "FJ85DUhgBZd7", - "metadata": { - "id": "FJ85DUhgBZd7" - }, - "source": [ - "## 3. Llama Stack Agent Evaluations\n" - ] - }, - { - "cell_type": "markdown", - "id": "ydeBDpDT5VHd", - "metadata": { - "id": "ydeBDpDT5VHd" - }, - "source": [ - "#### 3.1. Online Evaluation Dataset Collection\n", - "\n", - "- Llama Stack allows you to query each steps of the agents execution in your application. \n", - "- In this example, we will show how to \n", - " 1. build an Agent with Llama Stack\n", - " 2. Query the agent's session, turns, and steps\n", - " 3. Evaluate the results" - ] - }, - { - "cell_type": "markdown", - "id": "_t_tcWq0JcJ4", - "metadata": { - "id": "_t_tcWq0JcJ4" - }, - "source": [ - "##### 3.1.1. Building a Search Agent\n", - "\n", - "First, let's build an agent that have access to a search tool with Llama Stack, and use it to run some user queries. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "4iCO59kP20Zs", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "4iCO59kP20Zs", - "outputId": "894c6333-30e9-4f1e-9b63-1bfb1cae51e2" - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[33minference> \u001b[0m\u001b[36m\u001b[0m\u001b[36mbr\u001b[0m\u001b[36mave\u001b[0m\u001b[36m_search\u001b[0m\u001b[36m.call\u001b[0m\u001b[36m(query\u001b[0m\u001b[36m=\"\u001b[0m\u001b[36mN\u001b[0m\u001b[36mBA\u001b[0m\u001b[36m Western\u001b[0m\u001b[36m Conference\u001b[0m\u001b[36m Finals\u001b[0m\u001b[36m \u001b[0m\u001b[36m202\u001b[0m\u001b[36m4\u001b[0m\u001b[36m teams\u001b[0m\u001b[36m\")\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[32mtool_execution> Tool:brave_search Args:{'query': 'NBA Western Conference Finals 2024 teams'}\u001b[0m\n", - "\u001b[32mtool_execution> Tool:brave_search Response:{\"query\": \"NBA Western Conference Finals 2024 teams\", \"top_k\": [{\"title\": \"2024 NBA Western Conference Finals - Basketball-Reference.com\", \"url\": \"https://www.basketball-reference.com/playoffs/2024-nba-western-conference-finals-mavericks-vs-timberwolves.html\", \"content\": \"2024 NBA Playoffs Dallas Mavericks vs. Dallas Mavericks vs. Dallas Mavericks vs. 5 Dallas Mavericks (4-1) vs. 7 Derrick Jones Jr. 2024 NBA Playoffs Dallas Mavericks vs. Dallas Mavericks vs. Dallas Mavericks vs. College Tools: Player Season Finder, Player Game Finder, Team Season Finder, Team Game Finder Players, Teams, Seasons, Leaders, Awards ... Players, Teams, Seasons, Leaders, Awards ... Players, Teams, Seasons, Leaders, Awards, All-Star Games, Executives ... Players, Teams, Seasons, Leaders, Awards ... Subscribe to Stathead Basketball: Get your first month FREE The SPORTS REFERENCE, STATHEAD, IMMACULATE GRID, and IMMACULATE FOOTY trademarks are owned exclusively by Sports Reference LLC. Sports\\u00a0Reference\\u202f\\u00ae Baseball Football (college) Basketball (college) Hockey F\\u00fatbol Blog Stathead\\u202f\\u00ae Immaculate Grid\\u202f\\u00ae\", \"score\": 0.89030397, \"raw_content\": null}, {\"title\": \"NBA Standings - 2024-25 season - ESPN\", \"url\": \"https://www.espn.com/nba/standings\", \"content\": \"NBA Standings - 2024-25 season - ESPN Skip to main contentSkip to navigation ESPN NFL NBA NCAAF NHL NCAAM NCAAW Soccer More Sports Watch Fantasy NBA Home Scores Schedule Standings Stats Teams Odds Where To Watch All-Star Game Fantasy More NBA Standings 2024-25 Standings Expanded Vs. Division NBA Cup LeagueConferenceDivision Eastern Conference | | | --- | | 1CLECleveland Cavaliers | | 2BOSBoston Celtics | | 3NYNew York Knicks | | 4INDIndiana Pacers | | 5MILMilwaukee Bucks | | 6DETDetroit Pistons | | 7MIAMiami Heat | | 8ORLOrlando Magic | | 9ATLAtlanta Hawks | | 10CHIChicago Bulls | | PHIPhiladelphia 76ers | | BKNBrooklyn Nets | | TORToronto Raptors | | CHACharlotte Hornets | | WSHWashington Wizards | | W | L | PCT | GB | HOME | AWAY | DIV | CONF | PPG | OPP PPG | DIFF | STRK | L10 | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | 42 | 10 | .808 | - | 24-4 | 18-6 | 9-1 | 28-7 | 122.4 | 112.1 | +10.3 | W2 | 6-4 | | 36 | 16 | .692 | 6 | 16-10 | 20-6 | 6-2 | 26-9 | 117.3 | 108.8 | +8.5 | L1 | 7-3 | | 34 | 17 | .667 | 7.5 | 18-9 | 16-8 | 9-1 | 23-10 | 117.9 | 111.4 | +6.5 | W2 | 8-2 | | 29 | 21 | .580 | 12 | 14-7 | 14-13 | 6-4 | 17-15 | 115.7 | 114.9 | +0.8 | W1 | 7-3 | | 27 | 23 | .540 | 14 | 16-8 | 10-15 | 6-5 | 22-16 | 114.2 | 112.6 | +1.6 | L1 | 4-6 | | 26 | 26 | .500 | 16 | 13-13 | 13-13 | 2-9 | 18-20 | 113.0 | 113.8 | -0.8 | W1 | 5-5 | | 25 | 25 | .500 | 16 | 12-10 | 12-15 | 5-3 | 14-15 | 110.5 | 110.6 | -0.1 | L1 | 5-5 | | 25 | 28 | .472 | 17.5 | 15-9 | 10-19 | 5-2 | 20-15 | 103.8 | 105.6 | -1.8 | L1 | 2-8 | | 24 | 28 | .462 | 18 | 12-12 | 12-15 | 4-2 | 17-13 | 116.1 | 119.0 | -2.9 | W1 | 2-8 | | 22 | 30 | .423 | 20 | 10-16 | 12-14 | 3-7 | 17-18 | 116.7 | 120.1 | -3.4 | L1 | 4-6 | | 20 | 31 | .392 | 21.5 | 10-16 | 10-15 | 3-4 | 14-17 | 109.1 | 112.9 | -3.8 | L2 | 5-5 | | 18 | 34 | .346 | 24 | 7-17 | 11-17 | 1-8 | 9-23 | 105.3 | 111.7 | -6.4 | W1 | 4-6 | | 16 | 36 | .308 | 26 | 12-16 | 4-20 | 3-7 | 10-23 | 111.2 | 116.9 | -5.7 | L3 | 6-4 | | 13 | 36 | .265 | 27.5 | 9-20 | 4-16 | 0-9 | 7-27 | 107.1 | 112.3 | -5.2 | W1 | 2-8 | | 9 | 42 | .176 | 32.5 | 5-20 | 4-21 | 5-3 | 7-21 | 107.8 | 121.5 | -13.7 | L1 | 3-7 | Western Conference | | | --- | | 1OKCOklahoma City Thunder | | 2MEMMemphis Grizzlies | | 3DENDenver Nuggets | | 4HOUHouston Rockets | | 5LALLos Angeles Lakers | | 6MINMinnesota Timberwolves | | 7LACLA Clippers | | 8DALDallas Mavericks | | 9PHXPhoenix Suns | | 10SACSacramento Kings | | GSGolden State Warriors | | SASan Antonio Spurs | | PORPortland Trail Blazers | | UTAHUtah Jazz | | NONew Orleans Pelicans | | W | L | PCT | GB | HOME | AWAY | DIV | CONF | PPG | OPP PPG | DIFF | STRK | L10 | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | 41 | 9 | .820 | - | 23-3 | 17-6 | 7-1 | 23-8 | 117.7 | 104.7 | +13.0 | W4 | 7-3 | | 35 | 16 | .686 | 6.5 | 21-5 | 14-11 | 8-4 | 19-12 | 123.8 | 115.4 | +8.4 | W4 | 9-1 | | 33 | 19 | .635 | 9 | 17-8 | 16-11 | 4-4 | 19-12 | 120.8 | 115.9 | +4.9 | W5 | 7-3 | | 32 | 20 | .615 | 10 | 15-8 | 17-11 | 9-3 | 19-12 | 113.3 | 109.1 | +4.2 | L6 | 4-6 | | 30 | 19 | .612 | 10.5 | 17-6 | 13-13 | 9-3 | 19-11 | 112.6 | 112.0 | +0.6 | W4 | 8-2 | | 29 | 23 | .558 | 13 | 14-12 | 15-11 | 4-3 | 21-14 | 111.7 | 108.2 | +3.5 | W2 | 7-3 | | 28 | 23 | .549 | 13.5 | 17-10 | 11-13 | 6-4 | 17-18 | 110.1 | 107.7 | +2.4 | L3 | 4-6 | | 28 | 25 | .528 | 14.5 | 15-10 | 13-15 | 6-4 | 20-17 | 115.5 | 113.3 | +2.2 | W2 | 5-5 | | 26 | 25 | .510 | 15.5 | 16-9 | 10-16 | 7-4 | 17-14 | 113.4 | 114.7 | -1.3 | W1 | 5-5 | | 25 | 26 | .490 | 16.5 | 13-13 | 12-13 | 4-6 | 16-17 | 116.1 | 115.4 | +0.7 | L2 | 4-6 | | 25 | 26 | .490 | 16.5 | 15-13 | 10-13 | 1-10 | 17-18 | 111.5 | 111.9 | -0.4 | L2 | 4-6 | | 22 | 27 | .449 | 18.5 | 13-12 | 8-14 | 2-7 | 16-18 | 112.8 | 114.3 | -1.5 | L1 | 3-7 | | 23 | 29 | .442 | 19 | 15-13 | 8-16 | 4-5 | 14-24 | 109.0 | 113.9 | -4.9 | W6 | 9-1 | | 12 | 38 | .240 | 29 | 5-18 | 7-20 | 1-7 | 4-29 | 111.9 | 118.9 | -7.0 | L1 | 2-8 | | 12 | 39 | .235 | 29.5 | 8-18 | 4-21 | 1-8 | 6-23 | 110.0 | 118.8 | -8.8 | L7 | 3-7 | Standings are updated with the completion of each game.Teams seeded 7-10 in each conference will compete in a play-in tournament at the end of the regular season. Glossary W:Wins L:Losses PCT:Winning Percentage GB:Games Back HOME:Home Record AWAY:Away Record DIV:Division Record CONF:Conference Record PPG:Points Per Game OPP PPG:Opponent Points Per Game DIFF:Average Point Differential STRK:Current Streak L10:Record last 10 games NBA News Anthony Davis leads Mavericks past Rockets 116-105 in Mavs debut but leaves with lower-body injury -------------------------------------------------------------------------------------------------- \\u2014 Anthony Davis had 26 points, 16 rebounds, seven assists and three blocks in his Mavericks debut but left the game late in the third quarter with a... * 38m Hawks request waivers on newly acquired Bones Hyland ---------------------------------------------------- The Atlanta Hawks requested waivers on guard Bones Hyland on Saturday, just two days after the guard was obtained from the Clippers in a deal at the NBA trade deadline. * 1h AD posts 26-point double-double in debut before suffering injury ---------------------------------------------------------------- Anthony Davis has a strong debut with the Mavs, dropping 26 points, 16 rebounds and 7 assists, before leaving with a lower-body injury. * 1h All NBA News Terms of Use Privacy Policy Your US State Privacy Rights Children's Online Privacy Policy Interest-Based Ads About Nielsen Measurement Do Not Sell or Share My Personal Information Contact Us Disney Ad Sales Site Work for ESPN Corrections ESPN BET Sportsbook is owned and operated by PENN Entertainment, Inc. and its subsidiaries ('PENN').\", \"score\": 0.83549726, \"raw_content\": null}, {\"title\": \"2024 Playoffs: West Finals | Timberwolves (3) vs. Mavericks (5) | NBA.com\", \"url\": \"https://www.nba.com/playoffs/2024/west-final\", \"content\": \"Mavericks (5) | NBA.com 2024-25 NBA CrunchTime NBA TV Draft Kings DFS NBA Bet Home NBA Store NBA Game Worn NBA Photo Store NBA Experiences NBA G League NBA 2K League NBA Play NBA Bet ### Doncic, Irving carry Mavs to NBA Finals Luka Doncic and Kyrie Irving pour in 36 points apiece to guide Dallas to its 1st appearance in the NBA Finals since 2011. ### Luka: 'This is special, coming from the West' Luka Doncic with Ernie, Charles, Kenny & Shaq about the Mavs being NBA Finals-bound, his Game 5 play and more. NBA Organization NBA ID NBA Official NBA Careers NBA Initiatives NBA Cares NBA Foundation NBA Communications NBA Transactions NBA Auctions NBA Photostore\", \"score\": 0.75312227, \"raw_content\": null}, {\"title\": \"2024 NBA Playoffs | Official Bracket, Schedule and Series Matchups\", \"url\": \"https://www.nba.com/playoffs/2024?os=wtmbloozowcj&ref=app\", \"content\": \"Draft Kings DFS NBA Store NBA Play NBA Finals ### Chasing History: Celtics clinch banner 18 (Ep. 25) Jayson Tatum and Finals MVP Jaylen Brown close out Dallas in Game 5 to secure Boston's NBA-record 18th championship. WE DID ITTTT!' Jayson Tatum walkoff interview after Celtics defeat Mavericks in Game 5 of 2024 NBA Finals, clinching title with a 4-1 series win. ### Horford finally champ after key sacrifice Al Horford, who played the most playoff games in NBA history before winning his 1st title, crosses the plateau in his 17th season. 30:13 ### Best of the 2024 NBA Finals 17:47 ### Best of Boston Celtics from the 2024 NBA Finals\", \"score\": 0.63234437, \"raw_content\": null}, {\"title\": \"2025 NBA Playoffs: Standings, bracket and clinching updates\", \"url\": \"https://www.nba.com/news/2025-nba-playoffs-standings-and-bracket-updates\", \"content\": \"NBA TV NBA Play NBA Store NBA Game Worn NBA Play NBA Official NBA Playoffs bracket ### What to know about 2025 SoFi NBA Play-In Tournament The SoFi NBA Play-In Tournament features the Nos. 7-10 teams in each conference battling for the 7th and 8th playoff seeds. Click \\\"Access Content\\\" to agree to our Terms of Use and Privacy Policy and to sign up for emails about the latest news and products from the NBA Family and its partners. #### What to know about 2025 SoFi NBA Play-In Tournament The SoFi NBA Play-In Tournament features the Nos. 7-10 teams in each conference battling for the 7th and 8th playoff seeds. NBA ID NBA Official NBA Transactions NBA Auctions\", \"score\": 0.13435538, \"raw_content\": null}]}\u001b[0m\n", - "\u001b[33minference> \u001b[0m\u001b[33mThe\u001b[0m\u001b[33m teams\u001b[0m\u001b[33m that\u001b[0m\u001b[33m played\u001b[0m\u001b[33m in\u001b[0m\u001b[33m the\u001b[0m\u001b[33m NBA\u001b[0m\u001b[33m Western\u001b[0m\u001b[33m Conference\u001b[0m\u001b[33m Finals\u001b[0m\u001b[33m of\u001b[0m\u001b[33m \u001b[0m\u001b[33m202\u001b[0m\u001b[33m4\u001b[0m\u001b[33m were\u001b[0m\u001b[33m the\u001b[0m\u001b[33m Dallas\u001b[0m\u001b[33m Mavericks\u001b[0m\u001b[33m and\u001b[0m\u001b[33m the\u001b[0m\u001b[33m Minnesota\u001b[0m\u001b[33m Timber\u001b[0m\u001b[33mw\u001b[0m\u001b[33molves\u001b[0m\u001b[33m.\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[30m\u001b[0m\u001b[33minference> \u001b[0m\u001b[36m\u001b[0m\u001b[36mbr\u001b[0m\u001b[36mave\u001b[0m\u001b[36m_search\u001b[0m\u001b[36m.call\u001b[0m\u001b[36m(query\u001b[0m\u001b[36m=\"\u001b[0m\u001b[36mSouth\u001b[0m\u001b[36m Park\u001b[0m\u001b[36m Bill\u001b[0m\u001b[36m Cosby\u001b[0m\u001b[36m episode\u001b[0m\u001b[36m season\u001b[0m\u001b[36m\")\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[32mtool_execution> Tool:brave_search Args:{'query': 'South Park Bill Cosby episode season'}\u001b[0m\n", - "\u001b[32mtool_execution> Tool:brave_search Response:{\"query\": \"South Park Bill Cosby episode season\", \"top_k\": [{\"title\": \"Bill Cosby | South Park Archives | Fandom\", \"url\": \"https://southpark.fandom.com/wiki/Bill_Cosby\", \"content\": \"SIGN IN CHARACTERS SIGN IN Explore EXPLORE CHARACTERS SIGN IN TO EDIT Character Information For other uses, see Bill (Disambiguation). Bill Cosby is elderly, having gray hair as well as various facial wrinkles. More Information: Criminal Celebrities More Information: Movie Celebrities Minor Characters from Season Four More information: List of Minor Characters from Season Four | Season Four Community content is available under CC-BY-SA unless otherwise noted. EXPLORE PROPERTIES FOLLOW US Terms of Use Global Sitemap Local Sitemap Follow on IG\", \"score\": 0.48294178, \"raw_content\": null}, {\"title\": \"Stunning and Brave - Wikipedia\", \"url\": \"https://en.wikipedia.org/wiki/Stunning_and_Brave\", \"content\": \"South Park episode \\\"Stunning and Brave\\\" is the first episode in the nineteenth season of the American animated television series South Park. Cartman and others mount an 'anti-PC' assault on the fraternity house but Kyle interrupts it, publicly calling Jenner a hero and brave. IGN's Max Nicholson gave the episode a 7.8 out of 10 and stated \\\"South Park's latest episode took on political correctness with scathing wit and truly outrageous moments.\\\"[1] \\\"South Park: \\\"Stunning and Brave\\\" Review\\\". \\\"South Park: Stunning and Brave Review\\\". \\\"South Park: Stunning and Brave\\\". \\\"South Park premiere is 'Stunning and Brave'\\\". \\\"Stunning and Brave\\\" Full episode at South Park Studios South Park episodes\", \"score\": 0.21465065, \"raw_content\": null}, {\"title\": \"Here Comes the Neighborhood - Wikipedia\", \"url\": \"https://en.wikipedia.org/wiki/Here_Comes_the_Neighborhood\", \"content\": \"\\\"Here Comes the Neighborhood\\\" is the 12th episode of the fifth season of the animated television series South Park, and the 77th episode of the series overall. Despondent at his social estrangement, Token decides to arrange for dozens of rich people (who all happen to be black) such as Will Smith and Snoop Dogg to move into South Park, which leads to Mr. Garrison complaining about the \\\"richers\\\" in the town, which in turn leads to ire among the other, less affluent members of the community (who all happen to be white). \\\"Here Comes the Neighborhood,\\\" along with the thirteen other episodes from South Park: the Complete Fifth Season, was released on a three-disc DVD set in the United States on February 22, 2005. South Park: The Complete Fifth Season: \\\"Here Comes the Neighborhood\\\" (DVD Disc audio commentary). \\\"Here Comes the Neighborhood\\\" Full episode at South Park Studios\", \"score\": 0.19947985, \"raw_content\": null}, {\"title\": \"Trapper Keeper | South Park Archives | Fandom\", \"url\": \"https://southpark.fandom.com/wiki/Trapper_Keeper\", \"content\": \"Trapper Keeper | South Park Archives | Fandom Episodes Episodes in: Episodes, Featured Article Winners, Season 4, Episodes Focusing On Cartman | Episode no. Episode 12 | | List of all South Park episodes | \\\"Trapper Keeper\\\" is the twelfth episode of Season Four and the 60th overall episode of South Park. Kyle takes a Dawson's Creek Trapper Keeper with him to school and is soon met by Cartman. Cartman brags about his Dawson's Creek Trapper Keeper Ultra Keeper Futura S 2000, of which shows off many features that far exceed Kyle's. \\u2191 Jump up to: 1.0 1.1 Trapper Keeper (Season 4, Episode 13). Episodes Episodes Focusing On Cartman Espa\\u00f1ol Fran\\u00e7ais Italiano Portugu\\u00eas do Brasil \\u4e2d\\u6587\", \"score\": 0.1287991, \"raw_content\": null}, {\"title\": \"\\\"South Park\\\" Trapper Keeper (TV Episode 2000) - IMDb\", \"url\": \"https://www.imdb.com/title/tt0705978/\", \"content\": \"Trapper Keeper is a very interesting south park episode.It spoofs plenty of classic sci-fi films such as The Terminator, 2001 A Space Odyssea and the 1988 anime classic Akira(great movie if you haven't seen it).The episode has Cartman with a Dawson's Creek Trapper Keeper.A trapper keeper seems to be a school supply(I have never heard of it before).Cartman's trapper keeper is very advanced in terms of technology, however a robot from the future has come to destroy it because the trapper keeper takes over the world and destroys humanity in the future.The Trapper Keeper turns into a big blob(like in Akira) and sucks Cartman in.It then roams South Park and the boys try to stop it.Meanwhile, Kyle's brother Ike starts kindergarten where Garrison is the teacher.They decide to have a vote for class president between Ike and a kid named Filmore.It turns into a heated debate!\", \"score\": 0.12658015, \"raw_content\": null}]}\u001b[0m\n", - "\u001b[33minference> \u001b[0m\u001b[33mBill\u001b[0m\u001b[33m Cosby\u001b[0m\u001b[33m first\u001b[0m\u001b[33m appears\u001b[0m\u001b[33m in\u001b[0m\u001b[33m the\u001b[0m\u001b[33m episode\u001b[0m\u001b[33m \"\u001b[0m\u001b[33mTr\u001b[0m\u001b[33mapped\u001b[0m\u001b[33m in\u001b[0m\u001b[33m the\u001b[0m\u001b[33m Closet\u001b[0m\u001b[33m\"\u001b[0m\u001b[33m (\u001b[0m\u001b[33mSeason\u001b[0m\u001b[33m \u001b[0m\u001b[33m9\u001b[0m\u001b[33m,\u001b[0m\u001b[33m Episode\u001b[0m\u001b[33m \u001b[0m\u001b[33m12\u001b[0m\u001b[33m)\u001b[0m\u001b[33m of\u001b[0m\u001b[33m South\u001b[0m\u001b[33m Park\u001b[0m\u001b[33m.\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[30m\u001b[0m\u001b[33minference> \u001b[0m\u001b[36m\u001b[0m\u001b[36mbr\u001b[0m\u001b[36mave\u001b[0m\u001b[36m_search\u001b[0m\u001b[36m.call\u001b[0m\u001b[36m(query\u001b[0m\u001b[36m=\"\u001b[0m\u001b[36mAndrew\u001b[0m\u001b[36m Tate\u001b[0m\u001b[36m kick\u001b[0m\u001b[36mboxing\u001b[0m\u001b[36m name\u001b[0m\u001b[36m\")\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[32mtool_execution> Tool:brave_search Args:{'query': 'Andrew Tate kickboxing name'}\u001b[0m\n", - "\u001b[32mtool_execution> Tool:brave_search Response:{\"query\": \"Andrew Tate kickboxing name\", \"top_k\": [{\"title\": \"Andrew Tate Height, Weight, Biography, Age, Wife ... - News Unzip\", \"url\": \"https://www.newsunzip.com/wiki/andrew-tate/\", \"content\": \"Andrew Tate aka King Cobra (Real Name: 'Emory Andrew Tate III', born 1 December 1986, Age: 36 Years) is a professional kickboxer, MMA fighter, internet. Monday , 10 March 2025 ... Andrew's Kickboxing and MMA Record Andrew Tate Net worth, Lifestyle & Cars Collection. Andrew is a millionaire businessman. He makes a lot of money from his\", \"score\": 0.85995835, \"raw_content\": null}, {\"title\": \"The Life Of Andrew Tate (By Andrew Tate Himself ... - Sidekick Boxing\", \"url\": \"https://sidekickboxing.co.uk/the-life-of-andrew-king-cobra-tate/\", \"content\": \"Andrew Tate is a British-American former professional kickboxing world champion who fought in the cruiserweight and super cruiserweight divisions. Andrew Tate\\u2019s Kickboxing Career Andrew Tate in the Big Brother house Andrew Tate\\u2019s Kickboxing World Titles and his Sidekick boxing gloves Andrew Tate After Kickboxing Andrew Tate and his brother Tristan moved to Romania to set up their empire of businesses including trading in Bitcoin, Hustlers University, CobraTate.com, The Real World, and The War Room. From being a 4x kickboxing world champion to becoming the world\\u2019s most Googled man in the world with a private jet and over 33 cars, Andrew Tate\\u2019s life has been full of adventure.\", \"score\": 0.78194773, \"raw_content\": null}, {\"title\": \"Andrew Tate (\\\"King Cobra\\\") | MMA Fighter Page - Tapology\", \"url\": \"https://www.tapology.com/fightcenter/fighters/72139-andrew-tate\", \"content\": \"Andrew Tate (\\\"King Cobra\\\") | MMA Fighter Page | Tapology Andrew \\\"King Cobra\\\" Tate Andrew Tate Name: Andrew Tate Height: 6'1\\\" (185cm) | Reach: Andrew Tate is ineligible for Tapology's regional MMA rankings due to inactivity. Fighters must have at least one completed MMA bout in the past two years to be ranked. Andrew Tate MMA Fight Record Former top-ranked UFC fighter has called out Andrew Tate for having a paper title when it comes to combat... Andrew Tate \\u2022 All the biggest upcoming MMA & Boxing fights | UFC Fight Night | 02.01.2025, 12:00 PM ET | MMA Junkie: UFC Fight Night 249 video: Nine stoppages to open the year?! MMA Mania: Prochazka Vs. Hill: Odds, Full Fight Preview & Prediction\", \"score\": 0.6999322, \"raw_content\": null}, {\"title\": \"Andrew Tate: Kickboxing Record, Facts, Height, Weight, Age, Biography\", \"url\": \"https://www.lowkickmma.com/andrew-tate-kickboxing-record-facts-height-weight-age-biography/\", \"content\": \"Who is Andrew Tate? Andrew Tate is a businessman, internet personality, and former professional kickboxer. Where is Andrew Tate From? Who is Andrew Tate\\u2019s Father? Andrew Tate Kickboxing Record What Kickboxing Gym Did Andrew Tate Train Out Of? How Many Professional Kickboxing Matches Has Andrew Tate Participated In? Andrew Tate competed in a total of 86 professional kickboxing bouts. What is Andrew Tate\\u2019 Professional Kickboxing Record? What Weight Classes Did Andrew Tate Compete In? In his professional kickboxing career, Andrew Tate won 32 of his fights by knockout. Did Andrew Tate Compete For Any Championship Titles? Did Tate Ever Compete In MMA? Andrew Tate competed in 1 professional MMA bout. How Much Money Did Andrew Tate Make In Kickboxing?\", \"score\": 0.50930125, \"raw_content\": null}, {\"title\": \"Andrew Tate - Wikipedia\", \"url\": \"https://en.wikipedia.org/wiki/Andrew_Tate\", \"content\": \"In 2011, Tate won his first International Sport Kickboxing Association (ISKA) world title in a rematch against Jean-Luc Beno\\u00eet via knockout, having previously lost to Beno\\u00eet by decision.[41] In 2012, Tate lost to Sahak Parparyan by unanimous decision while challenging for his It's Showtime 85MAX Championship.[42] Later that year, Tate lost the Enfusion championship tournament to Franci Graj\\u0161.[1] Before his loss, he was ranked second-best light-heavyweight kickboxer in the world.[43] In 2013, Tate won his second ISKA world title in a 12-round match against Vincent Petitjean, making him world champion in two weight divisions.[44] He defended the ISKA Belt and Won the Enfusion Belt in 2014, making him a four-time world champion[45] before he retired with 31 recorded fights.[46]\", \"score\": 0.49904844, \"raw_content\": null}]}\u001b[0m\n", - "\u001b[33minference> \u001b[0m\u001b[33mAndrew\u001b[0m\u001b[33m Tate\u001b[0m\u001b[33m's\u001b[0m\u001b[33m kick\u001b[0m\u001b[33mboxing\u001b[0m\u001b[33m name\u001b[0m\u001b[33m is\u001b[0m\u001b[33m \"\u001b[0m\u001b[33mKing\u001b[0m\u001b[33m Cobra\u001b[0m\u001b[33m\".\u001b[0m\u001b[97m\u001b[0m\n", - "\u001b[30m\u001b[0m" - ] - } - ], - "source": [ - "from llama_stack_client import Agent, AgentEventLogger\n", - "\n", - "agent = Agent(\n", - " client,\n", - " model=\"meta-llama/Llama-3.3-70B-Instruct\",\n", - " instructions=\"You are a helpful assistant. Use web_search tool to answer the questions.\",\n", - " tools=[\"builtin::websearch\"],\n", - ")\n", - "user_prompts = [\n", - " \"Which teams played in the NBA western conference finals of 2024. Search the web for the answer.\",\n", - " \"In which episode and season of South Park does Bill Cosby (BSM-471) first appear? Give me the number and title. Search the web for the answer.\",\n", - " \"What is the British-American kickboxer Andrew Tate's kickboxing name? Search the web for the answer.\",\n", - "]\n", - "\n", - "session_id = agent.create_session(uuid.uuid4().hex)\n", - "\n", - "for prompt in user_prompts:\n", - " response = agent.create_turn(\n", - " messages=[\n", - " {\n", - " \"role\": \"user\",\n", - " \"content\": prompt,\n", - " }\n", - " ],\n", - " session_id=session_id,\n", - " )\n", - "\n", - " for log in AgentEventLogger().log(response):\n", - " log.print()\n" - ] - }, - { - "cell_type": "markdown", - "id": "d0a50faf", - "metadata": {}, - "source": [ - "##### 3.1.2 Query Agent Execution Steps\n", - "\n", - "Now, let's look deeper into the agent's execution steps and see if how well our agent performs. As a sanity check, we will first check if all user prompts is followed by a tool call to `brave_search`." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "c28ea2d1", - "metadata": {}, - "outputs": [], - "source": [ - "# query the agents session\n", - "from rich.pretty import pprint\n", - "\n", - "session_response = client.agents.session.retrieve(\n", - " session_id=session_id,\n", - " agent_id=agent.agent_id,\n", - ")\n", - "\n", - "pprint(session_response.turns)" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "id": "f87a376d", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3/3 user prompts are followed by a tool call to `brave_search`\n" - ] - } - ], - "source": [ - "num_tool_call = 0\n", - "for turn in session_response.turns:\n", - " for step in turn.steps:\n", - " if step.step_type == \"tool_execution\" and step.tool_calls[0].tool_name == \"brave_search\":\n", - " num_tool_call += 1\n", - "\n", - "print(f\"{num_tool_call}/{len(session_response.turns)} user prompts are followed by a tool call to `brave_search`\")" - ] - }, - { - "cell_type": "markdown", - "id": "ed69220f", - "metadata": {}, - "source": [ - "##### 3.1.3 Evaluate Agent Responses\n", - "\n", - "Now, we want to evaluate the agent's responses to the user prompts. \n", - "\n", - "1. First, we will process the agent's execution history into a list of rows that can be used for evaluation.\n", - "2. Next, we will label the rows with the expected answer.\n", - "3. Finally, we will use the `/scoring` API to score the agent's responses." - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "id": "a2b293bc", - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
[\n",
-       "{\n",
-       "│   │   'input_query': 'Which teams played in the NBA western conference finals of 2024. Search the web for the answer.',\n",
-       "│   │   'generated_answer': 'The teams that played in the NBA Western Conference Finals of 2024 were the Dallas Mavericks and the Minnesota Timberwolves.',\n",
-       "│   │   'expected_answer': 'Dallas Mavericks and the Minnesota Timberwolves'\n",
-       "},\n",
-       "{\n",
-       "│   │   'input_query': 'In which episode and season of South Park does Bill Cosby (BSM-471) first appear? Give me the number and title. Search the web for the answer.',\n",
-       "│   │   'generated_answer': 'Bill Cosby first appears in the episode \"Trapped in the Closet\" (Season 9, Episode 12) of South Park.',\n",
-       "│   │   'expected_answer': 'Season 4, Episode 12'\n",
-       "},\n",
-       "{\n",
-       "│   │   'input_query': \"What is the British-American kickboxer Andrew Tate's kickboxing name? Search the web for the answer.\",\n",
-       "│   │   'generated_answer': 'Andrew Tate\\'s kickboxing name is \"King Cobra\".',\n",
-       "│   │   'expected_answer': 'King Cobra'\n",
-       "}\n",
-       "]\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[1m[\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m{\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[32m'input_query'\u001b[0m: \u001b[32m'Which teams played in the NBA western conference finals of 2024. Search the web for the answer.'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[32m'generated_answer'\u001b[0m: \u001b[32m'The teams that played in the NBA Western Conference Finals of 2024 were the Dallas Mavericks and the Minnesota Timberwolves.'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[32m'expected_answer'\u001b[0m: \u001b[32m'Dallas Mavericks and the Minnesota Timberwolves'\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m}\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m{\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[32m'input_query'\u001b[0m: \u001b[32m'In which episode and season of South Park does Bill Cosby \u001b[0m\u001b[32m(\u001b[0m\u001b[32mBSM-471\u001b[0m\u001b[32m)\u001b[0m\u001b[32m first appear? Give me the number and title. Search the web for the answer.'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[32m'generated_answer'\u001b[0m: \u001b[32m'Bill Cosby first appears in the episode \"Trapped in the Closet\" \u001b[0m\u001b[32m(\u001b[0m\u001b[32mSeason 9, Episode 12\u001b[0m\u001b[32m)\u001b[0m\u001b[32m of South Park.'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[32m'expected_answer'\u001b[0m: \u001b[32m'Season 4, Episode 12'\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m}\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m{\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[32m'input_query'\u001b[0m: \u001b[32m\"What is the British-American kickboxer Andrew Tate's kickboxing name? Search the web for the answer.\"\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[32m'generated_answer'\u001b[0m: \u001b[32m'Andrew Tate\\'s kickboxing name is \"King Cobra\".'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[32m'expected_answer'\u001b[0m: \u001b[32m'King Cobra'\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m}\u001b[0m\n", - "\u001b[1m]\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
ScoringScoreResponse(\n",
-       "results={\n",
-       "│   │   'basic::subset_of': ScoringResult(\n",
-       "│   │   │   aggregated_results={'accuracy': {'accuracy': 0.6666666666666666, 'num_correct': 2.0, 'num_total': 3}},\n",
-       "│   │   │   score_rows=[{'score': 1.0}, {'score': 0.0}, {'score': 1.0}]\n",
-       "│   │   )\n",
-       "}\n",
-       ")\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[1;35mScoringScoreResponse\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mresults\u001b[0m=\u001b[1m{\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[32m'basic::subset_of'\u001b[0m: \u001b[1;35mScoringResult\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33maggregated_results\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'accuracy'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'accuracy'\u001b[0m: \u001b[1;36m0.6666666666666666\u001b[0m, \u001b[32m'num_correct'\u001b[0m: \u001b[1;36m2.0\u001b[0m, \u001b[32m'num_total'\u001b[0m: \u001b[1;36m3\u001b[0m\u001b[1m}\u001b[0m\u001b[1m}\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mscore_rows\u001b[0m=\u001b[1m[\u001b[0m\u001b[1m{\u001b[0m\u001b[32m'score'\u001b[0m: \u001b[1;36m1.0\u001b[0m\u001b[1m}\u001b[0m, \u001b[1m{\u001b[0m\u001b[32m'score'\u001b[0m: \u001b[1;36m0.0\u001b[0m\u001b[1m}\u001b[0m, \u001b[1m{\u001b[0m\u001b[32m'score'\u001b[0m: \u001b[1;36m1.0\u001b[0m\u001b[1m}\u001b[0m\u001b[1m]\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[1m)\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m}\u001b[0m\n", - "\u001b[1m)\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "eval_rows = []\n", - "\n", - "expected_answers = [\n", - " \"Dallas Mavericks and the Minnesota Timberwolves\",\n", - " \"Season 4, Episode 12\",\n", - " \"King Cobra\",\n", - "]\n", - "\n", - "for i, turn in enumerate(session_response.turns):\n", - " eval_rows.append(\n", - " {\n", - " \"input_query\": turn.input_messages[0].content,\n", - " \"generated_answer\": turn.output_message.content,\n", - " \"expected_answer\": expected_answers[i],\n", - " }\n", - " )\n", - "\n", - "pprint(eval_rows)\n", - "\n", - "scoring_params = {\n", - " \"basic::subset_of\": None,\n", - "}\n", - "scoring_response = client.scoring.score(\n", - " input_rows=eval_rows, scoring_functions=scoring_params\n", - ")\n", - "pprint(scoring_response)" - ] - }, - { - "cell_type": "markdown", - "id": "ekOS2kM4P0LM", - "metadata": { - "id": "ekOS2kM4P0LM" - }, - "source": [ - "##### 3.1.4 Query Telemetry & Evaluate\n", - "\n", - "Another way to get the agent's execution history is to query the telemetry logs from the `/telemetry` API. The following example shows how to query the telemetry logs and post-process them to prepare data for evaluation." - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "id": "agkWgToGAsuA", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/", - "height": 1000 - }, - "id": "agkWgToGAsuA", - "outputId": "4233a1d9-8282-4aa9-bdc4-0c105939f97e" - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Getting traces for session_id=d73d9aaa-65ac-4255-8153-9f5cbff6e01e\n", - "Here are examples of traces:\n" - ] - }, - { - "data": { - "text/html": [ - "
[\n",
-       "{\n",
-       "│   │   'input': '[{\"role\": \"system\", \"content\": \"You are a helpful assistant. Use web_search tool to answer the questions.\"}, {\"role\": \"user\", \"content\": \"Which teams played in the NBA western conference finals of 2024. Search the web for the answer.\", \"context\": null}]',\n",
-       "│   │   'output': '{\"content\": \"\", \"tool_calls\": [{\"call_id\": \"5f77ab69-72d9-4d51-b96c-bd4352ced54a\", \"tool_name\": \"brave_search\", \"arguments\": {\"query\": \"NBA Western Conference Finals 2024 teams\"}, \"arguments_json\": \"{\\\\\"query\\\\\": \\\\\"NBA Western Conference Finals 2024 teams\\\\\"}\"}]}'\n",
-       "},\n",
-       "{\n",
-       "│   │   'input': '{\"role\":\"assistant\",\"content\":\"\",\"stop_reason\":\"end_of_turn\",\"tool_calls\":[{\"call_id\":\"5f77ab69-72d9-4d51-b96c-bd4352ced54a\",\"tool_name\":\"brave_search\",\"arguments\":{\"query\":\"NBA Western Conference Finals 2024 teams\"},\"arguments_json\":\"{\\\\\"query\\\\\": \\\\\"NBA Western Conference Finals 2024 teams\\\\\"}\"}]}',\n",
-       "│   │   'output': '{\"role\":\"tool\",\"call_id\":\"5f77ab69-72d9-4d51-b96c-bd4352ced54a\",\"content\":\"{\\\\\"query\\\\\": \\\\\"NBA Western Conference Finals 2024 teams\\\\\", \\\\\"top_k\\\\\": [{\\\\\"title\\\\\": \\\\\"2024 NBA Western Conference Finals - Basketball-Reference.com\\\\\", \\\\\"url\\\\\": \\\\\"https://www.basketball-reference.com/playoffs/2024-nba-western-conference-finals-mavericks-vs-timberwolves.html\\\\\", \\\\\"content\\\\\": \\\\\"2024 NBA Playoffs Dallas Mavericks vs. Dallas Mavericks vs. Dallas Mavericks vs. 5 Dallas Mavericks (4-1) vs. 7   Derrick Jones Jr. 2024 NBA Playoffs Dallas Mavericks vs. Dallas Mavericks vs. Dallas Mavericks vs. College Tools: Player Season Finder, Player Game Finder, Team Season Finder, Team Game Finder Players, Teams, Seasons, Leaders, Awards ... Players, Teams, Seasons, Leaders, Awards ... Players, Teams, Seasons, Leaders, Awards, All-Star Games, Executives ... Players, Teams, Seasons, Leaders, Awards ... Subscribe to Stathead Basketball: Get your first month FREE The SPORTS REFERENCE, STATHEAD, IMMACULATE GRID, and IMMACULATE FOOTY trademarks are owned exclusively by Sports Reference LLC. Sports\\\\\\\\u00a0Reference\\\\\\\\u202f\\\\\\\\u00ae Baseball Football (college) Basketball (college) Hockey F\\\\\\\\u00fatbol Blog Stathead\\\\\\\\u202f\\\\\\\\u00ae Immaculate Grid\\\\\\\\u202f\\\\\\\\u00ae\\\\\", \\\\\"score\\\\\": 0.89030397, \\\\\"raw_content\\\\\": null}, {\\\\\"title\\\\\": \\\\\"NBA Standings - 2024-25 season - ESPN\\\\\", \\\\\"url\\\\\": \\\\\"https://www.espn.com/nba/standings\\\\\", \\\\\"content\\\\\": \\\\\"NBA Standings - 2024-25 season - ESPN Skip to main contentSkip to navigation ESPN NFL NBA NCAAF NHL NCAAM NCAAW Soccer More Sports Watch Fantasy NBA Home Scores Schedule Standings Stats Teams Odds Where To Watch All-Star Game Fantasy More NBA Standings 2024-25 Standings Expanded Vs. Division NBA Cup LeagueConferenceDivision Eastern Conference | | | --- | | 1CLECleveland Cavaliers | | 2BOSBoston Celtics | | 3NYNew York Knicks | | 4INDIndiana Pacers | | 5MILMilwaukee Bucks | | 6DETDetroit Pistons | | 7MIAMiami Heat | | 8ORLOrlando Magic | | 9ATLAtlanta Hawks | | 10CHIChicago Bulls | | PHIPhiladelphia 76ers | | BKNBrooklyn Nets | | TORToronto Raptors | | CHACharlotte Hornets | | WSHWashington Wizards | | W | L | PCT | GB | HOME | AWAY | DIV | CONF | PPG | OPP PPG | DIFF | STRK | L10 | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | 42 | 10 | .808 | - | 24-4 | 18-6 | 9-1 | 28-7 | 122.4 | 112.1 | +10.3 | W2 | 6-4 | | 36 | 16 | .692 | 6 | 16-10 | 20-6 | 6-2 | 26-9 | 117.3 | 108.8 | +8.5 | L1 | 7-3 | | 34 | 17 | .667 | 7.5 | 18-9 | 16-8 | 9-1 | 23-10 | 117.9 | 111.4 | +6.5 | W2 | 8-2 | | 29 | 21 | .580 | 12 | 14-7 | 14-13 | 6-4 | 17-15 | 115.7 | 114.9 | +0.8 | W1 | 7-3 | | 27 | 23 | .540 | 14 | 16-8 | 10-15 | 6-5 | 22-16 | 114.2 | 112.6 | +1.6 | L1 | 4-6 | | 26 | 26 | .500 | 16 | 13-13 | 13-13 | 2-9 | 18-20 | 113.0 | 113.8 | -0.8 | W1 | 5-5 | | 25 | 25 | .500 | 16 | 12-10 | 12-15 | 5-3 | 14-15 | 110.5 | 110.6 | -0.1 | L1 | 5-5 | | 25 | 28 | .472 | 17.5 | 15-9 | 10-19 | 5-2 | 20-15 | 103.8 | 105.6 | -1.8 | L1 | 2-8 | | 24 | 28 | .462 | 18 | 12-12 | 12-15 | 4-2 | 17-13 | 116.1 | 119.0 | -2.9 | W1 | 2-8 | | 22 | 30 | .423 | 20 | 10-16 | 12-14 | 3-7 | 17-18 | 116.7 | 120.1 | -3.4 | L1 | 4-6 | | 20 | 31 | .392 | 21.5 | 10-16 | 10-15 | 3-4 | 14-17 | 109.1 | 112.9 | -3.8 | L2 | 5-5 | | 18 | 34 | .346 | 24 | 7-17 | 11-17 | 1-8 | 9-23 | 105.3 | 111.7 | -6.4 | W1 | 4-6 | | 16 | 36 | .308 | 26 | 12-16 | 4-20 | 3-7 | 10-23 | 111.2 | 116.9 | -5.7 | L3 | 6-4 | | 13 | 36 | .265 | 27.5 | 9-20 | 4-16 | 0-9 | 7-27 | 107.1 | 112.3 | -5.2 | W1 | 2-8 | | 9 | 42 | .176 | 32.5 | 5-20 | 4-21 | 5-3 | 7-21 | 107.8 | 121.5 | -13.7 | L1 | 3-7 | Western Conference | | | --- | | 1OKCOklahoma City Thunder | | 2MEMMemphis Grizzlies | | 3DENDenver Nuggets | | 4HOUHouston Rockets | | 5LALLos Angeles Lakers | | 6MINMinnesota Timberwolves | | 7LACLA Clippers | | 8DALDallas Mavericks | | 9PHXPhoenix Suns | | 10SACSacramento Kings | | GSGolden State Warriors | | SASan Antonio Spurs | | PORPortland Trail Blazers | | UTAHUtah Jazz | | NONew Orleans Pelicans | | W | L | PCT | GB | HOME | AWAY | DIV | CONF | PPG | OPP PPG | DIFF | STRK | L10 | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | 41 | 9 | .820 | - | 23-3 | 17-6 | 7-1 | 23-8 | 117.7 | 104.7 | +13.0 | W4 | 7-3 | | 35 | 16 | .686 | 6.5 | 21-5 | 14-11 | 8-4 | 19-12 | 123.8 | 115.4 | +8.4 | W4 | 9-1 | | 33 | 19 | .635 | 9 | 17-8 | 16-11 | 4-4 | 19-12 | 120.8 | 115.9 | +4.9 | W5 | 7-3 | | 32 | 20 | .615 | 10 | 15-8 | 17-11 | 9-3 | 19-12 | 113.3 | 109.1 | +4.2 | L6 | 4-6 | | 30 | 19 | .612 | 10.5 | 17-6 | 13-13 | 9-3 | 19-11 | 112.6 | 112.0 | +0.6 | W4 | 8-2 | | 29 | 23 | .558 | 13 | 14-12 | 15-11 | 4-3 | 21-14 | 111.7 | 108.2 | +3.5 | W2 | 7-3 | | 28 | 23 | .549 | 13.5 | 17-10 | 11-13 | 6-4 | 17-18 | 110.1 | 107.7 | +2.4 | L3 | 4-6 | | 28 | 25 | .528 | 14.5 | 15-10 | 13-15 | 6-4 | 20-17 | 115.5 | 113.3 | +2.2 | W2 | 5-5 | | 26 | 25 | .510 | 15.5 | 16-9 | 10-16 | 7-4 | 17-14 | 113.4 | 114.7 | -1.3 | W1 | 5-5 | | 25 | 26 | .490 | 16.5 | 13-13 | 12-13 | 4-6 | 16-17 | 116.1 | 115.4 | +0.7 | L2 | 4-6 | | 25 | 26 | .490 | 16.5 | 15-13 | 10-13 | 1-10 | 17-18 | 111.5 | 111.9 | -0.4 | L2 | 4-6 | | 22 | 27 | .449 | 18.5 | 13-12 | 8-14 | 2-7 | 16-18 | 112.8 | 114.3 | -1.5 | L1 | 3-7 | | 23 | 29 | .442 | 19 | 15-13 | 8-16 | 4-5 | 14-24 | 109.0 | 113.9 | -4.9 | W6 | 9-1 | | 12 | 38 | .240 | 29 | 5-18 | 7-20 | 1-7 | 4-29 | 111.9 | 118.9 | -7.0 | L1 | 2-8 | | 12 | 39 | .235 | 29.5 | 8-18 | 4-21 | 1-8 | 6-23 | 110.0 | 118.8 | -8.8 | L7 | 3-7 | Standings are updated with the completion of each game.Teams seeded 7-10 in each conference will compete in a play-in tournament at the end of the regular season. Glossary W:Wins L:Losses PCT:Winning Percentage GB:Games Back HOME:Home Record AWAY:Away Record DIV:Division Record CONF:Conference Record PPG:Points Per Game OPP PPG:Opponent Points Per Game DIFF:Average Point Differential STRK:Current Streak L10:Record last 10 games NBA News Anthony Davis leads Mavericks past Rockets 116-105 in Mavs debut but leaves with lower-body injury -------------------------------------------------------------------------------------------------- \\\\\\\\u2014 Anthony Davis had 26 points, 16 rebounds, seven assists and three blocks in his Mavericks debut but left the game late in the third quarter with a... * 38m Hawks request waivers on newly acquired Bones Hyland ---------------------------------------------------- The Atlanta Hawks requested waivers on guard Bones Hyland on Saturday, just two days after the guard was obtained from the Clippers in a deal at the NBA trade deadline. * 1h AD posts 26-point double-double in debut before suffering injury ---------------------------------------------------------------- Anthony Davis has a strong debut with the Mavs, dropping 26 points, 16 rebounds and 7 assists, before leaving with a lower-body injury. * 1h All NBA News Terms of Use Privacy Policy Your US State Privacy Rights Children\\'s Online Privacy Policy Interest-Based Ads About Nielsen Measurement Do Not Sell or Share My Personal Information Contact Us Disney Ad Sales Site Work for ESPN Corrections ESPN BET Sportsbook is owned and operated by PENN Entertainment, Inc. and its subsidiaries (\\'PENN\\').\\\\\", \\\\\"score\\\\\": 0.83549726, \\\\\"raw_content\\\\\": null}, {\\\\\"title\\\\\": \\\\\"2024 Playoffs: West Finals | Timberwolves (3) vs. Mavericks (5) | NBA.com\\\\\", \\\\\"url\\\\\": \\\\\"https://www.nba.com/playoffs/2024/west-final\\\\\", \\\\\"content\\\\\": \\\\\"Mavericks (5) | NBA.com 2024-25 NBA CrunchTime NBA TV Draft Kings DFS NBA Bet Home NBA Store NBA Game Worn NBA Photo Store NBA Experiences NBA G League NBA 2K League NBA Play NBA Bet ### Doncic, Irving carry Mavs to NBA Finals Luka Doncic and Kyrie Irving pour in 36 points apiece to guide Dallas to its 1st appearance in the NBA Finals since 2011. ### Luka: \\'This is special, coming from the West\\' Luka Doncic with Ernie, Charles, Kenny & Shaq about the Mavs being NBA Finals-bound, his Game 5 play and more. NBA Organization NBA ID NBA Official NBA Careers NBA Initiatives NBA Cares NBA Foundation NBA Communications NBA Transactions NBA Auctions NBA Photostore\\\\\", \\\\\"score\\\\\": 0.75312227, \\\\\"raw_content\\\\\": null}, {\\\\\"title\\\\\": \\\\\"2024 NBA Playoffs | Official Bracket, Schedule and Series Matchups\\\\\", \\\\\"url\\\\\": \\\\\"https://www.nba.com/playoffs/2024?os=wtmbloozowcj&ref=app\\\\\", \\\\\"content\\\\\": \\\\\"Draft Kings DFS NBA Store NBA Play NBA Finals ### Chasing History: Celtics clinch banner 18 (Ep. 25) Jayson Tatum and Finals MVP Jaylen Brown close out Dallas in Game 5 to secure Boston\\'s NBA-record 18th championship. WE DID ITTTT!\\' Jayson Tatum walkoff interview after Celtics defeat Mavericks in Game 5 of 2024 NBA Finals, clinching title with a 4-1 series win. ### Horford finally champ after key sacrifice Al Horford, who played the most playoff games in NBA history before winning his 1st title, crosses the plateau in his 17th season. 30:13 ### Best of the 2024 NBA Finals 17:47 ### Best of Boston Celtics from the 2024 NBA Finals\\\\\", \\\\\"score\\\\\": 0.63234437, \\\\\"raw_content\\\\\": null}, {\\\\\"title\\\\\": \\\\\"2025 NBA Playoffs: Standings, bracket and clinching updates\\\\\", \\\\\"url\\\\\": \\\\\"https://www.nba.com/news/2025-nba-playoffs-standings-and-bracket-updates\\\\\", \\\\\"content\\\\\": \\\\\"NBA TV NBA Play NBA Store NBA Game Worn NBA Play NBA Official NBA Playoffs bracket ### What to know about 2025 SoFi NBA Play-In Tournament The SoFi NBA Play-In Tournament features the Nos. 7-10 teams in each conference battling for the 7th and 8th playoff seeds. Click \\\\\\\\\\\\\"Access Content\\\\\\\\\\\\\" to agree to our Terms of Use and Privacy Policy and to sign up for emails about the latest news and products from the NBA Family and its partners. #### What to know about 2025 SoFi NBA Play-In Tournament The SoFi NBA Play-In Tournament features the Nos. 7-10 teams in each conference battling for the 7th and 8th playoff seeds. NBA ID NBA Official NBA Transactions NBA Auctions\\\\\", \\\\\"score\\\\\": 0.13435538, \\\\\"raw_content\\\\\": null}]}\"}'\n",
-       "}\n",
-       "]\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[1m[\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m{\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[32m'input'\u001b[0m: \u001b[32m'\u001b[0m\u001b[32m[\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\"role\": \"system\", \"content\": \"You are a helpful assistant. Use web_search tool to answer the questions.\"\u001b[0m\u001b[32m}\u001b[0m\u001b[32m, \u001b[0m\u001b[32m{\u001b[0m\u001b[32m\"role\": \"user\", \"content\": \"Which teams played in the NBA western conference finals of 2024. Search the web for the answer.\", \"context\": null\u001b[0m\u001b[32m}\u001b[0m\u001b[32m]\u001b[0m\u001b[32m'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[32m'output'\u001b[0m: \u001b[32m'\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\"content\": \"\", \"tool_calls\": \u001b[0m\u001b[32m[\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\"call_id\": \"5f77ab69-72d9-4d51-b96c-bd4352ced54a\", \"tool_name\": \"brave_search\", \"arguments\": \u001b[0m\u001b[32m{\u001b[0m\u001b[32m\"query\": \"NBA Western Conference Finals 2024 teams\"\u001b[0m\u001b[32m}\u001b[0m\u001b[32m, \"arguments_json\": \"\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\\\\\"query\\\\\": \\\\\"NBA Western Conference Finals 2024 teams\\\\\"\u001b[0m\u001b[32m}\u001b[0m\u001b[32m\"\u001b[0m\u001b[32m}\u001b[0m\u001b[32m]\u001b[0m\u001b[32m}\u001b[0m\u001b[32m'\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m}\u001b[0m,\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m{\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[32m'input'\u001b[0m: \u001b[32m'\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\"role\":\"assistant\",\"content\":\"\",\"stop_reason\":\"end_of_turn\",\"tool_calls\":\u001b[0m\u001b[32m[\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\"call_id\":\"5f77ab69-72d9-4d51-b96c-bd4352ced54a\",\"tool_name\":\"brave_search\",\"arguments\":\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\"query\":\"NBA Western Conference Finals 2024 teams\"\u001b[0m\u001b[32m}\u001b[0m\u001b[32m,\"arguments_json\":\"\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\\\\\"query\\\\\": \\\\\"NBA Western Conference Finals 2024 teams\\\\\"\u001b[0m\u001b[32m}\u001b[0m\u001b[32m\"\u001b[0m\u001b[32m}\u001b[0m\u001b[32m]\u001b[0m\u001b[32m}\u001b[0m\u001b[32m'\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[32m'output'\u001b[0m: \u001b[32m'\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\"role\":\"tool\",\"call_id\":\"5f77ab69-72d9-4d51-b96c-bd4352ced54a\",\"content\":\"\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\\\\\"query\\\\\": \\\\\"NBA Western Conference Finals 2024 teams\\\\\", \\\\\"top_k\\\\\": \u001b[0m\u001b[32m[\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\\\\\"title\\\\\": \\\\\"2024 NBA Western Conference Finals - Basketball-Reference.com\\\\\", \\\\\"url\\\\\": \\\\\"https://www.basketball-reference.com/playoffs/2024-nba-western-conference-finals-mavericks-vs-timberwolves.html\\\\\", \\\\\"content\\\\\": \\\\\"2024 NBA Playoffs Dallas Mavericks vs. Dallas Mavericks vs. Dallas Mavericks vs. 5 Dallas Mavericks \u001b[0m\u001b[32m(\u001b[0m\u001b[32m4-1\u001b[0m\u001b[32m)\u001b[0m\u001b[32m vs. 7 Derrick Jones Jr. 2024 NBA Playoffs Dallas Mavericks vs. Dallas Mavericks vs. Dallas Mavericks vs. College Tools: Player Season Finder, Player Game Finder, Team Season Finder, Team Game Finder Players, Teams, Seasons, Leaders, Awards ... Players, Teams, Seasons, Leaders, Awards ... Players, Teams, Seasons, Leaders, Awards, All-Star Games, Executives ... Players, Teams, Seasons, Leaders, Awards ... Subscribe to Stathead Basketball: Get your first month FREE The SPORTS REFERENCE, STATHEAD, IMMACULATE GRID, and IMMACULATE FOOTY trademarks are owned exclusively by Sports Reference LLC. Sports\\\\\\\\u00a0Reference\\\\\\\\u202f\\\\\\\\u00ae Baseball Football \u001b[0m\u001b[32m(\u001b[0m\u001b[32mcollege\u001b[0m\u001b[32m)\u001b[0m\u001b[32m Basketball \u001b[0m\u001b[32m(\u001b[0m\u001b[32mcollege\u001b[0m\u001b[32m)\u001b[0m\u001b[32m Hockey F\\\\\\\\u00fatbol Blog Stathead\\\\\\\\u202f\\\\\\\\u00ae Immaculate Grid\\\\\\\\u202f\\\\\\\\u00ae\\\\\", \\\\\"score\\\\\": 0.89030397, \\\\\"raw_content\\\\\": null\u001b[0m\u001b[32m}\u001b[0m\u001b[32m, \u001b[0m\u001b[32m{\u001b[0m\u001b[32m\\\\\"title\\\\\": \\\\\"NBA Standings - 2024-25 season - ESPN\\\\\", \\\\\"url\\\\\": \\\\\"https://www.espn.com/nba/standings\\\\\", \\\\\"content\\\\\": \\\\\"NBA Standings - 2024-25 season - ESPN Skip to main contentSkip to navigation ESPN NFL NBA NCAAF NHL NCAAM NCAAW Soccer More Sports Watch Fantasy NBA Home Scores Schedule Standings Stats Teams Odds Where To Watch All-Star Game Fantasy More NBA Standings 2024-25 Standings Expanded Vs. Division NBA Cup LeagueConferenceDivision Eastern Conference | | | --- | | 1CLECleveland Cavaliers | | 2BOSBoston Celtics | | 3NYNew York Knicks | | 4INDIndiana Pacers | | 5MILMilwaukee Bucks | | 6DETDetroit Pistons | | 7MIAMiami Heat | | 8ORLOrlando Magic | | 9ATLAtlanta Hawks | | 10CHIChicago Bulls | | PHIPhiladelphia 76ers | | BKNBrooklyn Nets | | TORToronto Raptors | | CHACharlotte Hornets | | WSHWashington Wizards | | W | L | PCT | GB | HOME | AWAY | DIV | CONF | PPG | OPP PPG | DIFF | STRK | L10 | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | 42 | 10 | .808 | - | 24-4 | 18-6 | 9-1 | 28-7 | 122.4 | 112.1 | +10.3 | W2 | 6-4 | | 36 | 16 | .692 | 6 | 16-10 | 20-6 | 6-2 | 26-9 | 117.3 | 108.8 | +8.5 | L1 | 7-3 | | 34 | 17 | .667 | 7.5 | 18-9 | 16-8 | 9-1 | 23-10 | 117.9 | 111.4 | +6.5 | W2 | 8-2 | | 29 | 21 | .580 | 12 | 14-7 | 14-13 | 6-4 | 17-15 | 115.7 | 114.9 | +0.8 | W1 | 7-3 | | 27 | 23 | .540 | 14 | 16-8 | 10-15 | 6-5 | 22-16 | 114.2 | 112.6 | +1.6 | L1 | 4-6 | | 26 | 26 | .500 | 16 | 13-13 | 13-13 | 2-9 | 18-20 | 113.0 | 113.8 | -0.8 | W1 | 5-5 | | 25 | 25 | .500 | 16 | 12-10 | 12-15 | 5-3 | 14-15 | 110.5 | 110.6 | -0.1 | L1 | 5-5 | | 25 | 28 | .472 | 17.5 | 15-9 | 10-19 | 5-2 | 20-15 | 103.8 | 105.6 | -1.8 | L1 | 2-8 | | 24 | 28 | .462 | 18 | 12-12 | 12-15 | 4-2 | 17-13 | 116.1 | 119.0 | -2.9 | W1 | 2-8 | | 22 | 30 | .423 | 20 | 10-16 | 12-14 | 3-7 | 17-18 | 116.7 | 120.1 | -3.4 | L1 | 4-6 | | 20 | 31 | .392 | 21.5 | 10-16 | 10-15 | 3-4 | 14-17 | 109.1 | 112.9 | -3.8 | L2 | 5-5 | | 18 | 34 | .346 | 24 | 7-17 | 11-17 | 1-8 | 9-23 | 105.3 | 111.7 | -6.4 | W1 | 4-6 | | 16 | 36 | .308 | 26 | 12-16 | 4-20 | 3-7 | 10-23 | 111.2 | 116.9 | -5.7 | L3 | 6-4 | | 13 | 36 | .265 | 27.5 | 9-20 | 4-16 | 0-9 | 7-27 | 107.1 | 112.3 | -5.2 | W1 | 2-8 | | 9 | 42 | .176 | 32.5 | 5-20 | 4-21 | 5-3 | 7-21 | 107.8 | 121.5 | -13.7 | L1 | 3-7 | Western Conference | | | --- | | 1OKCOklahoma City Thunder | | 2MEMMemphis Grizzlies | | 3DENDenver Nuggets | | 4HOUHouston Rockets | | 5LALLos Angeles Lakers | | 6MINMinnesota Timberwolves | | 7LACLA Clippers | | 8DALDallas Mavericks | | 9PHXPhoenix Suns | | 10SACSacramento Kings | | GSGolden State Warriors | | SASan Antonio Spurs | | PORPortland Trail Blazers | | UTAHUtah Jazz | | NONew Orleans Pelicans | | W | L | PCT | GB | HOME | AWAY | DIV | CONF | PPG | OPP PPG | DIFF | STRK | L10 | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | 41 | 9 | .820 | - | 23-3 | 17-6 | 7-1 | 23-8 | 117.7 | 104.7 | +13.0 | W4 | 7-3 | | 35 | 16 | .686 | 6.5 | 21-5 | 14-11 | 8-4 | 19-12 | 123.8 | 115.4 | +8.4 | W4 | 9-1 | | 33 | 19 | .635 | 9 | 17-8 | 16-11 | 4-4 | 19-12 | 120.8 | 115.9 | +4.9 | W5 | 7-3 | | 32 | 20 | .615 | 10 | 15-8 | 17-11 | 9-3 | 19-12 | 113.3 | 109.1 | +4.2 | L6 | 4-6 | | 30 | 19 | .612 | 10.5 | 17-6 | 13-13 | 9-3 | 19-11 | 112.6 | 112.0 | +0.6 | W4 | 8-2 | | 29 | 23 | .558 | 13 | 14-12 | 15-11 | 4-3 | 21-14 | 111.7 | 108.2 | +3.5 | W2 | 7-3 | | 28 | 23 | .549 | 13.5 | 17-10 | 11-13 | 6-4 | 17-18 | 110.1 | 107.7 | +2.4 | L3 | 4-6 | | 28 | 25 | .528 | 14.5 | 15-10 | 13-15 | 6-4 | 20-17 | 115.5 | 113.3 | +2.2 | W2 | 5-5 | | 26 | 25 | .510 | 15.5 | 16-9 | 10-16 | 7-4 | 17-14 | 113.4 | 114.7 | -1.3 | W1 | 5-5 | | 25 | 26 | .490 | 16.5 | 13-13 | 12-13 | 4-6 | 16-17 | 116.1 | 115.4 | +0.7 | L2 | 4-6 | | 25 | 26 | .490 | 16.5 | 15-13 | 10-13 | 1-10 | 17-18 | 111.5 | 111.9 | -0.4 | L2 | 4-6 | | 22 | 27 | .449 | 18.5 | 13-12 | 8-14 | 2-7 | 16-18 | 112.8 | 114.3 | -1.5 | L1 | 3-7 | | 23 | 29 | .442 | 19 | 15-13 | 8-16 | 4-5 | 14-24 | 109.0 | 113.9 | -4.9 | W6 | 9-1 | | 12 | 38 | .240 | 29 | 5-18 | 7-20 | 1-7 | 4-29 | 111.9 | 118.9 | -7.0 | L1 | 2-8 | | 12 | 39 | .235 | 29.5 | 8-18 | 4-21 | 1-8 | 6-23 | 110.0 | 118.8 | -8.8 | L7 | 3-7 | Standings are updated with the completion of each game.Teams seeded 7-10 in each conference will compete in a play-in tournament at the end of the regular season. Glossary W:Wins L:Losses PCT:Winning Percentage GB:Games Back HOME:Home Record AWAY:Away Record DIV:Division Record CONF:Conference Record PPG:Points Per Game OPP PPG:Opponent Points Per Game DIFF:Average Point Differential STRK:Current Streak L10:Record last 10 games NBA News Anthony Davis leads Mavericks past Rockets 116-105 in Mavs debut but leaves with lower-body injury -------------------------------------------------------------------------------------------------- \\\\\\\\u2014 Anthony Davis had 26 points, 16 rebounds, seven assists and three blocks in his Mavericks debut but left the game late in the third quarter with a... * 38m Hawks request waivers on newly acquired Bones Hyland ---------------------------------------------------- The Atlanta Hawks requested waivers on guard Bones Hyland on Saturday, just two days after the guard was obtained from the Clippers in a deal at the NBA trade deadline. * 1h AD posts 26-point double-double in debut before suffering injury ---------------------------------------------------------------- Anthony Davis has a strong debut with the Mavs, dropping 26 points, 16 rebounds and 7 assists, before leaving with a lower-body injury. * 1h All NBA News Terms of Use Privacy Policy Your US State Privacy Rights Children\\'s Online Privacy Policy Interest-Based Ads About Nielsen Measurement Do Not Sell or Share My Personal Information Contact Us Disney Ad Sales Site Work for ESPN Corrections ESPN BET Sportsbook is owned and operated by PENN Entertainment, Inc. and its subsidiaries \u001b[0m\u001b[32m(\u001b[0m\u001b[32m\\'PENN\\'\u001b[0m\u001b[32m)\u001b[0m\u001b[32m.\\\\\", \\\\\"score\\\\\": 0.83549726, \\\\\"raw_content\\\\\": null\u001b[0m\u001b[32m}\u001b[0m\u001b[32m, \u001b[0m\u001b[32m{\u001b[0m\u001b[32m\\\\\"title\\\\\": \\\\\"2024 Playoffs: West Finals | Timberwolves \u001b[0m\u001b[32m(\u001b[0m\u001b[32m3\u001b[0m\u001b[32m)\u001b[0m\u001b[32m vs. Mavericks \u001b[0m\u001b[32m(\u001b[0m\u001b[32m5\u001b[0m\u001b[32m)\u001b[0m\u001b[32m | NBA.com\\\\\", \\\\\"url\\\\\": \\\\\"https://www.nba.com/playoffs/2024/west-final\\\\\", \\\\\"content\\\\\": \\\\\"Mavericks \u001b[0m\u001b[32m(\u001b[0m\u001b[32m5\u001b[0m\u001b[32m)\u001b[0m\u001b[32m | NBA.com 2024-25 NBA CrunchTime NBA TV Draft Kings DFS NBA Bet Home NBA Store NBA Game Worn NBA Photo Store NBA Experiences NBA G League NBA 2K League NBA Play NBA Bet ### Doncic, Irving carry Mavs to NBA Finals Luka Doncic and Kyrie Irving pour in 36 points apiece to guide Dallas to its 1st appearance in the NBA Finals since 2011. ### Luka: \\'This is special, coming from the West\\' Luka Doncic with Ernie, Charles, Kenny & Shaq about the Mavs being NBA Finals-bound, his Game 5 play and more. NBA Organization NBA ID NBA Official NBA Careers NBA Initiatives NBA Cares NBA Foundation NBA Communications NBA Transactions NBA Auctions NBA Photostore\\\\\", \\\\\"score\\\\\": 0.75312227, \\\\\"raw_content\\\\\": null\u001b[0m\u001b[32m}\u001b[0m\u001b[32m, \u001b[0m\u001b[32m{\u001b[0m\u001b[32m\\\\\"title\\\\\": \\\\\"2024 NBA Playoffs | Official Bracket, Schedule and Series Matchups\\\\\", \\\\\"url\\\\\": \\\\\"https://www.nba.com/playoffs/2024?\u001b[0m\u001b[32mos\u001b[0m\u001b[32m=\u001b[0m\u001b[32mwtmbloozowcj\u001b[0m\u001b[32m&\u001b[0m\u001b[32mref\u001b[0m\u001b[32m=\u001b[0m\u001b[32mapp\u001b[0m\u001b[32m\\\\\", \\\\\"content\\\\\": \\\\\"Draft Kings DFS NBA Store NBA Play NBA Finals ### Chasing History: Celtics clinch banner 18 \u001b[0m\u001b[32m(\u001b[0m\u001b[32mEp. 25\u001b[0m\u001b[32m)\u001b[0m\u001b[32m Jayson Tatum and Finals MVP Jaylen Brown close out Dallas in Game 5 to secure Boston\\'s NBA-record 18th championship. WE DID ITTTT!\\' Jayson Tatum walkoff interview after Celtics defeat Mavericks in Game 5 of 2024 NBA Finals, clinching title with a 4-1 series win. ### Horford finally champ after key sacrifice Al Horford, who played the most playoff games in NBA history before winning his 1st title, crosses the plateau in his 17th season. 30:13 ### Best of the 2024 NBA Finals 17:47 ### Best of Boston Celtics from the 2024 NBA Finals\\\\\", \\\\\"score\\\\\": 0.63234437, \\\\\"raw_content\\\\\": null\u001b[0m\u001b[32m}\u001b[0m\u001b[32m, \u001b[0m\u001b[32m{\u001b[0m\u001b[32m\\\\\"title\\\\\": \\\\\"2025 NBA Playoffs: Standings, bracket and clinching updates\\\\\", \\\\\"url\\\\\": \\\\\"https://www.nba.com/news/2025-nba-playoffs-standings-and-bracket-updates\\\\\", \\\\\"content\\\\\": \\\\\"NBA TV NBA Play NBA Store NBA Game Worn NBA Play NBA Official NBA Playoffs bracket ### What to know about 2025 SoFi NBA Play-In Tournament The SoFi NBA Play-In Tournament features the Nos. 7-10 teams in each conference battling for the 7th and 8th playoff seeds. Click \\\\\\\\\\\\\"Access Content\\\\\\\\\\\\\" to agree to our Terms of Use and Privacy Policy and to sign up for emails about the latest news and products from the NBA Family and its partners. #### What to know about 2025 SoFi NBA Play-In Tournament The SoFi NBA Play-In Tournament features the Nos. 7-10 teams in each conference battling for the 7th and 8th playoff seeds. NBA ID NBA Official NBA Transactions NBA Auctions\\\\\", \\\\\"score\\\\\": 0.13435538, \\\\\"raw_content\\\\\": null\u001b[0m\u001b[32m}\u001b[0m\u001b[32m]\u001b[0m\u001b[32m}\u001b[0m\u001b[32m\"\u001b[0m\u001b[32m}\u001b[0m\u001b[32m'\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m}\u001b[0m\n", - "\u001b[1m]\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "# NBVAL_SKIP\n", - "print(f\"Getting traces for session_id={session_id}\")\n", - "import json\n", - "\n", - "from rich.pretty import pprint\n", - "\n", - "agent_logs = []\n", - "\n", - "for span in client.telemetry.query_spans(\n", - " attribute_filters=[\n", - " {\"key\": \"session_id\", \"op\": \"eq\", \"value\": session_id},\n", - " ],\n", - " attributes_to_return=[\"input\", \"output\"],\n", - "):\n", - " if span.attributes[\"output\"] != \"no shields\":\n", - " agent_logs.append(span.attributes)\n", - "\n", - "print(\"Here are examples of traces:\")\n", - "pprint(agent_logs[:2])\n" - ] - }, - { - "cell_type": "markdown", - "id": "QF30H7ufP2RE", - "metadata": { - "id": "QF30H7ufP2RE" - }, - "source": [ - "- Now, we want to run evaluation to assert that our search agent succesfully calls brave_search from online traces.\n", - "- We will first post-process the agent's telemetry logs and run evaluation." - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "id": "sy4Xaff_Avuu", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/", - "height": 432 - }, - "id": "sy4Xaff_Avuu", - "outputId": "1b14b5ed-4c77-47c4-edfb-1c13a88e5ef4" - }, - "outputs": [ - { - "data": { - "text/html": [ - "
ScoringScoreResponse(\n",
-       "results={\n",
-       "│   │   'basic::subset_of': ScoringResult(\n",
-       "│   │   │   aggregated_results={'accuracy': {'accuracy': 1.0, 'num_correct': 3.0, 'num_total': 3}},\n",
-       "│   │   │   score_rows=[{'score': 1.0}, {'score': 1.0}, {'score': 1.0}]\n",
-       "│   │   )\n",
-       "}\n",
-       ")\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[1;35mScoringScoreResponse\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mresults\u001b[0m=\u001b[1m{\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[32m'basic::subset_of'\u001b[0m: \u001b[1;35mScoringResult\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33maggregated_results\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'accuracy'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'accuracy'\u001b[0m: \u001b[1;36m1.0\u001b[0m, \u001b[32m'num_correct'\u001b[0m: \u001b[1;36m3.0\u001b[0m, \u001b[32m'num_total'\u001b[0m: \u001b[1;36m3\u001b[0m\u001b[1m}\u001b[0m\u001b[1m}\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mscore_rows\u001b[0m=\u001b[1m[\u001b[0m\u001b[1m{\u001b[0m\u001b[32m'score'\u001b[0m: \u001b[1;36m1.0\u001b[0m\u001b[1m}\u001b[0m, \u001b[1m{\u001b[0m\u001b[32m'score'\u001b[0m: \u001b[1;36m1.0\u001b[0m\u001b[1m}\u001b[0m, \u001b[1m{\u001b[0m\u001b[32m'score'\u001b[0m: \u001b[1;36m1.0\u001b[0m\u001b[1m}\u001b[0m\u001b[1m]\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[1m)\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m}\u001b[0m\n", - "\u001b[1m)\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "# NBVAL_SKIP\n", - "# post-process telemetry spance and prepare data for eval\n", - "# in this case, we want to assert that all user prompts is followed by a tool call\n", - "import ast\n", - "import json\n", - "\n", - "eval_rows = []\n", - "\n", - "for log in agent_logs:\n", - " input = json.loads(log[\"input\"])\n", - " if isinstance(input, list):\n", - " input = input[-1]\n", - " if input[\"role\"] == \"user\":\n", - " eval_rows.append(\n", - " {\n", - " \"input_query\": input[\"content\"],\n", - " \"generated_answer\": log[\"output\"],\n", - " # check if generated_answer uses tools brave_search\n", - " \"expected_answer\": \"brave_search\",\n", - " },\n", - " )\n", - "\n", - "# pprint(eval_rows)\n", - "scoring_params = {\n", - " \"basic::subset_of\": None,\n", - "}\n", - "scoring_response = client.scoring.score(\n", - " input_rows=eval_rows, scoring_functions=scoring_params\n", - ")\n", - "pprint(scoring_response)\n" - ] - }, - { - "cell_type": "markdown", - "id": "IKbzhxcw5e_c", - "metadata": { - "id": "IKbzhxcw5e_c" - }, - "source": [ - "#### 3.2. Agentic Application Dataset Scoring\n", - "- Llama Stack offers a library of scoring functions and the `/scoring` API, allowing you to run evaluations on your pre-annotated AI application datasets.\n", - "\n", - "- In this example, we will work with an example RAG dataset you have built previously, label with an annotation, and use LLM-As-Judge with custom judge prompt for scoring. Please checkout our [Llama Stack Playground](https://llama-stack.readthedocs.io/en/latest/playground/index.html) for an interactive interface to upload datasets and run scorings." - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "id": "xG4Y84VQBb0g", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/", - "height": 304 - }, - "id": "xG4Y84VQBb0g", - "outputId": "cf7dcecc-a81d-4c60-af5e-b36b8fe85c69" - }, - "outputs": [ - { - "data": { - "text/html": [ - "
ScoringScoreResponse(\n",
-       "results={\n",
-       "│   │   'llm-as-judge::base': ScoringResult(\n",
-       "│   │   │   aggregated_results={},\n",
-       "│   │   │   score_rows=[\n",
-       "│   │   │   │   {\n",
-       "│   │   │   │   │   'score': 'B',\n",
-       "│   │   │   │   │   'judge_feedback': 'Answer: B, Explanation: The GENERATED_RESPONSE is a superset of the EXPECTED_RESPONSE and is fully consistent with it. The EXPECTED_RESPONSE only mentions \"LoRA\", which is a topic that is extensively covered in the GENERATED_RESPONSE. The GENERATED_RESPONSE provides more specific and detailed topics related to LoRA, but it does not contradict the EXPECTED_RESPONSE.'\n",
-       "│   │   │   │   }\n",
-       "│   │   │   ]\n",
-       "│   │   ),\n",
-       "│   │   'basic::subset_of': ScoringResult(\n",
-       "│   │   │   aggregated_results={'accuracy': {'accuracy': 1.0, 'num_correct': 1.0, 'num_total': 1}},\n",
-       "│   │   │   score_rows=[{'score': 1.0}]\n",
-       "│   │   )\n",
-       "}\n",
-       ")\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[1;35mScoringScoreResponse\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[33mresults\u001b[0m=\u001b[1m{\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[32m'llm-as-judge::base'\u001b[0m: \u001b[1;35mScoringResult\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33maggregated_results\u001b[0m=\u001b[1m{\u001b[0m\u001b[1m}\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mscore_rows\u001b[0m=\u001b[1m[\u001b[0m\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[1m{\u001b[0m\n", - "\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[32m'score'\u001b[0m: \u001b[32m'B'\u001b[0m,\n", - "\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[32m'judge_feedback'\u001b[0m: \u001b[32m'Answer: B, Explanation: The GENERATED_RESPONSE is a superset of the EXPECTED_RESPONSE and is fully consistent with it. The EXPECTED_RESPONSE only mentions \"LoRA\", which is a topic that is extensively covered in the GENERATED_RESPONSE. The GENERATED_RESPONSE provides more specific and detailed topics related to LoRA, but it does not contradict the EXPECTED_RESPONSE.'\u001b[0m\n", - "\u001b[2;32m│ │ │ │ \u001b[0m\u001b[1m}\u001b[0m\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m]\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[1m)\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[32m'basic::subset_of'\u001b[0m: \u001b[1;35mScoringResult\u001b[0m\u001b[1m(\u001b[0m\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33maggregated_results\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'accuracy'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'accuracy'\u001b[0m: \u001b[1;36m1.0\u001b[0m, \u001b[32m'num_correct'\u001b[0m: \u001b[1;36m1.0\u001b[0m, \u001b[32m'num_total'\u001b[0m: \u001b[1;36m1\u001b[0m\u001b[1m}\u001b[0m\u001b[1m}\u001b[0m,\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[33mscore_rows\u001b[0m=\u001b[1m[\u001b[0m\u001b[1m{\u001b[0m\u001b[32m'score'\u001b[0m: \u001b[1;36m1.0\u001b[0m\u001b[1m}\u001b[0m\u001b[1m]\u001b[0m\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[1m)\u001b[0m\n", - "\u001b[2;32m│ \u001b[0m\u001b[1m}\u001b[0m\n", - "\u001b[1m)\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "import rich\n", - "from rich.pretty import pprint\n", - "\n", - "# could even use larger models like 405B\n", - "judge_model_id = \"meta-llama/Llama-3.3-70B-Instruct\"\n", - "\n", - "JUDGE_PROMPT = \"\"\"\n", - "Given a QUESTION and GENERATED_RESPONSE and EXPECTED_RESPONSE.\n", - "\n", - "Compare the factual content of the GENERATED_RESPONSE with the EXPECTED_RESPONSE. Ignore any differences in style, grammar, or punctuation.\n", - " The GENERATED_RESPONSE may either be a subset or superset of the EXPECTED_RESPONSE, or it may conflict with it. Determine which case applies. Answer the question by selecting one of the following options:\n", - " (A) The GENERATED_RESPONSE is a subset of the EXPECTED_RESPONSE and is fully consistent with it.\n", - " (B) The GENERATED_RESPONSE is a superset of the EXPECTED_RESPONSE and is fully consistent with it.\n", - " (C) The GENERATED_RESPONSE contains all the same details as the EXPECTED_RESPONSE.\n", - " (D) There is a disagreement between the GENERATED_RESPONSE and the EXPECTED_RESPONSE.\n", - " (E) The answers differ, but these differences don't matter from the perspective of factuality.\n", - "\n", - "Give your answer in the format \"Answer: One of ABCDE, Explanation: \".\n", - "\n", - "Your actual task:\n", - "\n", - "QUESTION: {input_query}\n", - "GENERATED_RESPONSE: {generated_answer}\n", - "EXPECTED_RESPONSE: {expected_answer}\n", - "\"\"\"\n", - "\n", - "input_query = (\n", - " \"What are the top 5 topics that were explained? Only list succinct bullet points.\"\n", - ")\n", - "generated_answer = \"\"\"\n", - "Here are the top 5 topics that were explained in the documentation for Torchtune:\n", - "\n", - "* What is LoRA and how does it work?\n", - "* Fine-tuning with LoRA: memory savings and parameter-efficient finetuning\n", - "* Running a LoRA finetune with Torchtune: overview and recipe\n", - "* Experimenting with different LoRA configurations: rank, alpha, and attention modules\n", - "* LoRA finetuning\n", - "\"\"\"\n", - "expected_answer = \"\"\"LoRA\"\"\"\n", - "\n", - "rows = [\n", - " {\n", - " \"input_query\": input_query,\n", - " \"generated_answer\": generated_answer,\n", - " \"expected_answer\": expected_answer,\n", - " },\n", - "]\n", - "\n", - "scoring_params = {\n", - " \"llm-as-judge::base\": {\n", - " \"judge_model\": judge_model_id,\n", - " \"prompt_template\": JUDGE_PROMPT,\n", - " \"type\": \"llm_as_judge\",\n", - " \"judge_score_regexes\": [\"Answer: (A|B|C|D|E)\"],\n", - " },\n", - " \"basic::subset_of\": None,\n", - "}\n", - "\n", - "response = client.scoring.score(input_rows=rows, scoring_functions=scoring_params)\n", - "pprint(response)\n" + " print(log, end=\"\", flush=True)\n" ] }, { @@ -2826,7 +2670,7 @@ "id": "ad077440", "metadata": {}, "source": [ - "## 4. Image Understanding with Llama 3.2\n", + "## 3. Image Understanding with Llama 3.2\n", "\n", "Below is a complete example of to ask Llama 3.2 questions about an image." ] @@ -2836,12 +2680,12 @@ "id": "82e381ec", "metadata": {}, "source": [ - "### 4.1 Setup and helpers\n" + "### 3.1 Setup and helpers\n" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 54, "id": "44e05e16", "metadata": {}, "outputs": [ @@ -2851,7 +2695,7 @@ "text": [ " % Total % Received % Xferd Average Speed Time Time Time Current\n", " Dload Upload Total Spent Left Speed\n", - "100 275k 100 275k 0 0 901k 0 --:--:-- --:--:-- --:--:-- 903k\n" + "100 275k 100 275k 0 0 923k 0 --:--:-- --:--:-- --:--:-- 927k\n" ] }, { @@ -2861,7 +2705,7 @@ "" ] }, - "execution_count": 29, + "execution_count": 54, "metadata": { "image/jpeg": { "height": 256, @@ -2880,13 +2724,13 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 55, "id": "a2c1e1c2", "metadata": {}, "outputs": [], "source": [ "import base64\n", - "vision_model_id = \"meta-llama/Llama-3.2-11B-Vision-Instruct\"\n", + "vision_model_id = \"together/meta-llama/Llama-4-Scout-17B-16E-Instruct\"\n", "\n", "def encode_image(image_path):\n", " with open(image_path, \"rb\") as image_file:\n", @@ -2900,20 +2744,33 @@ "id": "7737cd41", "metadata": {}, "source": [ - "### 4.2 Using Llama Stack Inference API for multimodal inference" + "### 3.2 Using Llama Stack Inference API for multimodal inference" ] }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 56, "id": "d7914894", "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:httpx:HTTP Request: POST http://0.0.0.0:8321/v1/chat/completions \"HTTP/1.1 200 OK\"\n" + ] + }, { "name": "stdout", "output_type": "stream", "text": [ - "There are three llamas in the image. The llama in the middle is purple, the llama on the left is white, and the llama on the right is also white, but it is wearing a blue party hat. Therefore, there are two different colors of llama in the image: purple and white.\n" + "The image features three llamas, each with a distinct color. The colors of the llamas are as follows:\n", + "\n", + "* One llama is white.\n", + "* Another llama is purple.\n", + "* The third llama is also white.\n", + "\n", + "Therefore, there are two different colors present among the llamas: white and purple.\n" ] } ], @@ -2924,11 +2781,9 @@ " \"role\": \"user\",\n", " \"content\": [\n", " {\n", - " \"type\": \"image\",\n", - " \"image\": {\n", - " \"url\": {\n", - " \"uri\": encode_image(\"Llama_Repo.jpeg\")\n", - " }\n", + " \"type\": \"image_url\",\n", + " \"image_url\": {\n", + " \"url\": encode_image(\"Llama_Repo.jpeg\")\n", " }\n", " },\n", " {\n", @@ -2944,14 +2799,6 @@ "\n", "print(response.choices[0].message.content)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "f3352379", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { @@ -2961,7 +2808,7 @@ "provenance": [] }, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -2975,7 +2822,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.16" + "version": "3.12.12" } }, "nbformat": 4,