設定品質警告

當代理的效能低於定義的門檻時,品質快訊會通知您。您可以運用這些快訊偵測品質漂移,也就是代理效能隨時間明顯下降。即使基礎模型保持不變,也可能發生這種情況,原因通常是實際使用者行為改變、資料模式演變,或複雜提示詞鏈結中的細微互動。

設定線上監控器後,系統會自動將數值評估分數匯出至 Cloud Monitoring。這些指標會在 Cloud Monitoring 中觸發事件。接著,您可以建立警告政策,在發生品質問題時通知團隊。

您可以為特定監控器建立指定警告政策:

  1. 前往 Google Cloud 控制台的「Agent Platform」>「代理」頁面。
  2. 在左側導覽選單中,選取「Evaluation」(評估)。

    前往「Evaluation」(評估)

  3. 選取「線上監控」分頁標籤。按一下監控器的「More options」(更多選項) ,然後選取「Create alerting policy」(建立警告政策)。

  4. 查看該監控項目的警告政策範本。

  5. 選取要啟用的範本。系統會根據監控器設定的每項指標,提供一個範本。

  6. 設定通知:選取「通知管道」。如果取消勾選「Use notification channels」,系統會執行檢查,但不會主動通知使用者。您仍可在「Monitoring」>「Alerting」(快訊) 頁面查看觸發的事件。

  7. 點選「建立」。

評估資訊主頁提供捷徑,可為所有運作中的監控工具啟用廣泛的品質護欄:

  1. 前往 Google Cloud 控制台的「Agent Platform」>「代理」頁面。
  2. 在左側導覽選單中,依序選取「Deployments」(部署作業) 和代理。

    前往「Deployments」(部署作業) 頁面

  3. 選取「資訊主頁」分頁,然後選取「評估」子節。

  4. 按一下右上角的「建議快訊」按鈕。

  5. 查看可用的範本,例如:

    • 線上監控 - 評估分數偏低:如果監控器的匯總分數過低,就會觸發。
    • 個別指標快訊:「工作成功」或「工具使用品質」等指標的特定門檻。
  6. 選取範本和通知管道,然後按一下「Create」(建立)。

以程式輔助方式建立警告

如要大規模部署,可以使用 gcloud CLI 或 Cloud Monitoring API 設定品質快訊。

使用 gcloud

透過 JSON 或 YAML 設定檔建立警告政策:

gcloud monitoring policies create --policy-from-file="policy.yaml"

以下是 policy.yaml 範例,如果 30 分鐘內的平均工作成功分數低於 80%,就會觸發:

displayName: "Low Task Success Score"
conditions:
- displayName: "Task Success < 0.8"
  conditionThreshold:
    filter: >
      metric.type="aiplatform.googleapis.com/online_evaluator/scores"
      AND metric.labels.evaluation_metric_name="task_success"
    comparison: COMPARISON_LT
    thresholdValue: 0.8
    duration: 1800s
    aggregations:
    - alignmentPeriod: 60s
      perSeriesAligner: ALIGN_MEAN
combiner: OR
enabled: true
notificationChannels:
- "projects/YOUR_PROJECT_ID/notificationChannels/CHANNEL_ID"

使用 Agent Platform SDK

from google.cloud import monitoring_v3

client = monitoring_v3.AlertPolicyServiceClient()
project_name = f"projects/YOUR_PROJECT_ID"

policy = {
    "display_name": "Agent Quality Drift",
    "conditions": [{
        "display_name": "Low Evaluation Score",
        "condition_threshold": {
            "filter": (
                'metric.type="aiplatform.googleapis.com/online_evaluator/scores"'
            ),
            "comparison": monitoring_v3.ComparisonType.COMPARISON_LT,
            "threshold_value": 0.7,
            "duration": {"seconds": 3600},
            "aggregations": [{
                "alignment_period": {"seconds": 60},
                "per_series_aligner": monitoring_v3.Aggregation.Aligner.ALIGN_MEAN,
            }],
        },
    }],
    "combiner": monitoring_v3.AlertPolicy.ConditionCombinerType.OR,
    "enabled": True,
}

response = client.create_alert_policy(name=project_name, alert_policy=policy)
print(f"Created alerting policy {response.name}")

管理警告政策

使用 Cloud Monitoring 控制台查看警告政策的位置,並調整設定。每個事件都會包含相關聯線上監控器的標籤,協助您調查根本原因。

前往「Alerting」(快訊)