1.0.0 • Published 5 months ago

gdpr-llm-guard v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

GDPR LLM Guard

A robust, enterprise-grade GDPR compliance framework for LLM agents. This library helps ensure your AI applications comply with GDPR requirements while interacting with language models.

Features

  • 🛡️ GDPR Compliance

    • Automatic PII detection and filtering
    • Data retention controls
    • Audit logging
    • Legal basis tracking
  • 🤖 LLM Integration

    • Support for multiple providers (OpenAI, GROQ)
    • Streaming responses
    • Conversation history management
  • 📊 Privacy Controls

    • Configurable data retention periods
    • Sensitive data pattern matching
    • Data minimization

Installation

npm install gdpr-llm-guard

Quick Start

import { MedGuard } from 'gdpr-llm-guard';

// Initialize the GDPR-compliant guard
const guard = new MedGuard({
  apiKey: process.env.GROQ_API_KEY,
  model: 'mixtral-8x7b-32768',
  provider: 'groq',
  dataRetentionDays: 30,
  auditEnabled: true,
  maxRetentionPeriod: 90,
  sensitiveDataPatterns: [
    /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/, // Email addresses
    /\b\d{16}\b/, // Credit card numbers
  ],
});

// Process data with GDPR compliance
const result = await guard.processSensitiveData(userInput, {
  dataController: 'MyApp',
  processingPurpose: 'Customer Support',
  legalBasis: 'Legitimate Interest',
  sessionId: 'user123',
  retentionPeriod: 30
});

Examples

Check out the examples directory for:

  • Simple chatbot implementation
  • Financial advisor bot
  • Haiku generator
  • Web-based chat interface

GDPR Compliance Features

  1. Data Protection

    • Automatic PII detection
    • Configurable retention periods
    • Secure data handling
  2. Audit Logging

    • Track all data processing
    • Monitor compliance
    • Generate reports
  3. Privacy by Design

    • Data minimization
    • Purpose limitation
    • Storage limitation

Configuration

interface MedGuardConfig {
  apiKey: string;
  model: string;
  provider: 'openai' | 'groq';
  dataRetentionDays: number;
  auditEnabled: boolean;
  maxRetentionPeriod: number;
  sensitiveDataPatterns: RegExp[];
}

Contributing

We welcome contributions! Please see our contributing guidelines for more details.

License

MIT License - see LICENSE file for details.