-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathschemas.py
More file actions
85 lines (64 loc) · 2.29 KB
/
Copy pathschemas.py
File metadata and controls
85 lines (64 loc) · 2.29 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
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
from __future__ import annotations
from datetime import datetime
from typing import Literal
from pydantic import BaseModel, Field, StrictStr, field_validator
def _parse_iso8601(value: str) -> str:
if not isinstance(value, str):
raise TypeError("must be a string")
candidate = value.replace("Z", "+00:00") if value.endswith("Z") else value
try:
datetime.fromisoformat(candidate)
except ValueError as exc:
raise ValueError("must be ISO-8601 timestamp") from exc
return value
class PlanRequest(BaseModel):
context: StrictStr
current_time: StrictStr
timezone: StrictStr
variant: Literal["v1_naive", "v2_structured", "v3_agentic_repair"]
@field_validator("current_time")
@classmethod
def validate_current_time(cls, value: str) -> str:
return _parse_iso8601(value)
class PlanItem(BaseModel):
task: StrictStr
start_time: StrictStr
end_time: StrictStr
timebox_minutes: int = Field(ge=0)
why: StrictStr
@field_validator("start_time")
@classmethod
def validate_start_time(cls, value: str) -> str:
return _parse_iso8601(value)
@field_validator("end_time")
@classmethod
def validate_end_time(cls, value: str) -> str:
return _parse_iso8601(value)
class ExtractedMetadata(BaseModel):
temporal_constraints: list[StrictStr]
ground_truth_entities: list[StrictStr]
actionable_tasks: list[StrictStr]
class ValidationMetrics(BaseModel):
constraint_violation_count: int = Field(ge=0)
overlap_minutes: int = Field(ge=0)
hallucination_count: int = Field(ge=0)
keyword_recall_score: float = Field(ge=0.0, le=1.0)
human_feasibility_flags: int = Field(ge=0)
class PlanValidation(BaseModel):
status: Literal["pass", "fail"]
metrics: ValidationMetrics
errors: list[StrictStr]
class DebugInfo(BaseModel):
repair_attempted: bool
repair_success: bool
variant: Literal["v1_naive", "v2_structured", "v3_agentic_repair"]
trace_id: StrictStr | None = None
class PlanResponse(BaseModel):
plan: list[PlanItem]
extracted_metadata: ExtractedMetadata
assumptions: list[StrictStr]
questions: list[StrictStr]
confidence: Literal["low", "medium", "high"]
validation: PlanValidation
debug: DebugInfo
technical_logs: list[StrictStr]