agent 가격협상 무한 루프 수정 + 선행 chat_server 의 가격협상 연출(카드 스크립트 + 협상지표 게이지) 복원, 버짓 확인 입력가 표시 버그, 요약카드 공급사 담당자/날짜 표시 정비. - agent: 가격협상 루프를 라운드 상한(MAX_ROUNDS)으로 종료(카드선택 실패해도 종료 보장 — 기존엔 카드소진에만 의존해 무한 입력). chat_server iteration>=3 동작 복원. - agent: 가격협상 턴에 선택 카드 스크립트(scripts_cards.json)를 script 로 렌더 + 협상지표(indicator.py, 1~99/PZ) 산출해 indicator_value/bot_chat_type 전달. Res_Chat 에 indicator/bot_chat_type, Req_Chat 에 item_price 추가. - agent: 가격협상_확인 멘트에 할인율(discount_rate) 표시, 가격협상_확인_버짓이 target 이 아니라 입력가(input_price)를 표시하도록 수정. - backend: item_price(기존 공급가) 를 agent 로 전달. 요약카드 공급사 담당자 정보를 supplier_users(빈 이메일) 대신 partner.suppliers.manager_* 에서 조회, ChatSummary.supplier_manager_phone 추가. - frontend: 요약카드 협상 개시/종료 시각을 "YYYY년 MM월 dd일 HH시 MM분 SS초"(KST) 로, 공급 계약 만료일(+1년) ISO 파싱, 우선협상 대상자에 공급사 연락처/이메일 표시. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
95 lines
3.6 KiB
Python
95 lines
3.6 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,
|
|
bot_chat_type→bot_chat_type, indicator_value→indicator_value.
|
|
summary(요약카드 데이터)는 backend 가 비즈니스 데이터로 조립해 채운다.
|
|
"""
|
|
|
|
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 = ""
|
|
supplier_manager_phone: 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 # 협상 지표(1~99). agent 가 가격협상 턴에 내려주면 표시.
|
|
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
|