Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

class TopicRelevanceLLMSafetyValidatorConfig(BaseValidatorConfig):
type: Literal["topic_relevance_llm"]
on_fail: GuardrailOnFail = GuardrailOnFail.Rephrase
configuration: Optional[str] = None
llm_callable: str = settings.DEFAULT_LLM_CALLABLE
threshold: int = Field(default=settings.TOPIC_RELEVANCE_LLM_THRESHOLD, ge=1, le=3)
Expand Down
2 changes: 2 additions & 0 deletions backend/app/tests/validators/test_topic_relevance_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from guardrails.validators import FailResult, PassResult

from app.core.constants import REPHRASE_ON_FAIL_PREFIX
from app.core.enum import GuardrailOnFail
from app.core.validators.config.topic_relevance_llm_safety_validator_config import (
TopicRelevanceLLMSafetyValidatorConfig,
)
Expand Down Expand Up @@ -403,6 +404,7 @@ def test_invalid_prompt_schema_version_returns_fail():
def test_config_defaults_to_forbidden_topics_schema():
config = TopicRelevanceLLMSafetyValidatorConfig(type="topic_relevance_llm")
assert config.prompt_schema_version == 2
assert config.on_fail == GuardrailOnFail.Rephrase


def test_config_rephrase_without_fallback_uses_generic_text():
Expand Down
Loading