Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

@waleedlatif1 waleedlatif1 commented Oct 12, 2025

waleedlatif1 and others added 6 commits October 11, 2025 20:37
* updated privacy policy for google

* update terms, privacy, and emails to incl address and update verbiage
* Adding guardrails block

* ack PR comments

* cleanup checkbox in dark mode

* cleanup

* fix supabase tools
… 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

* remove the ability for a block to reference its own outluts

* fixed order of responses for guardrails block
@vercel
Copy link

vercel bot commented Oct 12, 2025

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

Project Deployment Preview Comments Updated (UTC)
docs Ready Ready Preview Comment Oct 12, 2025 5:17am

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

This release bundles 6 separate PRs into v0.4.12, introducing guardrails for content validation, Mistral AI provider support, performance improvements, and UX enhancements.

Major Changes:

  • Guardrails Feature (#1605): Added comprehensive content validation system with JSON validation, regex pattern matching, RAG-based hallucination detection using knowledge bases, and PII detection/masking using Microsoft Presidio
  • Mistral AI Provider (#1607): Integrated Mistral AI as a new LLM provider with streaming support, tool calling, and updated pricing for all models across providers
  • Inference Billing Fix (#1606): Resolved critical billing bug where streaming API executions weren't properly tracked; now defers logging completion until after token counting
  • Drag-and-Drop Files (#1606): Enhanced deployed chat interface with drag-and-drop file upload capability
  • Performance Optimization (#1603): Removed unused database indexes on workflow_edges (source/target blocks) and added index on state_snapshot_id for faster execution log queries
  • Blog Path Redirect (#1604): Added permanent redirect from /building/* to /blog/* for backward compatibility
  • Privacy Policy Update (#1602): Updated privacy policy for additional Google OAuth scopes

Key Implementation Details:

  • Guardrails block uses Python subprocess for PII detection via Presidio, with proper error handling and JSON parsing
  • Hallucination detection queries knowledge bases via internal API and uses LLM to score confidence (0-10 scale)
  • Mistral provider uses OpenAI SDK with custom base URL for API compatibility
  • Streaming billing fix adds skipLoggingComplete flag and _streamingMetadata to defer cost calculation

Confidence Score: 5/5

  • This PR is safe to merge with high confidence
  • All changes are well-implemented with no critical issues found. The PR bundles multiple tested PRs (#1603-1607) that were already reviewed individually. Code follows established patterns, includes proper error handling, and the billing fix addresses a real production issue. Database migrations are minimal and safe (index changes only).
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
packages/db/migrations/0098_thick_prima.sql 5/5 Removed unused source/target block indexes and added index on state_snapshot_id for performance optimization
apps/sim/blocks/blocks/guardrails.ts 5/5 Added comprehensive guardrails block with JSON, regex, hallucination, and PII validation types
apps/sim/lib/guardrails/validate_pii.py 5/5 Implemented PII detection using Presidio library with block/mask modes and multi-language support
apps/sim/lib/guardrails/validate_hallucination.ts 5/5 Implemented RAG-based hallucination detection with knowledge base retrieval and LLM confidence scoring
apps/sim/providers/mistral/index.ts 5/5 Added Mistral AI provider with OpenAI-compatible API client, streaming support, and tool calling
apps/sim/lib/workflows/streaming.ts 5/5 Fixed streaming workflow billing by deferring logging completion until after token counting
apps/sim/app/api/workflows/[id]/execute/route.ts 5/5 Added skipLoggingComplete option to support deferred billing in streaming workflows

Sequence Diagram

sequenceDiagram
    participant Client
    participant API
    participant Executor
    participant Guardrails
    participant KB as Knowledge Base
    participant LLM
    participant Presidio as PII Detection
    participant Billing

    Client->>API: POST /api/workflows/[id]/execute
    API->>Executor: executeWorkflow(stream: true)
    
    alt Guardrails Block
        Executor->>Guardrails: Validate content
        
        alt Hallucination Check
            Guardrails->>KB: Query knowledge base (RAG)
            KB-->>Guardrails: Return chunks
            Guardrails->>LLM: Score confidence (0-10)
            LLM-->>Guardrails: Score + reasoning
        else PII Detection
            Guardrails->>Presidio: Analyze text
            Presidio-->>Guardrails: Detected entities
            alt Block Mode
                Guardrails-->>Executor: Validation failed
            else Mask Mode
                Guardrails-->>Executor: Masked text
            end
        end
    end
    
    Executor->>LLM: Execute workflow (stream)
    LLM-->>Executor: Stream response
    Executor-->>API: Stream chunks
    
    Note over Executor,Billing: Streaming Fix: Defer logging completion
    Executor->>Executor: Build trace spans with costs
    Executor->>Billing: Complete logging session
    
    API-->>Client: Return response
Loading

59 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

…1611)

* fix(vulns): fix SSRF vulnerabilities

* cleanup

* cleanup

* regen docs

* remove unused deps

* fix failing tests

* cleanup

* update deps

* regen bun lock
@waleedlatif1 waleedlatif1 merged commit 219a065 into main Oct 12, 2025
22 checks passed
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.

3 participants