86 lines
1.8 KiB
Python
86 lines
1.8 KiB
Python
"""API 数据传输模型(Pydantic)。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import uuid
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class EntityOut(BaseModel):
|
|
id: uuid.UUID
|
|
entity_type: str
|
|
business_key: str
|
|
display_name: str | None = None
|
|
attributes: dict = Field(default_factory=dict)
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class RelatedEntityOut(BaseModel):
|
|
"""穿透命中的关联实体,附最短跳数(证据强度的初步指示)。"""
|
|
|
|
entity: EntityOut
|
|
depth: int
|
|
|
|
|
|
class PenetrateRequest(BaseModel):
|
|
start_entity_id: uuid.UUID
|
|
max_depth: int = Field(default=3, ge=1, le=6)
|
|
|
|
|
|
class PenetrateResponse(BaseModel):
|
|
start_entity_id: uuid.UUID
|
|
max_depth: int
|
|
related_count: int
|
|
related: list[RelatedEntityOut]
|
|
|
|
|
|
class ClueOut(BaseModel):
|
|
id: uuid.UUID
|
|
title: str
|
|
risk_domain: str
|
|
scenario_code: str
|
|
confidence: str
|
|
score: float
|
|
status: str
|
|
rationale: str
|
|
evidence: dict = Field(default_factory=dict)
|
|
subjects: dict = Field(default_factory=dict)
|
|
amount_involved: float | None = None
|
|
assignee: str | None = None
|
|
feedback: str | None = None
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class AssignRequest(BaseModel):
|
|
assignee: str = Field(min_length=1)
|
|
actor: str = Field(min_length=1)
|
|
|
|
|
|
class AdjudicateRequest(BaseModel):
|
|
confirmed: bool
|
|
actor: str = Field(min_length=1)
|
|
note: str | None = None
|
|
|
|
|
|
class NLQRequest(BaseModel):
|
|
question: str = Field(min_length=1)
|
|
|
|
|
|
class NLQResponse(BaseModel):
|
|
question: str
|
|
answer: str
|
|
provider: str
|
|
model: str
|
|
egress: bool
|
|
|
|
|
|
class DashboardSummary(BaseModel):
|
|
total: int
|
|
by_status: dict[str, int]
|
|
by_confidence: dict[str, int]
|
|
by_scenario: dict[str, int]
|
|
total_amount_involved: float
|