Skip to main content

DuoGuard-Nemo: A multi-layered security system for LLM applications

Project description

DuoGuard-Nemo

A multi-layered security system for LLM applications, built on top of NeMo Guardrails.

Features

  • NeMo Guardrails integration for content filtering
  • OpenAI content generation with security checks
  • Comprehensive security logging
  • Easy-to-use SDK interface
  • Configurable security rules

Installation

pip install duoguard-nemo

Quick Start

import asyncio
from duoguard_nemo import DuoGuardNemoSDK

async def main():
    # Initialize the SDK
    sdk = DuoGuardNemoSDK(
        config_path="config",  # Path to NeMo Guardrails config
        openai_api_key="your-api-key",  # Or use OPENAI_API_KEY env var
        log_path="logs/security.log"
    )
    
    # Process a message
    result = await sdk.process_message(
        messages=[{"role": "user", "content": "Write an article about healthy eating."}],
        system_prompt="You are an AI Article writer..."
    )
    
    if result["success"]:
        print("Generated content:", result["response"])
    else:
        print("Error:", result["error"])

if __name__ == "__main__":
    asyncio.run(main())

Configuration

NeMo Guardrails Config

Place your NeMo Guardrails configuration in the config directory. The SDK will use this for content filtering.

Environment Variables

  • OPENAI_API_KEY: Your OpenAI API key (optional if provided during initialization)

Security Logging

Security decisions and events are logged to logs/security.log by default. Each log entry includes:

  • Timestamp
  • Event type
  • Message content
  • Decision details
  • Error information (if any)

Development

  1. Clone the repository
  2. Install development dependencies:
    pip install -e ".[dev]"
    
  3. Run tests:
    pytest
    

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

duoguard_nemo-0.1.0.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

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

duoguard_nemo-0.1.0-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: duoguard_nemo-0.1.0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for duoguard_nemo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dbd99c5c461ffcf0387051f49968a1a416b357d6d0202f9f3e0e9abba6c03120
MD5 6599be7b570b90a20457d16c62cdc586
BLAKE2b-256 2bcb3a999730afe3e97cafab5c2bf6d543cbfcde0a97bcc0d4d72692485c3e23

See more details on using hashes here.

File details

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

File metadata

  • Download URL: duoguard_nemo-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for duoguard_nemo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7c74048219699a56804603bb4b701a52ab0173724bd29d972ae176d99daa7440
MD5 d73f043db766dfa3036e5f3abd4bb86d
BLAKE2b-256 035cfa45c634829f35622a393926be4cf82826bc8a5086af2c8c47f7b661dbab

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