Coerce an LLM-supplied score to the 0..3 range.
(value)
| 405 | |
| 406 | |
| 407 | def clamp_dim(value) -> int: |
| 408 | """Coerce an LLM-supplied score to the 0..3 range.""" |
| 409 | try: |
| 410 | n = int(value) |
| 411 | except (TypeError, ValueError): |
| 412 | return 0 |
| 413 | return max(0, min(3, n)) |
| 414 | |
| 415 | |
| 416 | def sanitize_reason(text) -> str: |