| from __future__ import annotations | |
| from dataclasses import asdict, dataclass, field | |
| from typing import Any, Dict | |
| def _clamp(value: float, minimum: float, maximum: float) -> float: | |
| return max(minimum, min(maximum, value)) | |
| class Evidence: | |
| source: str | |
| category: str | |
| risk_score: int | |
| weight: float | |
| confidence: float | |
| explanation: str | |
| metadata: Dict[str, Any] = field(default_factory=dict) | |
| def __post_init__(self) -> None: | |
| self.risk_score = int(_clamp(float(self.risk_score), 0, 100)) | |
| self.weight = _clamp(float(self.weight), 0.0, 1.0) | |
| self.confidence = _clamp(float(self.confidence), 0.0, 1.0) | |
| def to_dict(self) -> Dict[str, Any]: | |
| return asdict(self) | |
| def evidence_from_reason( | |
| *, | |
| source: str, | |
| category: str, | |
| explanation: str, | |
| risk_score: int, | |
| weight: float = 0.5, | |
| confidence: float = 0.65, | |
| metadata: Dict[str, Any] | None = None, | |
| ) -> Evidence: | |
| return Evidence( | |
| source=source, | |
| category=category, | |
| risk_score=risk_score, | |
| weight=weight, | |
| confidence=confidence, | |
| explanation=explanation, | |
| metadata=metadata or {}, | |
| ) | |
Xet Storage Details
- Size:
- 1.19 kB
- Xet hash:
- b2808f4e2011b4f43cff602f212c311de69f905a54f8593f0813d7e282fdba55
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.