feat(guardrails): add LLMJudgeValidator#1714
Conversation
Adds an LLM-as-judge built-in guardrail validator that evaluates data against free-form natural-language criteria via the UiPath Guardrails API. Takes `criteria`, `model` (default gpt-4o-mini), and `threshold` (default 0.5). Supported at all stages. Also adds a generic `StringParameterValue` to the validator parameter union so future validators can pass string-typed parameters.
There was a problem hiding this comment.
Pull request overview
This PR introduces a new built-in guardrail validator, LLMJudgeValidator, which delegates validation to the UiPath Guardrails API using an LLM-as-judge mechanism (validator_type="llm_judge"). It also extends the guardrail parameter modeling to support string-typed validator parameters so the new validator can pass criteria/model settings to the API.
Changes:
- Added
LLMJudgeValidatorbuilt-in validator (criteria/model/threshold) and exported it via the decorators API. - Extended the validator-parameter discriminated union with a
StringParameterValuemodel to support string parameters. - Added unit tests covering
LLMJudgeValidatorvalidation behavior and guardrail construction.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/uipath-platform/tests/services/test_guardrails_decorators.py | Adds test coverage for LLMJudgeValidator validation and guardrail parameter construction. |
| packages/uipath-platform/src/uipath/platform/guardrails/guardrails.py | Adds StringParameterValue and includes it in ValidatorParameter union for built-in validator parameters. |
| packages/uipath-platform/src/uipath/platform/guardrails/decorators/validators/llm_judge.py | Implements the new LLMJudgeValidator and its guardrail payload construction. |
| packages/uipath-platform/src/uipath/platform/guardrails/decorators/validators/init.py | Re-exports LLMJudgeValidator from the validators package. |
| packages/uipath-platform/src/uipath/platform/guardrails/decorators/init.py | Re-exports LLMJudgeValidator from the public decorators module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if not criteria or not criteria.strip(): | ||
| raise ValueError("criteria must be a non-empty string") | ||
| if not 0.0 <= threshold <= 1.0: | ||
| raise ValueError(f"threshold must be between 0.0 and 1.0, got {threshold}") | ||
| self.criteria = criteria | ||
| self.model = model | ||
| self.threshold = threshold |
🚨 Heads up:
|
|



Summary
LLMJudgeValidatorbuilt-in guardrail validator that evaluates data against free-form natural-language criteria via the UiPath Guardrails API (validator_type="llm_judge").criteria(str),model(str, defaultgpt-4o-mini), andthreshold(float in [0, 1], default0.5). Supported at all execution stages.StringParameterValueto the validator parameter discriminated union so string-typed parameters can be passed to built-in validators.LLMJudgeValidatorfromuipath.platform.guardrails.decoratorsalongside the other validators.Usage
Test plan
pytest tests/services/test_guardrails_decorators.py— all 85 tests pass, including 8 newTestLLMJudgeValidatorcasespytest tests/services/test_guardrails_*.py tests/services/test_azure_guardrail_validators.py— 99 tests passruff check .— all checks passruff format --check .— 195/195 formattedmypy src tests— no issues found