guardrails

command
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

This example demonstrates output validation guardrails:

  • Basic guardrails: LengthGuardrail, ContainsGuardrail, BannedWordsGuardrail
  • Advanced guardrails: LLMGuardrail (LLM-as-a-judge), HallucinationGuardrail (fact-check), ContextGuardrail interface
  • Chain (multi-guardrail orchestration with collect-all / stop-on-first / max-errors)
  • Structured error handling: ValidationError / ValidationFailure with errors.As

Prerequisites:

  • An LLM API key (OpenAI, Ollama, or any supported provider)

Usage (OpenAI):

OPENAI_API_KEY=sk-... go run main.go

Usage (Ollama):

OLLAMA_BASE_URL=http://localhost:11434 OLLAMA_MODEL=gemma3:4b go run main.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL