feat(guardrails): added guardrails block/tools and docs#1605
Merged
waleedlatif1 merged 5 commits intostagingfrom Oct 12, 2025
Merged
feat(guardrails): added guardrails block/tools and docs#1605waleedlatif1 merged 5 commits intostagingfrom
waleedlatif1 merged 5 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
10 tasks
Contributor
There was a problem hiding this comment.
Greptile Overview
Summary
Added comprehensive guardrails block with four validation types: JSON, Regex, Hallucination Check (RAG + LLM scoring), and PII Detection (Microsoft Presidio). Integrated with workflow blocks system, added new grouped checkbox UI component for PII type selection, updated Docker setup for Python dependencies, and included full documentation.
Key Changes:
- New guardrails block configuration with conditional UI based on validation type
- API route at
/api/guardrails/validatewith input validation and error handling - TypeScript validators for JSON, regex, and hallucination detection
- Python-based PII detection using Microsoft Presidio with TypeScript wrapper
- New
grouped-checkbox-listsub-block component for multi-select PII types - Docker configuration updated to install Python 3, pip, and run setup script
- Comprehensive documentation with examples and best practices
Critical Issue:
validate_pii.ts:82- Promise constructor missingrejectparameter, causing runtime errors on lines 100 and 178
Confidence Score: 2/5
- This PR has a critical bug that will cause runtime failures in PII validation
- Score reflects a critical logical error in
validate_pii.tswhere the Promise constructor is missing therejectparameter (line 82), butrejectis called on lines 100 and 178. This will cause immediate runtime errors when PII validation times out or encounters spawn errors. The rest of the implementation is well-structured with good error handling, comprehensive validation logic, and proper documentation. - Critical attention required for
apps/sim/lib/guardrails/validate_pii.ts- must fix Promise constructor before merge
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/lib/guardrails/validate_pii.ts | 1/5 | PII validation with Python integration - critical bug: Promise missing reject parameter (lines 100, 178) |
| apps/sim/lib/guardrails/validate_hallucination.ts | 4/5 | Hallucination detection using RAG + LLM scoring - well-structured with proper error handling |
| apps/sim/blocks/blocks/guardrails.ts | 5/5 | Block configuration for guardrails with comprehensive PII types and conditional UI logic |
| apps/sim/app/api/guardrails/validate/route.ts | 5/5 | API route with input validation, type checking, and proper error handling |
| apps/sim/lib/guardrails/validate_pii.py | 5/5 | Python PII detection using Presidio with proper error handling and JSON output |
| docker/app.Dockerfile | 5/5 | Added Python 3 and pip to runner stage, copies guardrails setup files and runs setup script |
Sequence Diagram
sequenceDiagram
participant User
participant Block as Guardrails Block
participant Tool as guardrails_validate Tool
participant API as /api/guardrails/validate
participant Validator as Validation Logic
participant KB as Knowledge Base API
participant LLM as LLM Provider
participant Python as Python Script (PII)
User->>Block: Configure validation type & parameters
User->>Block: Wire input from previous block
Block->>Tool: Execute with input & config
Tool->>API: POST /api/guardrails/validate
alt JSON Validation
API->>Validator: validateJson(input)
Validator->>API: {passed, error?}
else Regex Validation
API->>Validator: validateRegex(input, pattern)
Validator->>API: {passed, error?}
else Hallucination Check
API->>Validator: validateHallucination(input, config)
Validator->>KB: Query knowledge base (RAG)
KB->>Validator: Return relevant chunks
Validator->>LLM: Score confidence (0-10)
LLM->>Validator: {score, reasoning}
Validator->>API: {passed, score, reasoning}
else PII Detection
API->>Validator: validatePII(input, config)
Validator->>Python: Spawn validate_pii.py
Python->>Python: Presidio analyze & anonymize
Python->>Validator: {passed, detectedEntities, maskedText?}
Validator->>API: {passed, detectedEntities, maskedText?}
end
API->>Tool: {success, output}
Tool->>Block: Return validation result
Block->>User: Display result (passed/failed)
25 files reviewed, 1 comment
8f82a12 to
62c07bc
Compare
waleedlatif1
added a commit
that referenced
this pull request
Oct 12, 2025
* Adding guardrails block * ack PR comments * cleanup checkbox in dark mode * cleanup * fix supabase tools
This was referenced Oct 12, 2025
waleedlatif1
added a commit
that referenced
this pull request
Oct 12, 2025
* Adding guardrails block * ack PR comments * cleanup checkbox in dark mode * cleanup * fix supabase tools
waleedlatif1
added a commit
that referenced
this pull request
Oct 12, 2025
* improvement(performance): remove unused source/target indices, add index on snapshot id (#1603) * fix(blog): rename building to blogs with redirect (#1604) * improvement(privacy-policy): updated privacy policy for google (#1602) * updated privacy policy for google * update terms, privacy, and emails to incl address and update verbiage * feat(guardrails): added guardrails block/tools and docs (#1605) * Adding guardrails block * ack PR comments * cleanup checkbox in dark mode * cleanup * fix supabase tools * fix(inference-billing): fix inference billing when stream is true via API, add drag-and-drop functionality to deployed chat (#1606) * fix(inference): fix inference billing when stream is true via API * add drag-and-drop to deployed chat * feat(mistal): added mistral as a provider, updated model prices (#1607) * feat(mistal): added mistral as a provider, updated model prices * remove the ability for a block to reference its own outluts * fixed order of responses for guardrails block * feat(versions): added the ability to rename deployment versions (#1610) * fix(vulns): fix various vulnerabilities and enhanced code security (#1611) * fix(vulns): fix SSRF vulnerabilities * cleanup * cleanup * regen docs * remove unused deps * fix failing tests * cleanup * update deps * regen bun lock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
added guardrails block/tools and docs
Type of Change
Testing
Tested manually.
Checklist