-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
49 lines (40 loc) · 1.66 KB
/
Copy pathmodels.py
File metadata and controls
49 lines (40 loc) · 1.66 KB
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
"""
models.py
---------
Pydantic schemas for the /explain endpoint.
These are provider-agnostic and shared across the entire application.
"""
from __future__ import annotations
from typing import Optional
from pydantic import BaseModel, Field
class ViolationRequest(BaseModel):
"""
Violation payload sent from the xDECAF frontend.
Fields
------
constraint : The DSL constraint expression that was violated.
violated_vertex : Name of the vertex at which the violation is observed.
inducing_vertex : Name of the vertex whose property causes the violation.
tfg : Names of all vertices in the affected Transpose Flow Graph.
"""
constraint: str = Field(..., description="DSL constraint expression")
violated_vertex: list[str] = Field(...,
description="Vertex where the violation occurs")
inducing_vertex: list[str] = Field(
..., description="Vertex whose property induces the violation"
)
tfg: list[str] = Field(..., description="Vertex names in the affected TFG")
class ExplanationResponse(BaseModel):
"""Structured explanation returned to the frontend."""
constraint_explanation: str = Field(
description="Plain-English explanation of what the DSL constraint means."
)
violation_explanation: str = Field(
description="What the violation means concretely in this graph."
)
provider: str = Field(
description="LLM provider that generated this explanation.")
raw_model_output: Optional[str] = Field(
default=None,
description="Raw LLM output for debugging (only set when DEBUG_RAW_OUTPUT=true).",
)