Skip to main content

LangChain-integrated compliance audit handler for GenAI (EU AI Act etc.). Captures prompts, outputs, and model usage with provenance hashing.

Project description

genai-auditor

LangChain に統合できる GenAI コンプライアンス監査パッケージです。

ディレクトリ構成

genai-auditor/
├── pyproject.toml          # ビルド・メタデータ(PyPI 公開用)
├── README.md
├── example.py              # 開発者向け動作確認スクリプト
└── src/
    └── genai_auditor/
        ├── __init__.py     # パッケージエントリ(ComplianceAuditCallbackHandler を公開)
        └── callback.py     # コールバック実装・監査ログ生成・保存ロジック

EU AI Act 等の 2026 年 AI 法規制に対応するため、LLM の入力・出力・モデル名を自動取得し、改ざん防止用のプロビナンスハッシュ付きで監査ログを保存します。

インストール

pip install genai-auditor

開発版(ローカル):

pip install -e /path/to/genai-auditor

3 行で導入

既存の LangChain コードにコールバックを渡すだけで監査が有効になります。

from langchain_openai import ChatOpenAI
from genai_auditor import ComplianceAuditCallbackHandler

audit = ComplianceAuditCallbackHandler()
llm = ChatOpenAI(model="gpt-4o-mini", callbacks=[audit])
response = llm.invoke("こんにちは")

監査ログはデフォルトで audit_logs.json に追記されます。

監査ログの形式

各エントリには以下が含まれます。

  • run_id: LangChain の実行 ID
  • model_name: 使用したモデル名
  • prompts: 入力プロンプト(リスト)
  • outputs: LLM 出力テキスト(リスト)
  • started_at / ended_at: ISO 8601 タイムスタンプ(UTC)
  • provenance_hash: 上記フィールドから計算した SHA-256 ハッシュ(改ざん検知用)

ログファイルの指定

audit = ComplianceAuditCallbackHandler(audit_log_path="./logs/compliance.json")

ライセンス

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

genai_auditor-0.1.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

genai_auditor-0.1.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file genai_auditor-0.1.0.tar.gz.

File metadata

  • Download URL: genai_auditor-0.1.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for genai_auditor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3b48ef942cde490c9229cc5679b9bcb89869cb8e55c8e594a36df61f220d17c2
MD5 6353f873a8d685d83d5f2c9b19ca0fab
BLAKE2b-256 7608830d8614ef2db25fa0793f737015deade278065d028da7cdbbb6ac7d3e0f

See more details on using hashes here.

File details

Details for the file genai_auditor-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: genai_auditor-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for genai_auditor-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a1d7a8a902036fea4b347dcaeec7905d78a9d83bbac847d0f733889f3676acba
MD5 95070972a14e673a14be35e53a79ee44
BLAKE2b-256 627426b318b7d8564401601225c9e5842f9f4869824770a692be1a7e920c85bf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page