mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-19 00:01:29 +00:00
fix(llm_as_a_judge): remove dead registry dicts, fix KeyError in prompt builder, set correct status on judge failure
This commit is contained in:
parent
7eaf1406b8
commit
5896ec8c02
1 changed files with 3 additions and 10 deletions
|
|
@ -12,7 +12,7 @@ from litellm.integrations.custom_guardrail import (
|
|||
CustomGuardrail,
|
||||
log_guardrail_information,
|
||||
)
|
||||
from litellm.types.guardrails import GuardrailEventHooks, SupportedGuardrailIntegrations
|
||||
from litellm.types.guardrails import GuardrailEventHooks
|
||||
from litellm.types.utils import GenericGuardrailAPIInputs, GuardrailStatus
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
|
@ -71,7 +71,7 @@ def _build_judge_prompt(
|
|||
response_text: str,
|
||||
) -> str:
|
||||
criteria_block = "\n".join(
|
||||
f'- {c["name"]} (weight {c["weight"]}%): {c.get("description", "")}'
|
||||
f'- {c.get("name", "")} (weight {c.get("weight", 0)}%): {c.get("description", "")}'
|
||||
for c in criteria
|
||||
)
|
||||
conversation = "\n".join(
|
||||
|
|
@ -181,6 +181,7 @@ class LLMAsAJudgeGuardrail(CustomGuardrail):
|
|||
verbose_logger.warning(
|
||||
f"llm_as_a_judge guardrail: judge call failed, failing open. Error: {judge_err}"
|
||||
)
|
||||
status = "guardrail_failed_to_respond"
|
||||
return inputs
|
||||
|
||||
try:
|
||||
|
|
@ -297,14 +298,6 @@ def initialize_guardrail(
|
|||
return instance
|
||||
|
||||
|
||||
guardrail_initializer_registry = {
|
||||
SupportedGuardrailIntegrations.LLM_AS_A_JUDGE.value: initialize_guardrail,
|
||||
}
|
||||
|
||||
guardrail_class_registry = {
|
||||
SupportedGuardrailIntegrations.LLM_AS_A_JUDGE.value: LLMAsAJudgeGuardrail,
|
||||
}
|
||||
|
||||
__all__ = [
|
||||
"LLMAsAJudgeGuardrail",
|
||||
"initialize_guardrail",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue