|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": null, |
| 6 | + "metadata": { |
| 7 | + "id": "9ZUGfIJwT-H2" |
| 8 | + }, |
| 9 | + "outputs": [], |
| 10 | + "source": [ |
| 11 | + "# Copyright 2025 Google LLC\n", |
| 12 | + "#\n", |
| 13 | + "# Licensed under the Apache License, Version 2.0 (the \"License\");\n", |
| 14 | + "\n", |
| 15 | + "# you may not use this file except in compliance with the License.\n", |
| 16 | + "# You may obtain a copy of the License at\n", |
| 17 | + "#\n", |
| 18 | + "# https://www.apache.org/licenses/LICENSE-2.0\n", |
| 19 | + "#\n", |
| 20 | + "# Unless required by applicable law or agreed to in writing, software\n", |
| 21 | + "# distributed under the License is distributed on an \"AS IS\" BASIS,\n", |
| 22 | + "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n", |
| 23 | + "# See the License for the specific language governing permissions and\n", |
| 24 | + "# limitations under the License." |
| 25 | + ] |
| 26 | + }, |
| 27 | + { |
| 28 | + "cell_type": "markdown", |
| 29 | + "metadata": { |
| 30 | + "id": "NulM87jyTWJG" |
| 31 | + }, |
| 32 | + "source": [ |
| 33 | + "# Placeholder of Gen AI Agent Eval SDK (Colab 1 for UI)" |
| 34 | + ] |
| 35 | + }, |
| 36 | + { |
| 37 | + "cell_type": "markdown", |
| 38 | + "source": [ |
| 39 | + "**Goals:**\n", |
| 40 | + "\n", |
| 41 | + "This Colab notebook demonstrates how to use the Gen AI Eval SDK to evaluate your agents. It covers one primary use cases:\n", |
| 42 | + "\n", |
| 43 | + "1. Run Agent + Create Evaluatuation Run: The SDK will first run the agent and then create evaluation run to perform the evaluation." |
| 44 | + ], |
| 45 | + "metadata": { |
| 46 | + "id": "NWiijMdFxAon" |
| 47 | + } |
| 48 | + }, |
| 49 | + { |
| 50 | + "cell_type": "markdown", |
| 51 | + "metadata": { |
| 52 | + "id": "JTK2Y3bRUMce" |
| 53 | + }, |
| 54 | + "source": [ |
| 55 | + "# Set up" |
| 56 | + ] |
| 57 | + }, |
| 58 | + { |
| 59 | + "cell_type": "markdown", |
| 60 | + "source": [ |
| 61 | + "## Authenticate" |
| 62 | + ], |
| 63 | + "metadata": { |
| 64 | + "id": "mqNKLziY0mr3" |
| 65 | + } |
| 66 | + }, |
| 67 | + { |
| 68 | + "cell_type": "code", |
| 69 | + "execution_count": null, |
| 70 | + "metadata": { |
| 71 | + "id": "nax0k_afTVKc" |
| 72 | + }, |
| 73 | + "outputs": [], |
| 74 | + "source": [ |
| 75 | + "from google.colab import auth\n", |
| 76 | + "auth.authenticate_user()" |
| 77 | + ] |
| 78 | + }, |
| 79 | + { |
| 80 | + "cell_type": "markdown", |
| 81 | + "metadata": { |
| 82 | + "id": "f4_NugC0UFCU" |
| 83 | + }, |
| 84 | + "source": [ |
| 85 | + "## Install Vertex AI SDK for Gen AI Evaluation Service" |
| 86 | + ] |
| 87 | + }, |
| 88 | + { |
| 89 | + "cell_type": "code", |
| 90 | + "source": [ |
| 91 | + "%pip install --upgrade --force-reinstall -q google-cloud-aiplatform[evaluation]" |
| 92 | + ], |
| 93 | + "metadata": { |
| 94 | + "id": "lWaDe8WN0sKm" |
| 95 | + }, |
| 96 | + "execution_count": null, |
| 97 | + "outputs": [] |
| 98 | + }, |
| 99 | + { |
| 100 | + "cell_type": "markdown", |
| 101 | + "source": [ |
| 102 | + "## Initialize Variables" |
| 103 | + ], |
| 104 | + "metadata": { |
| 105 | + "id": "a1r_ha0J69yQ" |
| 106 | + } |
| 107 | + }, |
| 108 | + { |
| 109 | + "cell_type": "code", |
| 110 | + "execution_count": null, |
| 111 | + "metadata": { |
| 112 | + "id": "r8-HbNKnUQD3" |
| 113 | + }, |
| 114 | + "outputs": [], |
| 115 | + "source": [ |
| 116 | + "import vertexai\n", |
| 117 | + "import pandas as pd\n", |
| 118 | + "from vertexai.preview import reasoning_engines\n", |
| 119 | + "from vertexai import agent_engines\n", |
| 120 | + "import os\n", |
| 121 | + "\n", |
| 122 | + "PROJECT_ID = \"\" # @param {type: \"string\", placeholder: \"[your-project-id]\", isTemplate: true}\n", |
| 123 | + "if not PROJECT_ID or PROJECT_ID == \"[your-project-id]\":\n", |
| 124 | + " PROJECT_ID = str(os.environ.get(\"GOOGLE_CLOUD_PROJECT\"))\n", |
| 125 | + "LOCATION= \"\" # @param {type: \"string\", placeholder: \"us-central1\", isTemplate: true}\n", |
| 126 | + "LOCATION = os.environ.get(\"GOOGLE_CLOUD_REGION\", LOCATION)\n", |
| 127 | + "# e.g. gs://my-bucket/my-folder\n", |
| 128 | + "GCS_DEST = \"\" # @param {type: \"string\", placeholder: \"[your-gcs-bucket]\", isTemplate: true}\n", |
| 129 | + "# e.g. projects/977012026409/locations/us-central1/reasoningEngines/7188347537655332864\n", |
| 130 | + "AGENT = \"\" # @param {type: \"string\", placeholder: \"[your-agent]\", isTemplate: true}\n", |
| 131 | + "\n", |
| 132 | + "\n", |
| 133 | + "from vertexai import Client, types\n", |
| 134 | + "from google.genai import types as genai_types\n", |
| 135 | + "\n", |
| 136 | + "vertexai.init(project=PROJECT_ID, location=LOCATION)\n", |
| 137 | + "client = Client(project=PROJECT_ID, location=LOCATION)" |
| 138 | + ] |
| 139 | + } |
| 140 | + ], |
| 141 | + "metadata": { |
| 142 | + "colab": { |
| 143 | + "provenance": [], |
| 144 | + "toc_visible": true |
| 145 | + }, |
| 146 | + "kernelspec": { |
| 147 | + "display_name": "Python 3", |
| 148 | + "name": "python3" |
| 149 | + }, |
| 150 | + "language_info": { |
| 151 | + "name": "python" |
| 152 | + } |
| 153 | + }, |
| 154 | + "nbformat": 4, |
| 155 | + "nbformat_minor": 0 |
| 156 | +} |
0 commit comments