Handle percentage as int

This commit is contained in:
Nicolas Mowen 2026-03-10 07:00:53 -06:00
parent 5254bfd00e
commit 84402284fc
2 changed files with 4 additions and 1 deletions

View File

@ -15,7 +15,6 @@ class ReviewMetadata(BaseModel):
)
confidence: float = Field(
ge=0.0,
le=1.0,
description="Confidence in the analysis, from 0 to 1.",
)
potential_threat_level: int = Field(

View File

@ -181,6 +181,10 @@ Each line represents a detection state, not necessarily unique individuals. Pare
try:
metadata = ReviewMetadata.model_validate_json(clean_json)
# Normalize confidence if model returned a percentage (e.g. 85 instead of 0.85)
if metadata.confidence > 1.0:
metadata.confidence = min(metadata.confidence / 100.0, 1.0)
# If any verified objects (contain parentheses with name), set to 0
if any("(" in obj for obj in review_data["unified_objects"]):
metadata.potential_threat_level = 0