[feat] agent: per-company 카탈로그 — 회사 전용 카드도 action space 포함
카탈로그 스코프를 공용(user_id NULL) 전용에서 "공용 + 그 회사 유저가 만든 카드"로 확장. 공용 먼저(action_id 0..N-1 안정) → 회사 카드 뒤(append) 정렬로 공용 카드 학습을 보호. - get_nego_catalog(cdb, company_id): company_id 주면 공용 + company.users 소속 카드 함께 조회. - registry._apply_db_catalog: company_id(UUID)면 회사 카드 포함(데모/비-UUID는 공용만). - 효과: 견적이 회사 전용 카드를 선택해도 카탈로그에 있어 _selection_mask 가 매핑됨 (기존 스코프 불일치 갭 — 회사 카드 선택이 무시되던 문제 해소). 한계: 공용 카드 추가 시 회사 카드 action_id 밀림(공용은 안정) — 카드번호 기반 매핑 후속. agent 99/99. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
18020a9e07
commit
f4e59a2184
4 files changed
+88
-11
No files matched your search
@@ -8,9 +8,18 @@ Chat_server 는 `chat_engine = ChatEngine()` 전역 무인자 싱글톤이라
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import uuid
|
||||
from collections import defaultdict
|
||||
from typing import Dict, Optional
|
||||
|
||||
|
||||
def _as_uuid(key: Optional[str]):
|
||||
"""key 가 UUID(실 고객사 company_id)면 uuid.UUID 반환, 데모 테넌트명 등이면 None."""
|
||||
try:
|
||||
return uuid.UUID(key)
|
||||
except (ValueError, TypeError):
|
||||
return None
|
||||
|
||||
from common.database.db_session_manager import DB_SESSION_MNG
|
||||
from common.enums import DBType, DBWRType, ErrorType
|
||||
from common.logger import LOG
|
||||
@@ -120,9 +129,12 @@ class TenantEngineRegistry:
|
||||
|
||||
async def _apply_db_catalog(self, config: TenantConfig) -> None:
|
||||
"""DB 카탈로그로 config.action_mapping.action_to_card 를 덮어쓴다(성공 시).
|
||||
공용 카드 + 회사 전용 카드(company_id UUID 인 경우)로 action space 를 구성한다.
|
||||
비었거나 DB 불가면 config 의 파일 action_to_card 를 그대로 폴백 사용한다."""
|
||||
cid = _as_uuid(config.company_id or config.tenant_id) # UUID(실 고객사)면 회사 카드 포함
|
||||
|
||||
async def _q(s):
|
||||
_, numbers = await self._catalog_repo.get_nego_catalog(s)
|
||||
_, numbers = await self._catalog_repo.get_nego_catalog(s, cid)
|
||||
return numbers
|
||||
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user