VirtForemanBackend / app /models /tech_stack.py
Dirbol's picture
chore: pre-release — full project lifecycle (CRUD, history, docs, tests)
1d5d841
Raw
History Blame Contribute Delete
2.65 kB
"""Schemas for daily work input and tech-stack inference."""
from datetime import date
from typing import List, Literal, Optional
from pydantic import BaseModel, Field
class DailyWorkInput(BaseModel):
"""User free-form input describing work performed."""
raw_text: str = Field(
...,
min_length=3,
max_length=4000,
description="Casual statement by the user (RU/EN), e.g. 'Залита плита перекрытия А-В/1-3'",
)
date_from: date
date_to: date
axes: Optional[str] = Field(
default=None,
max_length=200,
description="Grid axes mentioned, e.g. 'А-В / 1-3'",
)
project_id: Optional[str] = Field(
default=None,
max_length=64,
description="Optional project_uuid — wires inference_history rows",
)
class TechStep(BaseModel):
"""One inferred engineering step in the synthesized tech-stack."""
order: int = Field(..., ge=1)
title: str = Field(..., description="Short RU title")
description: str = Field(..., description="Detailed description")
duration_hours: Optional[float] = None
required_acts: List[str] = Field(
default_factory=list,
description="Names of Belarusian acts (TKP SNiP) required after this step",
)
dependencies: List[int] = Field(
default_factory=list,
description="Step orders that must be completed before this one",
)
weather_sensitive: bool = False
class TechStackPayload(BaseModel):
"""Strict schema the LLM must fill — no service-side metadata fields."""
inferred_summary: str = Field(..., description="Chief-engineer summary in Russian")
steps: List[TechStep]
required_documents: List[str] = Field(
default_factory=list,
description="List of Belarusian document/act types triggered",
)
missing_info_prompts: List[str] = Field(
default_factory=list,
description="Checklist prompts where critical data is missing",
)
class TechStack(TechStackPayload):
"""Full inferred tech-stack with envelope metadata added by the service."""
source_input: str
model_used: str
generated_at: str
class InferredWorkResponse(BaseModel):
"""Top-level response returned to the frontend."""
tech_stack: TechStack
request_id: str
class DocumentRequest(BaseModel):
template_name: Literal[
"act_hidden_works",
"act_osmotr_responsibility",
"general_work_log",
"material_certificate",
]
project_id: str
context: dict = Field(default_factory=dict)
output_format: Literal["docx"] = "docx"