Skip to content

Instantly share code, notes, and snippets.

View inardini's full-sized avatar

Ivan Nardini inardini

View GitHub Profile
@inardini
inardini / adk_agent_engine_multimodal_query.py
Last active March 1, 2026 04:34
Sends a multimodal query to ADK agent hosted on Vertex AI Agent Engine.
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,
# 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")
@inardini
inardini / evaluate_judge.py
Last active April 2, 2025 02:27
Evaluate a judge model
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"]
### 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
# 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 \