AI Guard は サイトでは利用できません。

手動インテグレーションでは、AI Guard 保護を有効にするために追加の構成が必要です。各フレームワークの手順に従って、AI Guard の評価を設定します。

サポート対象のフレームワークとライブラリ

Amazon Strands および LiteLLM Proxy では、手動インテグレーションがサポートされています。その他のフレームワーク、またはカスタム LLM やツール呼び出しコードについては、SDK を使用して evaluate() コード内で呼び出します。

Python

フレームワークサポートされているバージョンSDK バージョン
Amazon Strands>= 1.29.0>= 4.7.0
LiteLLM Proxy>= 1.78.5>= 4.8.0

Set up the Datadog Agent

SDKs use the Datadog Agent to send AI Guard data to Datadog. The Agent must be running and accessible to your application.

If you don't use the Datadog Agent, the AI Guard evaluator API still works, but you can't see AI Guard traces in Datadog.

Required environment variables

Set the following environment variables in your application:

VariableValue
DD_AI_GUARD_ENABLEDtrue
DD_API_KEY<YOUR_API_KEY>
DD_APP_KEY<YOUR_APPLICATION_KEY>
DD_ENV<YOUR_ENVIRONMENT>
DD_SERVICE<YOUR_SERVICE>

Integrations

Amazon Strands

Python

Amazon Strands インテグレーションにより、Amazon Strands Agents SDK で構築されたアプリケーションで AI Guard の評価を実行できます。

セットアップ

dd-trace-py v4.7.0 以降をインストールします。

pip install ddtrace>=4.7.0

次に、プラグインまたはフックプロバイダーを使用して、インテグレーションのエントリポイントを定義します。

  • プラグイン (推奨):
from ddtrace.appsec.ai_guard import AIGuardStrandsPlugin

agent = Agent(
    model=model,
    plugins=[AIGuardStrandsPlugin()]
)
  • HookProvider (レガシー):
from ddtrace.appsec.ai_guard import AIGuardStrandsHookProvider

agent = Agent(
    model=model,
    hooks=[AIGuardStrandsHookProvider()]
)

LiteLLM Proxy

Python

LiteLLM Proxy インテグレーションにより、LiteLLM Proxy を使用するアプリケーションで AI Guard の評価を実行できます。

セットアップ

dd-trace-py v4.8.0 以降をインストールします。

pip install ddtrace>=4.8.0

構成ファイルの横に Datadog の LiteLLM ガードレールをインポートします (例: guardrails.py)。

from ddtrace.appsec.ai_guard.integrations.litellm import DatadogAIGuardGuardrail

__all__ = ["DatadogAIGuardGuardrail"]

インポートしたガードレールを構成ファイルに追加します。

guardrails:
  - guardrail_name: datadog_ai_guard
    litellm_params:
      guardrail: guardrails.DatadogAIGuardGuardrail
      mode: [pre_call, post_call]
      on_input: true
      on_output: true
      block: true

このガードレールは、pre_call、post_call、during_call の 3 つのモードすべてをサポートしています。

デフォルトでは、ガードレールは AI Guard サービスの設定で指定されたブロック設定に従います。ブロックを無効にするには、block パラメーターを false に設定します (SDK および REST API の block オプションと同等です)。

参考資料