Skip to content

Commit 526b066

Browse files
authored
Merge pull request #24 from hanjuhn/main
fix: intent router 수정
2 parents cd42327 + b012861 commit 526b066

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

core/shared/constants/constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
# 배송 추적 관련 키워드
1212
CUSTOMS_TRACKING_KEYWORDS = [
13-
'운송장', '통관', '조회', '추적', '배송상태', '위치', '도착', '출고', '통관번호', '운송장번호'
13+
'운송장', '통관', '조회', '추적', '배송상태', '위치', '도착', '출고', '통관번호', '운송장번호',
14+
'통관 진행', '배송 조회', '운송 조회', '통관 조회', '배송 상태', '운송 상태'
1415
]
1516

1617
# 의도 분류 관련 상수들

core/shared/router/intent_router.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
from core.shared.utils.llm import get_llm
77
from core.shared.constants import (
88
TARIFF_SESSION_KEYWORDS,
9+
TARIFF_PREDICTION_KEYWORDS,
10+
CUSTOMS_TRACKING_KEYWORDS,
911
NUMBER_SELECTION_PATTERNS,
1012
QUESTION_PATTERNS,
1113
INTENT_CLASSIFICATION_PROMPT,
@@ -25,6 +27,23 @@ def _is_question(query: str) -> bool:
2527
return any(re.search(pattern, query) for pattern in QUESTION_PATTERNS)
2628

2729

30+
def _classify_by_keywords(query: str) -> Optional[str]:
31+
"""키워드 기반으로 의도를 분류합니다."""
32+
query_lower = query.lower()
33+
34+
# 배송 추적 관련 키워드 확인
35+
tracking_keywords = [kw for kw in CUSTOMS_TRACKING_KEYWORDS if kw in query_lower]
36+
if tracking_keywords:
37+
return "customs_tracking"
38+
39+
# 관세 예측 관련 키워드 확인
40+
tariff_keywords = [kw for kw in TARIFF_PREDICTION_KEYWORDS if kw in query_lower]
41+
if tariff_keywords:
42+
return "tariff_prediction"
43+
44+
return None
45+
46+
2847
def _is_in_tariff_session(state: CustomsAgentState) -> bool:
2948
"""관세 예측 세션 중인지 확인합니다."""
3049
# 1. state의 intent 필드 확인 (가장 중요)
@@ -104,6 +123,13 @@ def intent_router(state: CustomsAgentState) -> CustomsAgentState:
104123
_add_classification_message(state, "qna", "질문 형태 감지")
105124
return state
106125

126+
# 키워드 기반 분류
127+
keyword_intent = _classify_by_keywords(current_query)
128+
if keyword_intent:
129+
state["intent"] = keyword_intent
130+
_add_classification_message(state, keyword_intent, "키워드 기반 분류")
131+
return state
132+
107133
# 숫자 선택이지만 관세 예측 세션이 아닌 경우에도 tariff_prediction으로 분류
108134
# (HS 코드 직접 입력 등의 경우)
109135
if is_number_selection:

0 commit comments

Comments
 (0)