perplexity-policy-guardrails

Featured

Implement content moderation, model selection policy, citation quality enforcement, and per-user usage quotas for Perplexity Sonar API. Trigger with phrases like "perplexity policy", "perplexity guardrails", "perplexity content moderation", "perplexity usage limits", "perplexity safety".

AI & Automation 2,944 stars 440 forks Updated today MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Perplexity Policy Guardrails ## Overview Policy enforcement for Perplexity Sonar API. Since Perplexity performs live web searches, guardrails must address: query content moderation (what users can search for), citation reliability (filtering low-quality sources), cost control (model selection + token limits), and responsible AI usage. ## Policy Pipeline ``` User Query │ ▼ Query Moderation (block harmful queries) │ ▼ PII Sanitization (strip personal data) │ ▼ Quota Check (daily limit by user tier) │ ▼ Model Selection (enforce tier-appropriate model) │ ▼ Perplexity API Call │ ▼ Citation Quality Scoring (filter low-trust sources) │ ▼ Response to User ``` ## Prerequisites - Perplexity API configured - Content moderation policy defined - User tier system in place - Redis for quota tracking (optional: in-memory for simple apps) ## Instructions ### Step 1: Query Content Moderation ```typescript const BLOCKED_PATTERNS = [ /\b(write|generate|create)\s+(malware|virus|exploit|ransomware)\b/i, /\b(personal|private)\s+(address|phone|ssn)\s+of\s+\w+/i, /\b(bypass|circumvent|hack)\s+(security|firewall|authentication)\b/i, /\b(how to|tutorial)\s+(stalk|dox|harass)\b/i, ]; const MAX_QUERY_LENGTH = 2000; class PolicyError extends Error { constructor(public code: string, message: string) { super(message); this.name = "PolicyError"; } } function moderateQuery(query: string): string { if (query.length > MAX_Q...

Details

Author
jeremylongshore
Repository
jeremylongshore/claude-code-plugins-plus-skills
Created
1 years ago
Last Updated
today
Language
Python
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category