- protocol: ChatSummary 전 필드 + ChatMessage/Res_ChatInit/Res_ChatSend 의 빈 Field 에 description 추가. 혼동되던 두 배송 필드를 조립 코드 기준으로 구분 명시(item_delivery_type=상품 기본 폴백 / delivery_type=배송형태선택 결과). - chat.py: session_id 경로 파라미터에 Path(description=...) 추가. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
59 lines
2.5 KiB
Python
59 lines
2.5 KiB
Python
from fastapi import APIRouter, Depends, Path
|
|
from fastapi.security import HTTPAuthorizationCredentials
|
|
|
|
from common.models.gmodel import UserInfo
|
|
from router.v1.validator.dependencies import IsValidAccessToken, RemoveNoneResponse, security
|
|
from services.chat_service import ChatService
|
|
from .protocol import Req_ChatSend, Res_ChatInit, Res_ChatMessages, Res_ChatSend
|
|
|
|
# URL 은 협상 세션의 하위 리소스라 prefix 는 /v1/negotiation 유지(파일만 chat/ 로 분리).
|
|
router = APIRouter(prefix="/v1/negotiation", tags=["Chat"], responses={404: {"description": "Not found"}})
|
|
|
|
|
|
@router.get(
|
|
path="/sessions/{session_id}/chat/init",
|
|
response_model=Res_ChatInit,
|
|
summary="채팅 진입(상품·견적 메타)",
|
|
description="채팅 화면 진입용. 상품/견적 정보 + 현재 세션 상태 + 마감 시각(타이머)을 반환한다. 소유(공급사) 검증.",
|
|
)
|
|
async def chat_init(
|
|
session_id: str = Path(description="대상 협상 세션 uuid"),
|
|
user_info: UserInfo = Depends(IsValidAccessToken),
|
|
credentials: HTTPAuthorizationCredentials = Depends(security),
|
|
service: ChatService = Depends(),
|
|
):
|
|
return RemoveNoneResponse(await service.init(user_info, credentials.credentials, session_id))
|
|
|
|
|
|
@router.get(
|
|
path="/sessions/{session_id}/chat/messages",
|
|
response_model=Res_ChatMessages,
|
|
summary="대화 히스토리",
|
|
description="세션의 대화 말풍선 목록(seq 오름차순). 비어 있고 협상중이면 오프닝 메시지를 생성해 포함한다.",
|
|
)
|
|
async def chat_messages(
|
|
session_id: str = Path(description="대상 협상 세션 uuid"),
|
|
user_info: UserInfo = Depends(IsValidAccessToken),
|
|
credentials: HTTPAuthorizationCredentials = Depends(security),
|
|
service: ChatService = Depends(),
|
|
):
|
|
return RemoveNoneResponse(await service.messages(user_info, credentials.credentials, session_id))
|
|
|
|
|
|
@router.post(
|
|
path="/sessions/{session_id}/chat/send",
|
|
response_model=Res_ChatSend,
|
|
summary="협상 한 턴 전송",
|
|
description="유저 입력을 보내고 agent 가 만든 봇 응답 1건을 반환한다(append-only). 종료 시 세션 입찰을 확정한다.",
|
|
)
|
|
async def chat_send(
|
|
session_id: str = Path(description="대상 협상 세션 uuid"),
|
|
req: Req_ChatSend = ...,
|
|
user_info: UserInfo = Depends(IsValidAccessToken),
|
|
credentials: HTTPAuthorizationCredentials = Depends(security),
|
|
service: ChatService = Depends(),
|
|
):
|
|
return RemoveNoneResponse(
|
|
await service.send(user_info, credentials.credentials, session_id, req.user_input_type, req.user_input)
|
|
)
|