버그 수정중 .
This commit is contained in:
1 parent
088c57f415
commit
cb3adf6d2e
5 files changed
+41
-11
No files matched your search
@@ -147,7 +147,7 @@ class ChatService:
|
||||
|
||||
async def _seed_opening(self, sess) -> Optional[ChatMessage]:
|
||||
"""오프닝(턴0) 봇 메시지를 agent 로 생성하고 seq=1 로 저장한다. 동시 진입 충돌은 무시(유니크가 방어)."""
|
||||
ctx = self._agent_context(sess, turn=0)
|
||||
ctx = await self._agent_context(sess, turn=0)
|
||||
turn = await self.agent.chat(session_id=str(sess.session_id), user_input=None, ctx=ctx)
|
||||
if not turn.ok:
|
||||
return None
|
||||
@@ -231,7 +231,7 @@ class ChatService:
|
||||
return res
|
||||
|
||||
# agent 위임 (한 턴). 실패 시 선점한 유저 메시지를 롤백 → 재시도 가능.
|
||||
ctx = self._agent_context(sess, turn=turn_no)
|
||||
ctx = await self._agent_context(sess, turn=turn_no)
|
||||
turn = await self.agent.chat(session_id=str(sess.session_id), user_input=user_input, ctx=ctx)
|
||||
if not turn.ok:
|
||||
await DB_SESSION_MNG.execute_lambda_run(
|
||||
@@ -270,10 +270,16 @@ class ChatService:
|
||||
return res
|
||||
|
||||
# ---- 빌더 / 매퍼 ----------------------------------------------------
|
||||
def _agent_context(self, sess, turn: int) -> AgentChatContext:
|
||||
async def _agent_context(self, sess, turn: int) -> AgentChatContext:
|
||||
# 핸드오프 #2/#5: X-Tenant-ID 는 견적(갑) 회사 company_id 여야 한다.
|
||||
# 현재 quotation.user_id 만 보유 → 정확한 company_id 해석(company.users 조회)은 agent 연동 시 보완.
|
||||
tenant_id = "" # mock 은 무시. 실제 연동 시 quotation 의 buyer company_id 로 채운다.
|
||||
# 상품(partner.items)의 소유 회사가 갑(buyer)이므로 item.company_id 로 해석한다.
|
||||
tenant_id = "" # 해석 실패 시 빈 값(agent 가 400) — 로깅으로 추적
|
||||
err_type, item = await DB_SESSION_MNG.execute_lambda(
|
||||
items.DBType(), DBWRType.DB_READ.value,
|
||||
lambda s: self.chat_crud.get_item_by_id(s, sess.item_id),
|
||||
)
|
||||
if err_type == ErrorType.SUCCESS and item is not None and item.company_id:
|
||||
tenant_id = str(item.company_id)
|
||||
rq_type = "재협상" if sess.qt_type == 1 else "재견적"
|
||||
anchor = int(sess.target_price * 0.99) if sess.target_price else 0
|
||||
return AgentChatContext(
|
||||
|
||||
Reference in new issue
Block a user