음성 재생과 운영 배포 정리

This commit is contained in:
Yun Chan 2026-06-28 12:18:20 +09:00
parent 8ed185ce6c
commit ac7db95542
1020 changed files with 46863 additions and 2175 deletions

View file

@ -16,50 +16,18 @@ text 는 *PII 마스킹 후(text_masked)* 만 보낸다 (R7/F-03, 마스킹은
from __future__ import annotations
import asyncio
from typing import Any, AsyncIterator, Literal, Optional
from typing import Any, AsyncIterator, Optional
import httpx
from pydantic import BaseModel, Field
from .config import settings
AIRole = Literal["client", "counselor", "evaluator"]
# ── 요청/응답 계약 모델 ─────────────────────────────────
class EngineMessage(BaseModel):
role: Literal["system", "user", "assistant"]
content: str
# 프롬프트 캐싱 힌트 (설계서 §1.2 L0~L2 cache_control). 게이트웨이가 해석.
cache: bool = False
class GenerateRequest(BaseModel):
"""단발 생성 요청 (평가 AI deep-loop, 회기종료 압축 등)."""
ai_role: AIRole
messages: list[EngineMessage]
model: Optional[str] = None # 명시 시 게이트웨이 override
max_tokens: int = 1024
temperature: float = 0.7
structured_schema: Optional[dict[str, Any]] = None # Structured Outputs (CCD 비노출 강제)
session_id: Optional[str] = None # 비용 텔레메트리 귀속
metadata: dict[str, Any] = Field(default_factory=dict)
class GenerateResponse(BaseModel):
text: str
model: str
provider: str
tokens_in: int = 0
tokens_out: int = 0
cost_usd: float = 0.0
inference_geo: Optional[str] = None # 'kr'|'us' (데이터 주권 audit)
structured: Optional[dict[str, Any]] = None
class StreamRequest(GenerateRequest):
"""SSE 스트림 요청 (내담자 AI 실시간 응답)."""
from .contracts.engine_gateway import (
AIRole,
EngineMessage,
GenerateRequest,
GenerateResponse,
StreamRequest,
)
class EngineError(RuntimeError):