File size: 2,647 Bytes
51122e7
 
 
 
 
 
 
 
 
 
 
 
 
 
1d5d841
51122e7
 
 
 
 
 
1d5d841
51122e7
 
1d5d841
 
 
 
 
51122e7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
db9eb12
 
51122e7
 
 
 
 
 
 
 
 
 
 
db9eb12
 
 
 
 
 
51122e7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
"""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"