feat(saju-lab): config + Pydantic 모델 + db.py CRUD (saju + compat) — 10 tests

This commit is contained in:
2026-05-25 20:18:19 +09:00
parent f4f518fc80
commit cad65dc869
4 changed files with 459 additions and 0 deletions

63
saju-lab/app/models.py Normal file
View File

@@ -0,0 +1,63 @@
"""saju-lab Pydantic 모델."""
from typing import List, Literal, Optional
from pydantic import BaseModel, Field
# --- Input ---
class SajuInterpretRequest(BaseModel):
year: int = Field(..., ge=1900, le=2100)
month: int = Field(..., ge=1, le=12)
day: int = Field(..., ge=1, le=31)
hour: Optional[int] = Field(None, ge=0, le=23)
gender: Literal["male", "female"]
calendar_type: Literal["solar", "lunar"] = "solar"
is_leap_month: bool = False
class CompatInterpretRequest(BaseModel):
person_a: SajuInterpretRequest
person_b: SajuInterpretRequest
# --- Response ---
class SajuInterpretResponse(BaseModel):
saju: dict
analysis: dict
daeun: List[dict]
interpretation_json: dict
reading_id: int
model: str
tokens_in: int
tokens_out: int
cost_usd: float
latency_ms: int
reroll_count: int = 0
class CompatInterpretResponse(BaseModel):
saju_a: dict
saju_b: dict
score: int
breakdown: dict
interpretation_json: dict
reading_id: int
model: str
tokens_in: int
tokens_out: int
cost_usd: float
latency_ms: int
reroll_count: int = 0
# --- CRUD ---
class SajuPatchRequest(BaseModel):
favorite: Optional[bool] = None
memo: Optional[str] = None
class CompatPatchRequest(BaseModel):
favorite: Optional[bool] = None
memo: Optional[str] = None