93 lines
3.4 KiB
Python
93 lines
3.4 KiB
Python
"""채팅(chat) 라우터 프로토콜 — backend ↔ 프론트 계약.
|
|
|
|
agent Res_Chat → 이 ChatMessage 매핑:
|
|
step→step, client_step→display_step, script→script,
|
|
input_mode→next_input_mode, input_options→next_input_type, chat_end→chat_end.
|
|
indicator/summary/reject 는 이번 범위 외(예약 필드, 기본 None).
|
|
"""
|
|
|
|
from typing import Optional
|
|
|
|
from common.models.gmodel import Res_WebPacketProtocol, WebPacketProtocol
|
|
|
|
|
|
# 협상 결과 요약 카드(summaryRSP/summaryCM)에 표시할 데이터. 종료 스텝에서만 채워 내려간다.
|
|
# 필드명은 프론트 ChatSummary 타입과 1:1 (item_isVAT 등 camelCase 유지).
|
|
class ChatSummary(WebPacketProtocol):
|
|
md_name: str = ""
|
|
md_email: str = ""
|
|
md_phone_number: str = ""
|
|
item_code: str = ""
|
|
item_name: str = ""
|
|
item_spec: str = ""
|
|
item_moq: str = ""
|
|
item_model: str = ""
|
|
item_maker: str = ""
|
|
item_isVAT: bool = False
|
|
item_lead_time: str = ""
|
|
item_display_date: str = ""
|
|
item_delivery_type: str = ""
|
|
final_price: int = 0
|
|
nego_start_date: str = ""
|
|
nego_end_date: str = ""
|
|
supplier_name: str = ""
|
|
supplier_manager_name: str = ""
|
|
supplier_manager_email: str = ""
|
|
delivery_type: Optional[str] = None
|
|
|
|
|
|
# 말풍선 한 건. sender 는 ChatSender 정수 코드(1=BOT, 2=USER)로 내려가고 라벨 매핑은 프론트가 한다.
|
|
class ChatMessage(WebPacketProtocol):
|
|
chat_id: str = ""
|
|
session_id: str = ""
|
|
seq: int = 0
|
|
sender: int = 0 # ChatSender 코드
|
|
script: str = ""
|
|
user_input_type: Optional[str] = None # 유저 입력 종류: text|percent|price
|
|
step: str = ""
|
|
display_step: str = "" # agent client_step
|
|
next_input_mode: Optional[str] = None # confirm|yes_no|percent|price|delivery_type
|
|
next_input_type: Optional[list[str]] = None # 다음 입력 선택지
|
|
chat_end: bool = False
|
|
indicator_value: Optional[float] = None # (범위 외 예약) 협상 지표
|
|
bot_chat_type: Optional[str] = None # summaryRSP|summaryCM|rejectRSP|rejectCM|indicator
|
|
summary: Optional[ChatSummary] = None # summaryRSP/summaryCM 일 때만 채워짐
|
|
|
|
|
|
# 채팅 진입 — 상품/견적 메타 + 현재 세션 상태 + 마감 시각(타이머용)
|
|
class Res_ChatInit(Res_WebPacketProtocol):
|
|
session_id: str = ""
|
|
session_status: int = 0 # SessionStatus 코드
|
|
quotation_id: str = ""
|
|
quotation_end_time: str = "" # ISO 8601 (마감 시각)
|
|
quotation_memo: str = ""
|
|
item_id: str = ""
|
|
item_name: str = ""
|
|
item_code: str = ""
|
|
item_image: str = ""
|
|
item_price: int = 0
|
|
item_model_name: str = ""
|
|
item_maker_name: str = ""
|
|
item_spec: str = ""
|
|
item_lead_time: str = ""
|
|
item_min_order_quantity: str = ""
|
|
item_vat_yn: Optional[bool] = None
|
|
item_delivery_fee_yn: Optional[bool] = None
|
|
|
|
|
|
# 대화 히스토리(재진입 복원)
|
|
class Res_ChatMessages(Res_WebPacketProtocol):
|
|
items: list[ChatMessage] = []
|
|
|
|
|
|
# 한 턴 전송. user_input 은 버튼 텍스트 또는 가격/퍼센트 문자열.
|
|
class Req_ChatSend(WebPacketProtocol):
|
|
user_input_type: Optional[str] = None # text|percent|price
|
|
user_input: str = ""
|
|
|
|
|
|
# append-only: 새 봇 메시지 1건 + 갱신된 세션 상태만 반환(전체 refetch 회피)
|
|
class Res_ChatSend(Res_WebPacketProtocol):
|
|
message: Optional[ChatMessage] = None
|
|
session_status: int = 0
|