chore: import upstream snapshot with attribution
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export { guardrailsValidateTool } from './validate'
|
||||
@@ -0,0 +1,210 @@
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export interface GuardrailsValidateInput {
|
||||
input: string
|
||||
validationType: 'json' | 'regex' | 'hallucination' | 'pii'
|
||||
regex?: string
|
||||
knowledgeBaseId?: string
|
||||
threshold?: string
|
||||
topK?: string
|
||||
model?: string
|
||||
apiKey?: string
|
||||
azureEndpoint?: string
|
||||
azureApiVersion?: string
|
||||
vertexProject?: string
|
||||
vertexLocation?: string
|
||||
vertexCredential?: string
|
||||
bedrockAccessKeyId?: string
|
||||
bedrockSecretKey?: string
|
||||
bedrockRegion?: string
|
||||
piiEntityTypes?: string[]
|
||||
piiMode?: string
|
||||
piiLanguage?: string
|
||||
_context?: {
|
||||
workflowId?: string
|
||||
workspaceId?: string
|
||||
}
|
||||
}
|
||||
|
||||
export interface GuardrailsValidateOutput {
|
||||
success: boolean
|
||||
output: {
|
||||
passed: boolean
|
||||
validationType: string
|
||||
input?: string
|
||||
error?: string
|
||||
score?: number
|
||||
reasoning?: string
|
||||
detectedEntities?: any[]
|
||||
maskedText?: string
|
||||
}
|
||||
error?: string
|
||||
}
|
||||
|
||||
export const guardrailsValidateTool: ToolConfig<GuardrailsValidateInput, GuardrailsValidateOutput> =
|
||||
{
|
||||
id: 'guardrails_validate',
|
||||
name: 'Guardrails Validate',
|
||||
description:
|
||||
'Validate content using guardrails (JSON, regex, hallucination check, or PII detection)',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
input: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Content to validate (from wired block)',
|
||||
},
|
||||
validationType: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Type of validation: json, regex, hallucination, or pii',
|
||||
},
|
||||
regex: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Regex pattern (required for regex validation)',
|
||||
},
|
||||
knowledgeBaseId: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Knowledge base ID (required for hallucination check)',
|
||||
},
|
||||
threshold: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Confidence threshold (0-10 scale, default: 3, scores below fail)',
|
||||
},
|
||||
topK: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of chunks to retrieve from knowledge base (default: 10)',
|
||||
},
|
||||
model: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'LLM model for confidence scoring (default: gpt-4o-mini)',
|
||||
},
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'API key for LLM provider (optional if using hosted)',
|
||||
},
|
||||
piiEntityTypes: {
|
||||
type: 'array',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'PII entity types to detect (empty = detect all)',
|
||||
},
|
||||
piiMode: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'PII action mode: block or mask (default: block)',
|
||||
},
|
||||
piiLanguage: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Language for PII detection (default: en)',
|
||||
},
|
||||
},
|
||||
|
||||
outputs: {
|
||||
passed: {
|
||||
type: 'boolean',
|
||||
description: 'Whether validation passed',
|
||||
},
|
||||
validationType: {
|
||||
type: 'string',
|
||||
description: 'Type of validation performed',
|
||||
},
|
||||
input: {
|
||||
type: 'string',
|
||||
description: 'Original input',
|
||||
},
|
||||
error: {
|
||||
type: 'string',
|
||||
description: 'Error message if validation failed',
|
||||
optional: true,
|
||||
},
|
||||
score: {
|
||||
type: 'number',
|
||||
description:
|
||||
'Confidence score (0-10, 0=hallucination, 10=grounded, only for hallucination check)',
|
||||
optional: true,
|
||||
},
|
||||
reasoning: {
|
||||
type: 'string',
|
||||
description: 'Reasoning for confidence score (only for hallucination check)',
|
||||
optional: true,
|
||||
},
|
||||
detectedEntities: {
|
||||
type: 'array',
|
||||
description: 'Detected PII entities (only for PII detection)',
|
||||
optional: true,
|
||||
},
|
||||
maskedText: {
|
||||
type: 'string',
|
||||
description: 'Text with PII masked (only for PII detection in mask mode)',
|
||||
optional: true,
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: '/api/guardrails/validate',
|
||||
method: 'POST',
|
||||
headers: () => ({
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params: GuardrailsValidateInput) => ({
|
||||
input: params.input,
|
||||
validationType: params.validationType,
|
||||
regex: params.regex,
|
||||
knowledgeBaseId: params.knowledgeBaseId,
|
||||
threshold: params.threshold,
|
||||
topK: params.topK,
|
||||
model: params.model,
|
||||
apiKey: params.apiKey,
|
||||
azureEndpoint: params.azureEndpoint,
|
||||
azureApiVersion: params.azureApiVersion,
|
||||
vertexProject: params.vertexProject,
|
||||
vertexLocation: params.vertexLocation,
|
||||
vertexCredential: params.vertexCredential,
|
||||
bedrockAccessKeyId: params.bedrockAccessKeyId,
|
||||
bedrockSecretKey: params.bedrockSecretKey,
|
||||
bedrockRegion: params.bedrockRegion,
|
||||
piiEntityTypes: params.piiEntityTypes,
|
||||
piiMode: params.piiMode,
|
||||
piiLanguage: params.piiLanguage,
|
||||
workflowId: params._context?.workflowId,
|
||||
workspaceId: params._context?.workspaceId,
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response): Promise<GuardrailsValidateOutput> => {
|
||||
const result = await response.json()
|
||||
|
||||
if (!response.ok && !result.output) {
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
passed: false,
|
||||
validationType: 'unknown',
|
||||
input: '',
|
||||
error: result.error || `Validation failed with status ${response.status}`,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user