This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import vertexai | |
| from vertexai import agent_engines | |
| from typing import Optional, Dict, Any | |
| def query_multimodal_agent( | |
| project_id: str, | |
| location: str, | |
| agent_engine_id: str, | |
| file_gcs_uri: str, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 1. Install dependencies (run in terminal) | |
| # pip install 'google-cloud-aiplatform>=1.84.0' 'openai' 'google-auth' 'requests' | |
| # 2. Import libraries | |
| import vertexai | |
| from vertexai.preview import model_garden | |
| # 3. Initialize Vertex AI SDK (replace placeholders) | |
| vertexai.init(project="your-project", location="your-region") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| from vertexai.preview.evaluation import PairwiseMetric, EvalTask, MetricPromptTemplateExamples | |
| from vertexai.preview.evaluation.autorater_utils import evaluate_autorater | |
| # Prepare the evaluation dataset with the human rating data column. | |
| human_rated_dataset = pd.DataFrame({ | |
| "prompt": ["Researchers at ... ", "Introducing the 'SilentStep'..."], | |
| "response": ["A new solar panel ...", "The 'SilentStep' treadmill..."], | |
| "baseline_model_response": ["Researchers developed...", "This is the 'SilentStep'..."], | |
| "pairwise_fluency/human_pairwise_choice": ["CANDIDATE", "BASELINE"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### Pseudo code of Cloud Function v2 retraining trigger | |
| import base64 | |
| import json | |
| import yaml | |
| from pathlib import Path as p | |
| from datetime import datetime | |
| from google.cloud import aiplatform as vertex_ai | |
| # Get config variables |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Vertex AI BQML pipeline pseudo code | |
| @dsl.pipeline( | |
| name=PIPELINE_NAME, | |
| description="A batch pipeline to train ARIMA PLUS and generate predictions using BQML", | |
| ) | |
| def pipeline( | |
| ): | |
| from google_cloud_pipeline_components.v1.bigquery import \ |