Skip to content

Commit 38abfb6

Browse files
authored
Merge pull request #33 from kookmin-sw/feature/#32-ai-schemas
[#32][AI] Pydantic 스키마 정의
2 parents 38c50aa + d69c4a7 commit 38abfb6

5 files changed

Lines changed: 247 additions & 5 deletions

File tree

ai/schemas/__init__.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,40 @@
1-
# ai/schemas — Pydantic 입출력 스키마
1+
"""ai/schemas — Pydantic 입출력 스키마 (AI Dataset Spec v3 기반)."""
2+
3+
from ai.schemas.accept import AcceptInput, AcceptOutput
4+
from ai.schemas.common import (
5+
CommonMistake,
6+
DecisionHistoryItem,
7+
GeneratedStep,
8+
ProjectInfo,
9+
RecommendedMethod,
10+
RequiredStepInfo,
11+
RequiredStepStatus,
12+
RetrievedChunk,
13+
StageInfo,
14+
StepInfo,
15+
)
16+
from ai.schemas.generate import GenerateInput, GenerateOutput
17+
from ai.schemas.side_panel import SidePanelInput, SidePanelOutput
18+
19+
__all__ = [
20+
# common
21+
"ProjectInfo",
22+
"StageInfo",
23+
"StepInfo",
24+
"DecisionHistoryItem",
25+
"RequiredStepInfo",
26+
"RequiredStepStatus",
27+
"GeneratedStep",
28+
"RecommendedMethod",
29+
"CommonMistake",
30+
"RetrievedChunk",
31+
# generate
32+
"GenerateInput",
33+
"GenerateOutput",
34+
# accept
35+
"AcceptInput",
36+
"AcceptOutput",
37+
# side_panel
38+
"SidePanelInput",
39+
"SidePanelOutput",
40+
]

ai/schemas/accept.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,34 @@
1-
# ai/schemas/accept.py — AcceptInput, AcceptOutput (Phase 1에서 구현)
1+
"""accept 시나리오 입출력 스키마 — AI Dataset Spec v3 기반.
2+
3+
필수 Step 충족 판단: is_current_required_step_completed를 반환.
4+
"""
5+
6+
from typing import Any, Optional
7+
8+
from pydantic import BaseModel
9+
10+
from ai.schemas.common import (
11+
ProjectInfo,
12+
RequiredStepInfo,
13+
RequiredStepStatus,
14+
StageInfo,
15+
StepInfo,
16+
)
17+
18+
19+
class AcceptInput(BaseModel):
20+
"""accept 시나리오 입력."""
21+
22+
project_info: ProjectInfo
23+
current_stage: StageInfo
24+
required_steps_status: list[RequiredStepStatus]
25+
current_required_step: Optional[RequiredStepInfo] = None
26+
accepted_steps_in_required: list[StepInfo]
27+
accepted_step: StepInfo
28+
rag_context: Optional[dict[str, Any]] = None
29+
30+
31+
class AcceptOutput(BaseModel):
32+
"""accept 시나리오 출력."""
33+
34+
is_current_required_step_completed: bool

ai/schemas/common.py

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,93 @@
1-
# ai/schemas/common.py — 공통 Pydantic 모델 (Phase 1에서 구현)
1+
"""공통 Pydantic 모델 — AI Dataset Spec v3 기반.
2+
3+
모든 AI 시나리오(generate, accept, side_panel)에서 공유하는 데이터 모델.
4+
"""
5+
6+
from typing import Optional
7+
8+
from pydantic import BaseModel
9+
10+
11+
class ProjectInfo(BaseModel):
12+
"""프로젝트 기본 정보."""
13+
14+
project_id: str
15+
name: Optional[str] = None
16+
duration_months: int
17+
member_count: int
18+
description: Optional[str] = None
19+
constraints: Optional[str] = None
20+
initial_prompt: str
21+
22+
23+
class StageInfo(BaseModel):
24+
"""현재 Stage 정보."""
25+
26+
stage_id: str
27+
stage_number: int
28+
name: str
29+
30+
31+
class StepInfo(BaseModel):
32+
"""Step 기본 정보 (current_step, target_step, accepted_step 등)."""
33+
34+
step_id: str
35+
name: str
36+
37+
38+
class DecisionHistoryItem(BaseModel):
39+
"""사용자 의사결정 히스토리 항목."""
40+
41+
step_id: str
42+
name: str
43+
status: str
44+
stage_number: Optional[int] = None
45+
46+
47+
class RequiredStepInfo(BaseModel):
48+
"""현재 진행 중인 필수 Step 상세 정보."""
49+
50+
step_id: str
51+
name: str
52+
is_completed: bool
53+
goal: str
54+
entry_criteria: str
55+
fulfillment_aspects: list[str]
56+
fulfillment_threshold: int
57+
58+
59+
class RequiredStepStatus(BaseModel):
60+
"""Stage 내 필수 Step 완료 상태."""
61+
62+
name: str
63+
order: int
64+
is_completed: bool
65+
66+
67+
class GeneratedStep(BaseModel):
68+
"""AI가 생성한 일반 Step."""
69+
70+
name: str
71+
description: str
72+
73+
74+
class RecommendedMethod(BaseModel):
75+
"""사이드패널 추천 방법."""
76+
77+
title: str
78+
content: str
79+
80+
81+
class CommonMistake(BaseModel):
82+
"""사이드패널 흔한 실수."""
83+
84+
mistake: str
85+
bad_example: str
86+
good_example: str
87+
88+
89+
class RetrievedChunk(BaseModel):
90+
"""KB에서 검색된 청크."""
91+
92+
text: str
93+
relevance_score: float

ai/schemas/generate.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,41 @@
1-
# ai/schemas/generate.py — GenerateInput, GenerateOutput (Phase 1에서 구현)
1+
"""generate 시나리오 입출력 스키마 — AI Dataset Spec v3 기반.
2+
3+
Step 동적 생성: 일반 Step 3개를 생성하여 반환.
4+
"""
5+
6+
from typing import Any, Optional
7+
8+
from pydantic import BaseModel, field_validator
9+
10+
from ai.schemas.common import (
11+
DecisionHistoryItem,
12+
GeneratedStep,
13+
ProjectInfo,
14+
RequiredStepInfo,
15+
StageInfo,
16+
StepInfo,
17+
)
18+
19+
20+
class GenerateInput(BaseModel):
21+
"""generate 시나리오 입력."""
22+
23+
project_info: ProjectInfo
24+
current_stage: StageInfo
25+
decision_history: list[DecisionHistoryItem]
26+
current_step: StepInfo
27+
current_required_step: Optional[RequiredStepInfo] = None
28+
rag_context: Optional[dict[str, Any]] = None
29+
30+
31+
class GenerateOutput(BaseModel):
32+
"""generate 시나리오 출력 — 정확히 3개의 GeneratedStep."""
33+
34+
generated_steps: list[GeneratedStep]
35+
36+
@field_validator("generated_steps")
37+
@classmethod
38+
def exactly_three(cls, v: list[GeneratedStep]) -> list[GeneratedStep]:
39+
if len(v) != 3:
40+
raise ValueError("generated_steps must contain exactly 3 items")
41+
return v

ai/schemas/side_panel.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,39 @@
1-
# ai/schemas/side_panel.py — SidePanelInput, SidePanelOutput (Phase 1에서 구현)
1+
"""side_panel 시나리오 입출력 스키마 — AI Dataset Spec v3.1 기반.
2+
3+
일반 Step 사이드패널 콘텐츠 동적 생성:
4+
description + recommended_methods + common_mistakes + one_line_tip.
5+
"""
6+
7+
from typing import Any, Optional
8+
9+
from pydantic import BaseModel
10+
11+
from ai.schemas.common import (
12+
CommonMistake,
13+
DecisionHistoryItem,
14+
ProjectInfo,
15+
RecommendedMethod,
16+
RequiredStepInfo,
17+
StageInfo,
18+
StepInfo,
19+
)
20+
21+
22+
class SidePanelInput(BaseModel):
23+
"""side_panel 시나리오 입력."""
24+
25+
project_info: ProjectInfo
26+
current_stage: StageInfo
27+
target_step: StepInfo
28+
decision_history: list[DecisionHistoryItem]
29+
current_required_step: Optional[RequiredStepInfo] = None
30+
rag_context: Optional[dict[str, Any]] = None
31+
32+
33+
class SidePanelOutput(BaseModel):
34+
"""side_panel 시나리오 출력 — 일반 Step용."""
35+
36+
description: str
37+
recommended_methods: list[RecommendedMethod]
38+
common_mistakes: list[CommonMistake]
39+
one_line_tip: str

0 commit comments

Comments
 (0)