assertions

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArenaAssertionMiddleware

func ArenaAssertionMiddleware(registry *runtimeValidators.Registry, assertions []AssertionConfig) pipeline.Middleware

ArenaAssertionMiddleware creates middleware that validates assertions after LLM responses

func NewArenaAssertionRegistry

func NewArenaAssertionRegistry() *runtimeValidators.Registry

NewArenaAssertionRegistry creates a new registry with arena-specific assertion validators

func NewAudioDurationValidator added in v1.1.0

func NewAudioDurationValidator(params map[string]interface{}) runtimeValidators.Validator

NewAudioDurationValidator creates a new audio_duration validator from params

func NewAudioFormatValidator added in v1.1.0

func NewAudioFormatValidator(params map[string]interface{}) runtimeValidators.Validator

NewAudioFormatValidator creates a new audio_format validator from params

func NewContentIncludesValidator

func NewContentIncludesValidator(params map[string]interface{}) runtimeValidators.Validator

NewContentIncludesValidator creates a new content_includes validator from params

func NewContentMatchesValidator

func NewContentMatchesValidator(params map[string]interface{}) runtimeValidators.Validator

NewContentMatchesValidator creates a new content_matches validator from params

func NewGuardrailTriggeredValidator added in v1.1.0

func NewGuardrailTriggeredValidator(params map[string]interface{}) runtimeValidators.Validator

NewGuardrailTriggeredValidator creates a new GuardrailTriggeredValidator instance

func NewImageDimensionsValidator added in v1.1.0

func NewImageDimensionsValidator(params map[string]interface{}) runtimeValidators.Validator

NewImageDimensionsValidator creates a new image_dimensions validator from params

func NewImageFormatValidator added in v1.1.0

func NewImageFormatValidator(params map[string]interface{}) runtimeValidators.Validator

NewImageFormatValidator creates a new image_format validator from params

func NewIsValidJSONValidator added in v1.1.1

func NewIsValidJSONValidator(params map[string]interface{}) runtimeValidators.Validator

NewIsValidJSONValidator creates a new is_valid_json validator

func NewJSONPathValidator added in v1.1.1

func NewJSONPathValidator(params map[string]interface{}) runtimeValidators.Validator

NewJSONPathValidator creates a new json_path validator

func NewJSONSchemaValidator added in v1.1.1

func NewJSONSchemaValidator(params map[string]interface{}) runtimeValidators.Validator

NewJSONSchemaValidator creates a new json_schema validator

func NewToolsCalledValidator

func NewToolsCalledValidator(params map[string]interface{}) runtimeValidators.Validator

NewToolsCalledValidator creates a new tools_called validator from params

func NewToolsNotCalledValidator

func NewToolsNotCalledValidator(params map[string]interface{}) runtimeValidators.Validator

NewToolsNotCalledValidator creates a new tools_not_called validator from params

func NewVideoDurationValidator added in v1.1.0

func NewVideoDurationValidator(params map[string]interface{}) runtimeValidators.Validator

NewVideoDurationValidator creates a new video_duration validator from params

func NewVideoResolutionValidator added in v1.1.0

func NewVideoResolutionValidator(params map[string]interface{}) runtimeValidators.Validator

NewVideoResolutionValidator creates a new video_resolution validator from params

Types

type AssertionConfig added in v1.1.0

type AssertionConfig struct {
	Type    string                 `json:"type" yaml:"type"`
	Params  map[string]interface{} `json:"params" yaml:"params"`
	Message string                 `json:"message,omitempty" yaml:"message,omitempty"` // Human-readable description of what this assertion checks
}

AssertionConfig extends ValidatorConfig with arena-specific fields

func (AssertionConfig) ToValidatorConfig added in v1.1.0

func (a AssertionConfig) ToValidatorConfig() runtimeValidators.ValidatorConfig

ToValidatorConfig converts AssertionConfig to runtime ValidatorConfig

type AssertionResult added in v1.1.0

type AssertionResult struct {
	Passed  bool        `json:"passed"`
	Details interface{} `json:"details,omitempty"`
	Message string      `json:"message,omitempty"` // Human-readable description from config
}

AssertionResult extends ValidationResult with the assertion message

func FromValidationResult added in v1.1.0

func FromValidationResult(vr runtimeValidators.ValidationResult, message string) AssertionResult

FromValidationResult creates an AssertionResult from a ValidationResult

type AudioDurationValidator added in v1.1.0

type AudioDurationValidator struct {
	// contains filtered or unexported fields
}

AudioDurationValidator checks that audio duration is within range

func (*AudioDurationValidator) Validate added in v1.1.0

func (v *AudioDurationValidator) Validate(content string, params map[string]interface{}) runtimeValidators.ValidationResult

Validate checks if audio duration is within allowed range

type AudioFormatValidator added in v1.1.0

type AudioFormatValidator struct {
	// contains filtered or unexported fields
}

AudioFormatValidator checks that audio content has one of the allowed formats

func (*AudioFormatValidator) Validate added in v1.1.0

func (v *AudioFormatValidator) Validate(content string, params map[string]interface{}) runtimeValidators.ValidationResult

Validate checks if the message contains audio with allowed formats

type ContentIncludesValidator

type ContentIncludesValidator struct {
	// contains filtered or unexported fields
}

ContentIncludesValidator checks that content includes all expected patterns

func (*ContentIncludesValidator) Validate

func (v *ContentIncludesValidator) Validate(content string, params map[string]interface{}) runtimeValidators.ValidationResult

Validate checks if all patterns are present in content (case-insensitive)

type ContentMatchesValidator

type ContentMatchesValidator struct {
	// contains filtered or unexported fields
}

ContentMatchesValidator checks that content matches a regex pattern

func (*ContentMatchesValidator) Validate

func (v *ContentMatchesValidator) Validate(content string, params map[string]interface{}) runtimeValidators.ValidationResult

Validate checks if content matches the regex pattern

type GuardrailTriggeredValidator added in v1.1.0

type GuardrailTriggeredValidator struct{}

GuardrailTriggeredValidator is an assertion validator that checks if a specific guardrail validator triggered (or didn't trigger) as expected. This is useful for testing that guardrails work correctly in PromptArena scenarios.

func (*GuardrailTriggeredValidator) Validate added in v1.1.0

func (v *GuardrailTriggeredValidator) Validate(
	content string,
	params map[string]interface{},
) runtimeValidators.ValidationResult

Validate checks if the expected validator triggered as expected

type ImageDimensionsValidator added in v1.1.0

type ImageDimensionsValidator struct {
	// contains filtered or unexported fields
}

ImageDimensionsValidator checks that images meet dimension requirements

func (*ImageDimensionsValidator) Validate added in v1.1.0

func (v *ImageDimensionsValidator) Validate(content string, params map[string]interface{}) runtimeValidators.ValidationResult

Validate checks if images meet dimension requirements

type ImageFormatValidator added in v1.1.0

type ImageFormatValidator struct {
	// contains filtered or unexported fields
}

ImageFormatValidator checks that media content has one of the allowed image formats

func (*ImageFormatValidator) Validate added in v1.1.0

func (v *ImageFormatValidator) Validate(content string, params map[string]interface{}) runtimeValidators.ValidationResult

Validate checks if the message contains images with allowed formats

type IsValidJSONValidator added in v1.1.1

type IsValidJSONValidator struct {
	// contains filtered or unexported fields
}

IsValidJSONValidator validates that content is parseable JSON

func (*IsValidJSONValidator) Validate added in v1.1.1

func (v *IsValidJSONValidator) Validate(
	content string,
	params map[string]interface{},
) runtimeValidators.ValidationResult

Validate checks if content is valid JSON

type JSONPathValidator added in v1.1.1

type JSONPathValidator struct {
	// contains filtered or unexported fields
}

JSONPathValidator validates JSON using JMESPath expressions

func (*JSONPathValidator) Validate added in v1.1.1

func (v *JSONPathValidator) Validate(content string, params map[string]interface{}) runtimeValidators.ValidationResult

Validate executes JMESPath expression and validates result

type JSONSchemaValidator added in v1.1.1

type JSONSchemaValidator struct {
	// contains filtered or unexported fields
}

JSONSchemaValidator validates JSON against a JSON Schema

func (*JSONSchemaValidator) Validate added in v1.1.1

func (v *JSONSchemaValidator) Validate(
	content string,
	params map[string]interface{},
) runtimeValidators.ValidationResult

Validate checks if JSON content matches the schema

type LengthCapValidator

type LengthCapValidator struct{}

LengthCapValidator ensures user messages are at most 2 sentences

func NewLengthCapValidator

func NewLengthCapValidator() *LengthCapValidator

NewLengthCapValidator creates a new length cap validator

func (*LengthCapValidator) SupportsStreaming

func (v *LengthCapValidator) SupportsStreaming() bool

SupportsStreaming returns false as sentence counting requires complete content

func (*LengthCapValidator) Validate

func (v *LengthCapValidator) Validate(content string, params map[string]interface{}) ValidationResult

Validate checks for sentence count violations

type QuestionCapValidator

type QuestionCapValidator struct{}

QuestionCapValidator ensures user messages have at most one question

func NewQuestionCapValidator

func NewQuestionCapValidator() *QuestionCapValidator

NewQuestionCapValidator creates a new question cap validator

func (*QuestionCapValidator) SupportsStreaming

func (v *QuestionCapValidator) SupportsStreaming() bool

SupportsStreaming returns false as question counting requires complete content

func (*QuestionCapValidator) Validate

func (v *QuestionCapValidator) Validate(content string, params map[string]interface{}) ValidationResult

Validate checks for question count violations

type RoleIntegrityValidator

type RoleIntegrityValidator struct{}

RoleIntegrityValidator checks that user LLM doesn't provide assistant-like responses

func NewRoleIntegrityValidator

func NewRoleIntegrityValidator() *RoleIntegrityValidator

NewRoleIntegrityValidator creates a new role integrity validator

func (*RoleIntegrityValidator) SupportsStreaming

func (v *RoleIntegrityValidator) SupportsStreaming() bool

SupportsStreaming returns false as role integrity requires complete content

func (*RoleIntegrityValidator) Validate

func (v *RoleIntegrityValidator) Validate(content string, params map[string]interface{}) ValidationResult

Validate checks for role integrity violations

type ToolsCalledValidator

type ToolsCalledValidator struct {
	// contains filtered or unexported fields
}

ToolsCalledValidator checks that expected tools were called in the response

func (*ToolsCalledValidator) Validate

func (v *ToolsCalledValidator) Validate(content string, params map[string]interface{}) runtimeValidators.ValidationResult

Validate checks if expected tools were called

type ToolsNotCalledValidator

type ToolsNotCalledValidator struct {
	// contains filtered or unexported fields
}

ToolsNotCalledValidator checks that forbidden tools were NOT called in the response

func (*ToolsNotCalledValidator) Validate

func (v *ToolsNotCalledValidator) Validate(content string, params map[string]interface{}) runtimeValidators.ValidationResult

Validate checks if any forbidden tools were called

type ValidationResult

type ValidationResult = validators.ValidationResult

ValidationResult is an alias for runtime validators.ValidationResult

type VideoDurationValidator added in v1.1.0

type VideoDurationValidator struct {
	// contains filtered or unexported fields
}

VideoDurationValidator checks that video duration is within range

func (*VideoDurationValidator) Validate added in v1.1.0

func (v *VideoDurationValidator) Validate(content string, params map[string]interface{}) runtimeValidators.ValidationResult

Validate checks if video duration is within allowed range

type VideoResolutionValidator added in v1.1.0

type VideoResolutionValidator struct {
	// contains filtered or unexported fields
}

VideoResolutionValidator checks that video resolution meets requirements

func (*VideoResolutionValidator) Validate added in v1.1.0

func (v *VideoResolutionValidator) Validate(content string, params map[string]interface{}) runtimeValidators.ValidationResult

Validate checks if video resolution meets requirements

Jump to

Keyboard shortcuts

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