Loading...
Loading...
Manages GenAI tuning jobs in Agent Platform. Use this to list, get, or cancel ongoing model tuning jobs. Don't use for fine-tuning models (use `agent-platform-tuning`), deploying models to endpoints (use `agent-platform-deploy`), or managing serving endpoints (use `agent-platform-endpoint-management`).
npx skill4agent add google/skills agent-platform-tuning-managementlistgetcancelpython3 -m venv ~/tuning_mgr_venv
source ~/tuning_mgr_venv/bin/activategcloud auth login
gcloud auth application-default loginpip install google-cloud-aiplatform[!NOTE] Resource Verification & Missing Projects/Jobs: If the execution of the Python snippet fails with an error (such as,403 Permission Denied,404 Not Found, or indicating a dummy/missing project or job ID), you MUST inform the user that the project or tuning job does not exist or cannot be accessed. You MUST prompt the user to provide a valid Project ID or Job ID, and stop tool execution immediately to wait for their response. Do NOT retry or loop, do NOT assume the resource is valid, and do NOT execute further scripts before receiving valid details from the user.INVALID_ARGUMENT
from google.cloud import aiplatform_v1
project_id = "YOUR_PROJECT_ID"
region = "YOUR_REGION"
parent = f"projects/{project_id}/locations/{region}"
client = aiplatform_v1.GenAiTuningServiceClient(
client_options={"api_endpoint": f"{region}-aiplatform.googleapis.com"}
)
jobs = client.list_tuning_jobs(parent=parent)
for job in jobs:
print(f"Name: {job.name}")
print(f"Base Model: {job.base_model}")
print(f"State: {job.state}")from google.cloud import aiplatform_v1
project_id = "YOUR_PROJECT_ID"
region = "YOUR_REGION"
job_id = "YOUR_JOB_ID" # 19-digit ID
name = f"projects/{project_id}/locations/{region}/tuningJobs/{job_id}"
client = aiplatform_v1.GenAiTuningServiceClient(
client_options={"api_endpoint": f"{region}-aiplatform.googleapis.com"}
)
job = client.get_tuning_job(name=name)
print(f"Name: {job.name}")
print(f"Base Model: {job.base_model}")
print(f"State: {job.state}")
print(f"Tuning Model: {job.tuned_model_display_name}")[!IMPORTANT] NEVER pre-emptively provide or execute any cancellation code before receiving the user's response in a new turn. You must never speculate or assume that confirmation will be given. Asking for confirmation and providing the code in a single parallel turn is a severe safety violation.
from google.cloud import aiplatform_v1
project_id = "YOUR_PROJECT_ID"
region = "YOUR_REGION"
job_id = "YOUR_JOB_ID" # 19-digit ID
name = f"projects/{project_id}/locations/{region}/tuningJobs/{job_id}"
client = aiplatform_v1.GenAiTuningServiceClient(
client_options={"api_endpoint": f"{region}-aiplatform.googleapis.com"}
)
client.cancel_tuning_job(name=name)
print(f"Successfully requested cancellation for {name}")