Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

added guardrails block/tools and docs

Type of Change

  • New feature

Testing

Tested manually.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Oct 11, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Oct 12, 2025 2:39am

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/validate with 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-list sub-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 missing reject parameter, 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.ts where the Promise constructor is missing the reject parameter (line 82), but reject is 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)
Loading

25 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@blacksmith-sh blacksmith-sh bot deleted a comment from waleedlatif1 Oct 12, 2025
@waleedlatif1 waleedlatif1 force-pushed the feat/djj/guardrails_block branch from 8f82a12 to 62c07bc Compare October 12, 2025 02:39
@waleedlatif1 waleedlatif1 merged commit 750c36e into staging Oct 12, 2025
9 checks passed
@waleedlatif1 waleedlatif1 deleted the feat/djj/guardrails_block branch October 12, 2025 02:55
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
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants