Skip to main content

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.

Metadata

Release files for duoguard-nemo 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for duoguard-nemo 0.1.0
File Size Uploaded
duoguard_nemo-0.1.0.tar.gz 11.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for duoguard-nemo 0.1.0
File Interpreter ABI Platform
duoguard_nemo-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 26.8 kB

Release files / duoguard_nemo-0.1.0.tar.gz

Download URL duoguard_nemo-0.1.0.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
dbd99c5c461ffcf0387051f49968a1a416b357d6d0202f9f3e0e9abba6c03120
BLAKE2b-256 checksum
How to use checksums
2bcb3a999730afe3e97cafab5c2bf6d543cbfcde0a97bcc0d4d72692485c3e23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release files / duoguard_nemo-0.1.0-py3-none-any.whl

Download URL duoguard_nemo-0.1.0-py3-none-any.whl
Size 15.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7c74048219699a56804603bb4b701a52ab0173724bd29d972ae176d99daa7440
BLAKE2b-256 checksum
How to use checksums
035cfa45c634829f35622a393926be4cf82826bc8a5086af2c8c47f7b661dbab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page