37 lines
790 B
Python
37 lines
790 B
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]
|