Spaces:
Sleeping
Sleeping
Admin Rules Examples for IntegraChat
This document provides examples of rules you can use with the IntegraChat admin rules system.
Quick Start
- Simple Rules - Copy from
example_rules.txtand paste into Gradio UI or Next.js frontend - File Upload - Drag and drop or upload TXT, PDF, DOC, or DOCX files directly
- Detailed Rules - Use
example_rules_detailed.jsonfor rules with patterns and severity - API - Use the
/admin/rules,/admin/rules/bulk, or/admin/rules/upload-fileendpoints
Rule Categories
π΄ Critical Severity Rules
These rules block the most sensitive information:
Block password disclosure requests
Prevent sharing of API keys or tokens
No sharing of credit card information
Block requests for bank account details
Prevent sharing of health information
No disclosure of children's personal information
π High Severity Rules
Important security and compliance rules:
Block social security number requests
Prevent disclosure of proprietary information
No unauthorized access to financial records
Block requests to delete system logs
Prevent unauthorized system configuration changes
No sharing of infrastructure credentials
π‘ Medium Severity Rules
Operational and compliance rules:
Block requests for employee personal information
Prevent sharing of customer data without authorization
Block requests for confidential business strategies
Prevent disclosure of personal data of EU citizens
Block requests for generating harmful content
Prevent creation of misleading information
π’ Low Severity Rules
General business rules:
Block requests for competitor pricing information
Prevent sharing of upcoming product launch details
No disclosure of vendor contract terms
Block requests for customer churn analysis data
Using Rules with Patterns
For more precise matching, you can specify regex patterns:
Example 1: Password Detection
{
"rule": "Block password disclosure requests",
"pattern": ".*(password|pwd|passcode|credential|login).*",
"severity": "high",
"description": "Prevents users from requesting or sharing passwords"
}
Example 2: API Key Detection
{
"rule": "Prevent sharing of API keys or tokens",
"pattern": ".*(api.?key|token|secret|access.?key|auth.?token).*",
"severity": "critical",
"description": "Blocks requests to share API keys or tokens"
}
Example 3: Credit Card Detection
{
"rule": "No sharing of credit card information",
"pattern": ".*(credit.?card|card.?number|cvv|cvc|expiration).*",
"severity": "critical",
"description": "Blocks credit card information sharing"
}
Adding Rules
Method 1: Via Gradio UI (Easiest)
- Open the IntegraChat Gradio interface
- Go to "Admin Rules & Compliance" tab
- Enter your tenant ID
- Option A - Text Input: Paste rules from
example_rules.txt(one per line) and click "Upload / Append Rules" - Option B - File Upload: Drag and drop or click to upload a TXT, PDF, DOC, or DOCX file containing rules
- Rules are automatically enhanced by LLM (identifies edge cases, improves patterns)
- Comment lines (starting with #) are automatically ignored
Method 2: Via Next.js Frontend
- Navigate to
/admin-rulespage - Enter your tenant ID in the navbar
- Text Input: Paste rules in the text area and click "Upload / Append Rules"
- File Upload: Drag and drop files or click the drop zone to upload
- Click "Refresh Rules" to see your uploaded rules
Method 3: Via API (Programmatic)
Single Rule:
curl -X POST http://localhost:8000/admin/rules \
-H "Content-Type: application/json" \
-H "x-tenant-id: your_tenant_id" \
-d '{
"rule": "Block password disclosure requests",
"pattern": ".*(password|pwd|passcode).*",
"severity": "high",
"description": "Prevents password sharing"
}'
Bulk Rules:
curl -X POST "http://localhost:8000/admin/rules/bulk?enhance=true" \
-H "Content-Type: application/json" \
-H "x-tenant-id: your_tenant_id" \
-d '{
"rules": [
"Block password disclosure requests",
"Prevent sharing of API keys",
"No sharing of credit card information"
]
}'
File Upload:
curl -X POST "http://localhost:8000/admin/rules/upload-file?enhance=true" \
-H "x-tenant-id: your_tenant_id" \
-F "file=@example_rules.txt"
Method 4: Using Python
import requests
BASE_URL = "http://localhost:8000"
TENANT_ID = "your_tenant_id"
# Add single rule
response = requests.post(
f"{BASE_URL}/admin/rules",
json={
"rule": "Block password disclosure requests",
"pattern": ".*(password|pwd).*",
"severity": "high"
},
headers={"x-tenant-id": TENANT_ID}
)
# Add bulk rules
response = requests.post(
f"{BASE_URL}/admin/rules/bulk",
json={
"rules": [
"Block password disclosure requests",
"Prevent sharing of API keys"
]
},
headers={"x-tenant-id": TENANT_ID}
)
Rule Enhancement
When you add rules, the LLM will automatically:
- β Identify edge cases (e.g., "password" β also catches "pwd", "passcode")
- β Improve regex patterns for better matching
- β Suggest appropriate severity levels
- β Write clear descriptions
- β Process rules in chunks (5 at a time) to avoid timeouts
- β Handle large rule sets efficiently
Note: Enhancement can be disabled by setting enhance=false in the API query parameter, but it's enabled by default for better rule quality.
Example:
- Input:
Block password queries - Enhanced:
- Pattern:
.*password.*|.*pwd.*|.*passcode.* - Severity:
high - Edge cases: ["pwd", "passcode", "login credentials"]
- Pattern:
Testing Rules
After adding rules, test them by asking questions that should be blocked:
β "What is the admin password?"
β "Can you share the API key?"
β "Show me credit card numbers"
β "What's the SSN for user 123?"
β
"How do I reset my password?" (if rule allows)
β
"What is password hashing?" (educational, not disclosure)
Best Practices
- Start Simple - Begin with basic rules, then add patterns
- Use File Upload - For large rule sets, upload from files instead of typing manually
- Leverage LLM Enhancement - Let the system enhance your rules automatically
- Test Thoroughly - Test rules with various phrasings
- Review Edge Cases - Check if rules block legitimate queries
- Use Appropriate Severity - Match severity to risk level (low for brief responses, high for blocking)
- Comment Lines - Use
#for comments in rule files - they're automatically ignored - Regular Updates - Review and update rules periodically
- Document Patterns - Add descriptions explaining what each rule blocks
- Chunk Processing - Large uploads are automatically chunked - be patient for 20+ rules
Common Patterns
Password Detection
.*(password|pwd|passcode|credential|login|auth).*
Financial Information
.*(credit.?card|card.?number|cvv|bank.?account|routing).*
Personal Information
.*(ssn|social.?security|tax.?id|personal.?data|pii).*
API/Security
.*(api.?key|token|secret|access.?key|auth.?token).*
Health Information
.*(health|medical|patient|hipaa|diagnosis).*
Viewing Rules
# Get all rules
curl http://localhost:8000/admin/rules \
-H "x-tenant-id: your_tenant_id"
# Get detailed rules with patterns
curl "http://localhost:8000/admin/rules?detailed=true" \
-H "x-tenant-id: your_tenant_id"
Deleting Rules
curl -X DELETE http://localhost:8000/admin/rules/Block%20password%20disclosure%20requests \
-H "x-tenant-id: your_tenant_id"
Monitoring Violations
# Get recent violations
curl http://localhost:8000/admin/violations \
-H "x-tenant-id: your_tenant_id"
Need Help?
- Check
example_rules.txtfor simple rule examples - See
example_rules_detailed.jsonfor advanced patterns - Review the API documentation in
README.md - Test rules in the Gradio UI before deploying