{"id":28424981,"url":"https://github.com/truefoundry/guardrails-server","last_synced_at":"2025-08-10T04:11:31.127Z","repository":{"id":287149553,"uuid":"951763125","full_name":"truefoundry/guardrails-server","owner":"truefoundry","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-14T08:42:12.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"init","last_synced_at":"2025-06-27T05:39:38.172Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/truefoundry.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-20T07:51:22.000Z","updated_at":"2025-04-08T16:04:56.000Z","dependencies_parsed_at":"2025-04-10T08:34:26.859Z","dependency_job_id":null,"html_url":"https://github.com/truefoundry/guardrails-server","commit_stats":null,"previous_names":["truefoundry/guardrails-server"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/truefoundry/guardrails-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/truefoundry%2Fguardrails-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/truefoundry%2Fguardrails-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/truefoundry%2Fguardrails-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/truefoundry%2Fguardrails-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/truefoundry","download_url":"https://codeload.github.com/truefoundry/guardrails-server/tar.gz/refs/heads/init","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/truefoundry%2Fguardrails-server/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269674049,"owners_count":24457257,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-05T10:30:57.127Z","updated_at":"2025-08-10T04:11:31.117Z","avatar_url":"https://github.com/truefoundry.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Guardrails Server\n\nA robust service for implementing safety and quality controls on Large Language Model (LLM) outputs. This service provides multiple guardrails to ensure LLM responses are safe, appropriate, and meet specified quality standards.\n\n## Features\n\n- **Multiple Guardrail Types:**\n  - Content Safety Filters (`safety`)\n    - Violence detection (low/medium/high)\n    - Hate speech detection (low/medium/high)\n    - Insults detection (low/medium/high)\n    - Misconduct detection (low/medium/high)\n    - Sexual content detection (low/medium/high)\n  - Topic Control (`topics`)\n    - Denied topics list\n  - Word Filtering (`words`)\n    - Built-in profanity detection\n    - Custom word list filtering\n  - PII Detection and Protection (`pii`)\n    - Standard PII types (email, phone, SSN, credit card, address, name, date of birth, IP address, passport, drivers license)\n    - Custom regex patterns for additional entity detection\n\n## API Endpoints\n\n### 1. List Available Guardrails\n```http\nGET /api/v1/guardrails\n```\n\nReturns a list of all available guardrails and their capabilities.\n\n**Response:**\n```json\n{\n  \"guardrails\": [\n    {\n      \"id\": \"pii\",\n      \"name\": \"PII Detection\",\n      \"description\": \"Detects and handles personally identifiable information\",\n      \"supports_validation\": true,\n      \"supports_transformation\": true,\n      \"options\": {\n        \"entity_types\": [\n          \"email\",\n          \"phone\",\n          \"ssn\",\n          \"credit_card\",\n          \"address\",\n          \"name\",\n          \"date_of_birth\",\n          \"ip_address\",\n          \"passport\",\n          \"drivers_license\"\n        ],\n        \"custom_regexes\": [\n          {\n            \"pattern\": \"regex_pattern\",\n            \"label\": \"custom_entity_label\"\n          }\n        ]\n      }\n    },\n    {\n      \"id\": \"profanity\",\n      \"name\": \"Profanity Filter\",\n      \"description\": \"Detects and filters offensive language\",\n      \"supports_validation\": true,\n      \"supports_transformation\": true,\n      \"options\": {\n        \"severity_levels\": [\"mild\", \"moderate\", \"severe\"]\n      }\n    }\n  ]\n}\n```\n\n### 2. Validate Response\n```http\nPOST /api/v1/validate\n```\n\nValidates an LLM response against specified guardrails and returns whether it passes or fails.\n\n**Request Body:**\n```json\n{\n  \"content\": \"LLM response text\",\n  \"guardrails\": [\"pii\", \"profanity\", \"relevancy\"],\n  \"options\": {\n    \"pii\": {\n      \"entity_types\": [\"email\", \"phone\", \"ssn\"],\n      \"custom_regexes\": [\n        {\n          \"pattern\": \"\\\\b[A-Z0-9._%+-]+@example\\\\.com\\\\b\",\n          \"label\": \"company_email\"\n        }\n      ]\n    },\n    \"profanity\": {},\n    \"relevancy\": {}\n  }\n}\n```\n\n**Response:**\n```json\n{\n  \"is_valid\": boolean,\n  \"failed_guardrails\": [\"string\"],\n  \"details\": {\n    \"guardrail_id\": {\n      \"passed\": boolean,\n      \"violations\": [\"string\"]\n    }\n  }\n}\n```\n\n### 3. Transform Response\n```http\nPOST /api/v1/transform\n```\n\nApplies specified transformations to make the content compliant with guardrails.\n\n**Request Body:**\n```json\n{\n  \"content\": \"LLM response text\",\n  \"guardrails\": [\"pii\", \"profanity\"],\n  \"options\": {\n    \"pii\": {\n      \"entity_types\": [\"email\", \"phone\", \"ssn\"],\n      \"custom_regexes\": [\n        {\n          \"pattern\": \"\\\\b[A-Z0-9._%+-]+@example\\\\.com\\\\b\",\n          \"label\": \"company_email\"\n        }\n      ]\n    },\n    \"profanity\": {}\n  }\n}\n```\n\n**Response:**\n```json\n{\n  \"transformed_content\": \"string\",\n  \"applied_transformations\": [\"string\"],\n  \"details\": {\n    \"guardrail_id\": {\n      \"details\": {}\n    }\n  }\n}\n```\n\n### 4. Health Check\n```http\nGET /health\n```\n\nVerifies the service is running and all guardrails are properly initialized.\n\n**Response:**\n```json\n{\n  \"status\": \"healthy\",\n  \"guardrails\": {\n    \"pii\": true,\n    \"profanity\": true\n  }\n}\n```\n\n## Project Structure\n\nThe project is organized into the following structure:\n\n```\nguardrails-service/\n├── config/              # Configuration files\n│   └── .env             # Environment variables\n├── src/                 # Source code\n│   ├── api/             # API endpoints and application server\n│   │   └── app.py       # FastAPI application\n│   ├── guardrails/      # Guardrail implementations\n│   │   ├── base.py      # Base guardrail classes and interfaces\n│   │   ├── pii.py       # PII detection guardrail\n│   │   ├── pii_types.py # PII entity types\n│   │   └── topic.py     # Topic control guardrail\n│   └── models/          # ML model services\n│       └── service.py   # Model service implementations\n├── .env                 # Environment variables (root copy for compatibility)\n├── Dockerfile           # Container definition\n├── requirements.txt     # Python dependencies\n└── run.py               # Entry point script\n```\n\n## Getting Started\n\n1. Set up your environment variables\n2. Install dependencies\n3. Run the service:\n   ```bash\n   python run.py\n   ```\n\n## Development\n\n```bash\n# Run in development mode\nuvicorn app:app --reload\n\n# Run tests\npytest\n\n# Run linting\nflake8\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftruefoundry%2Fguardrails-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftruefoundry%2Fguardrails-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftruefoundry%2Fguardrails-server/lists"}