File size: 2,250 Bytes
3552405 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | """Pydantic models for risk findings and scored clauses."""
from enum import Enum
from pydantic import BaseModel, Field
from clauseguard.models.clause import Clause
class Severity(str, Enum):
"""Enumeration of risk severity levels."""
CRITICAL = "CRITICAL"
HIGH = "HIGH"
MEDIUM = "MEDIUM"
LOW = "LOW"
INFO = "INFO"
class RecommendedAction(BaseModel):
"""A specific, actionable recommendation for a clause."""
action: str = Field(..., description="What to do (e.g., negotiate, remove, clarify)")
sample_counter_language: str = Field(
default="", description="Suggested alternative language for negotiation"
)
priority: int = Field(
default=1,
ge=1,
le=3,
description="Action priority: 1=do immediately, 2=strongly recommend, 3=consider",
)
class RiskFinding(BaseModel):
"""A risk finding associated with a specific clause."""
clause_id: int = Field(..., description="The ID of the clause this finding relates to")
severity: Severity = Field(..., description="Severity level of the risk")
risk_title: str = Field(..., description="Short title describing the risk")
risk_reason: str = Field(
..., description="Detailed explanation citing what the clause actually says"
)
recommended_action: str = Field(
default="", description="Specific, actionable recommendation"
)
negotiation_tip: str = Field(
default="",
description="Suggested counter-language or negotiation approach for this clause",
)
safer_clause_version: str = Field(
default="",
description="A rewritten, safer version of the clause to propose",
)
negotiation_message: str = Field(
default="",
description="Email-style message the user can copy-paste to request the change",
)
impact_scenarios: list[str] = Field(
default_factory=list,
description="2-3 realistic consequences if the user signs this clause as-is",
)
class ScoredClause(BaseModel):
"""A clause paired with its risk finding."""
clause: Clause = Field(..., description="The original clause")
finding: RiskFinding = Field(..., description="The associated risk finding")
|