Skip to main content

A lightweight Python framework for agent content moderation.

Project description

👍
allow-agent

A lightweight Python framework for agent content moderation.


Installation

pip install allow-agent

What is allow-agent?

allow-agent is a simple yet powerful framework that automatically intercepts outbound HTTP requests made by AI agents. It gives you complete visibility and control over what your AI agents are doing behind the scenes.

Quick Start

1. Define a Request Handler

Place this at the top of your file to automatically intercept all outbound API requests:

from allow_agent import *

# This decorator enables automatic request interception
@request
def request(url, method, headers, body):
    if url == "https://api.openai.com/v1/chat/completions":
        print(f"OpenAI API Request: {body['messages'][0]}")
        
    return True  # Allow all requests by default

2. Use the rest normally

The handler will automatically intercept all outbound requests. No need for any special configuration.

# Your code works normally - requests are automatically intercepted
from openai import OpenAI

client = OpenAI()
response = client.chat.completions.create(
    model="o1-mini",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "This is a test prompt."}
    ]
)
print(response.choices[0].message.content)

Compatibility

Library Status
openai ✅ Supported
anthropic 🔄 Coming soon
langchain 🔄 Coming soon
browser-use 🔄 Coming soon
aisuite 🔄 Coming soon
requests 🔄 Coming soon
google-generativeai 🔄 Coming soon

Block requests

@request
def request(url, method, headers, body):
    # Block requests containing sensitive keywords
    if "api.openai.com" in url:
        messages_text = str(body.get("messages", ""))
        sensitive_terms = ["password", "credit card", "ssn"]
        
        for term in sensitive_terms:
            if term in messages_text.lower():
                print(f"Blocked request containing sensitive term: {term}")
                return False  # Block the request
                
    return True  # Allow all other requests

Common Use Cases

  • Logging: Monitor all prompts sent to AI models
  • Content Filtering: Block requests containing sensitive information
  • Cost Control: Limit the number or size of API calls
  • Compliance: Ensure all AI interactions follow regulatory requirements
  • Debugging: Inspect exactly what data is being sent to external services

⭐ 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

allow_agent-1.1.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

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

allow_agent-1.1.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file allow_agent-1.1.0.tar.gz.

File metadata

  • Download URL: allow_agent-1.1.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for allow_agent-1.1.0.tar.gz
Algorithm Hash digest
SHA256 a70c93a154b6020b323556f661aa7e5957978ff582f337ec67f13dc6bf554b2c
MD5 12ce849ecf3918afcbcd33a404814192
BLAKE2b-256 d39ee66d9fe0c59dd7e01ea2caa9d3bdbb593e72ae56959ff7f2cfe800196029

See more details on using hashes here.

File details

Details for the file allow_agent-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: allow_agent-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for allow_agent-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 070a7f4f251fc831baafa25e8d1496cc36323ba3358f54acfaf2a8bda49b3884
MD5 d300cebdc9f1ca192895fdd511452909
BLAKE2b-256 1adf13980d14e2aee0fd0c1c9cd414add3f72e7268dd6d8c581ee2251231d807

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