mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-20 00:11:50 +00:00
fix(llm_as_a_judge): use float sum with tolerance for weight validation
This commit is contained in:
parent
3064834f7e
commit
55ae8b1a16
1 changed files with 2 additions and 2 deletions
|
|
@ -258,8 +258,8 @@ def initialize_guardrail(
|
|||
if not criteria:
|
||||
raise ValueError("llm_as_a_judge guardrail requires at least one criterion")
|
||||
|
||||
weight_total = sum(int(c.get("weight", 0)) for c in criteria)
|
||||
if weight_total != 100:
|
||||
weight_total = sum(float(c.get("weight", 0)) for c in criteria)
|
||||
if abs(weight_total - 100) > 0.5:
|
||||
raise ValueError(
|
||||
f"llm_as_a_judge criterion weights must sum to 100 (got {weight_total})"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue