Skip to content

feat : chatbot department clarification message add - #75

Merged
Yu-JeSeung merged 3 commits into
mainfrom
feat/chatbot-service
Feb 19, 2026
Merged

feat : chatbot department clarification message add#75
Yu-JeSeung merged 3 commits into
mainfrom
feat/chatbot-service

Conversation

@Yu-JeSeung

@Yu-JeSeung Yu-JeSeung commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

📌 챗봇 학과 이름 검증 로직 추가

📝 작업 내용

  • 학과 짧은 단어 예외처리 추가

✅ 체크리스트

  • 불필요한 주석/코드를 제거
  • 로컬 환경에서 정상 동작
  • 변경 요약
    채팅봇에 학과명 모호성 해소용 명확화 메시지 기능을 추가하고, 연락처 관련 쿼리 처리와 짧은 학과명 예외처리를 보강했습니다.

  • 주요 변경점

  • 공개 함수 dept_clarification_message() 추가로 사용자의 학과 질의에 대해 후보 제시 및 명확화 응답 제공

  • 핵심 추출 및 후보 검색용 내부 헬퍼 _extract_dept_query_core, _find_dept_candidates 등 4개 추가

  • 연락처 의도 감지용 CONTACT_INTENT_RE 정규식 추가 및 연락처 추출용 폴백 _fallback_phone_from_sub_answer 구현

  • one_sentence_from_sub_answer() 개선: 연락처 의도 감지 시 폴백 전화번호 추출 및 힌트 기반 레이블 정규화 추가

  • OSS 채팅 플로우(빠른 모드)에 학과 명확화 우선 처리 추가로 의도 혼동 시 조기 응답

  • 짧은 학과명 토큰에 대한 예외처리 로직(짧은 단어 특수 처리) 추가

  • 주의/리스크

  • 학과 후보 제시의 정확성(특히 단어가 짧은 경우)과 오탐 여지 검증 필요

  • 명확화 우선 처리로 기존 응답 흐름과 충돌 가능성 — 다른 서브로직 영향 확인 권장

  • 다음 액션

  • 학과 처리 및 연락처 추출의 엣지케이스에 대한 단위/통합 테스트 추가

  • 리뷰어가 있으면 로직 동작 예시(입력→출력 케이스) 제공하여 검증 요청

@Yu-JeSeung Yu-JeSeung self-assigned this Feb 19, 2026
@coderabbitai

coderabbitai Bot commented Feb 19, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Yu-JeSeung has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 15 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

OSS 모듈에 부서/학술기관 명확화 흐름과 연락처 의도 감지 및 폰 번호 폴백 추출 로직이 추가되어, 채팅 빠른 모드에서 부서 명확화를 우선 수행하도록 변경되었습니다. (새 헬퍼 5개, 정규식 상수 1개 추가)

Changes

Cohort / File(s) Summary
부서 명확화 및 연락처 인텐트 처리
LLM/OSS/Open_AI_OSS.py
dept_clarification_message, _extract_dept_query_core, _find_dept_candidates, _hint_matches_line, _fallback_phone_from_sub_answer 등 5개 헬퍼와 CONTACT_INTENT_RE 상수 추가. one_sentence_from_sub_answer에 연락처 인텐트 감지 및 폴백 추출 통합. OSS 빠른 모드 채팅 흐름에서 부서 명확화를 우선 실행하도록 로직 변경.
임포트/스타일 조정
LLM/OSS/Open_AI_OSS.py
임포트 중복 제거 및 재정렬, 관련 보조 함수 통합으로 파일 내 구조 및 일부 스타일라인 조정 (주로 삽입/제거 라인 변경).

코드 리뷰 소요 시간

🎯 3 (Moderate) | ⏱️ ~20분

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 변경사항의 주요 내용을 정확하게 반영합니다. 부서 명확화 메시지 추가 기능이 주요 변경사항이며, 제목에 명확하게 표현되어 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/chatbot-service

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
LLM/OSS/Open_AI_OSS.py (2)

409-431: _fallback_phone_from_sub_answeruser_text 매개변수가 사용되지 않습니다.

Ruff(ARG001)에서도 보고된 바와 같이, user_text가 함수 본문에서 전혀 참조되지 않습니다. 의도적으로 향후 사용할 예정이라면 _ prefix 컨벤션(_user_text)으로 명시하거나, 불필요하다면 시그니처에서 제거하는 것이 좋습니다.

제안: 미사용 매개변수 제거
-def _fallback_phone_from_sub_answer(user_text: str, sub_answer: str, hint: dict | None = None) -> Optional[str]:
+def _fallback_phone_from_sub_answer(sub_answer: str, hint: dict | None = None) -> Optional[str]:

호출부(Line 594)도 함께 수정해야 합니다:

-        phone = _fallback_phone_from_sub_answer(user_text, sub_answer, hint)
+        phone = _fallback_phone_from_sub_answer(sub_answer, hint)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@LLM/OSS/Open_AI_OSS.py` around lines 409 - 431, The parameter user_text on
_fallback_phone_from_sub_answer is unused; either remove it from the function
signature or mark it as intentionally unused by renaming to _user_text, and
update every call site that passes user_text to match the new signature (the
call that currently supplies user_text must be changed accordingly). Ensure you
update the function definition for _fallback_phone_from_sub_answer and its
invocation(s) consistently so the linter (Ruff ARG001) no longer flags an unused
parameter.

83-83: CONTACT_INTENT_RECONTACT_WORD_RE (Line 50) 간 중복이 존재합니다.

두 정규식이 거의 동일한 패턴(연락처|전화|전화번호|문의)을 공유하며, CONTACT_INTENT_RE에만 상담|담당자가 추가되어 있습니다. 추후 유지보수 시 한쪽만 수정하고 다른 쪽을 놓칠 위험이 있으므로, 하나의 패턴으로 통합하거나 CONTACT_WORD_RECONTACT_INTENT_RE 기반으로 재사용하는 것을 권장합니다.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@LLM/OSS/Open_AI_OSS.py` at line 83, CONTACT_INTENT_RE and CONTACT_WORD_RE
duplicate most of the same tokens; refactor to a single source of truth by
extracting the shared pattern into one symbol (e.g., CONTACT_BASE_PATTERN or
CONTACT_WORD_RE) and build CONTACT_INTENT_RE from that (e.g.,
re.compile(CONTACT_WORD_RE.pattern + r"|상담|담당자") or equivalent), so both regexes
reuse the same base and avoid drift between CONTACT_INTENT_RE and
CONTACT_WORD_RE.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@LLM/OSS/Open_AI_OSS.py`:
- Around line 319-336: In dept_clarification_message the short_like branch
currently treats any short_like as "multiple candidates" even when candidates
has exactly one entry; update the logic so that when short_like is True you
further branch on len(candidates): if len(candidates) >= 2 keep the existing
"후보가 여러 개예요" flow (using picks = ", ".join(candidates[:4])), if len(candidates)
== 1 return a different message tailored to a single match (e.g., suggest the
single candidate and ask for full name or confirmation), and if len(candidates)
== 0 fall back to the existing "풀네임으로 입력해 주세요" message; keep references to
short_like, candidates, picks and the function name dept_clarification_message
to locate the change.
- Around line 401-409: The type-hint syntax using PEP 604 (`dict | None`,
`tuple[str|None, ...]`) breaks compatibility with older Python and is
inconsistent with the codebase; update the function signatures to use
typing.Optional instead: change `_hint_matches_line(label: str, body: str, hint:
dict | None)` to `hint: Optional[dict]`, change
`_fallback_phone_from_sub_answer(user_text: str, sub_answer: str, hint: dict |
None = None)` to `hint: Optional[dict] = None`, and update the later function
that uses `hint: dict | None` and `tuple[str|None, str|None, str|None]` to
`hint: Optional[dict]` and `Optional[tuple[str, str, str]]` respectively; ensure
`Optional` and any required types are imported from typing at the top of the
module.

---

Nitpick comments:
In `@LLM/OSS/Open_AI_OSS.py`:
- Around line 409-431: The parameter user_text on
_fallback_phone_from_sub_answer is unused; either remove it from the function
signature or mark it as intentionally unused by renaming to _user_text, and
update every call site that passes user_text to match the new signature (the
call that currently supplies user_text must be changed accordingly). Ensure you
update the function definition for _fallback_phone_from_sub_answer and its
invocation(s) consistently so the linter (Ruff ARG001) no longer flags an unused
parameter.
- Line 83: CONTACT_INTENT_RE and CONTACT_WORD_RE duplicate most of the same
tokens; refactor to a single source of truth by extracting the shared pattern
into one symbol (e.g., CONTACT_BASE_PATTERN or CONTACT_WORD_RE) and build
CONTACT_INTENT_RE from that (e.g., re.compile(CONTACT_WORD_RE.pattern +
r"|상담|담당자") or equivalent), so both regexes reuse the same base and avoid drift
between CONTACT_INTENT_RE and CONTACT_WORD_RE.

Comment thread LLM/OSS/Open_AI_OSS.py
Comment thread LLM/OSS/Open_AI_OSS.py
Comment on lines +401 to +409
def _hint_matches_line(label: str, body: str, hint: dict | None) -> bool:
if not hint:
return False
aliases = set(hint.get("aliases") or [])
if not aliases:
return False
return any((a in (label or "")) or (a in (body or "")) for a in aliases)

def _fallback_phone_from_sub_answer(user_text: str, sub_answer: str, hint: dict | None = None) -> Optional[str]:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check Python version requirements
echo "=== pyproject.toml ==="
fd -t f "pyproject.toml" -x cat 2>/dev/null | head -50

echo ""
echo "=== setup.py ==="
fd -t f "setup.py" -x cat 2>/dev/null | head -30

echo ""
echo "=== setup.cfg ==="
fd -t f "setup.cfg" -x cat 2>/dev/null | head -30

echo ""
echo "=== .python-version ==="
fd -t f ".python-version" -x cat 2>/dev/null

echo ""
echo "=== Checking dict | None usage ==="
rg -n 'dict\s*\|\s*None' --type=py

echo ""
echo "=== Checking Optional usage patterns ==="
rg -n 'Optional\[dict\]|Optional\[.*\]' --type=py | head -20

Repository: dongsooop/AI

Length of output: 2003


타입 힌트 스타일 불일치 및 Python 버전 호환성 문제 수정 필요

dict | Nonetuple[str|None, ...] 구문(PEP 604)은 Python 3.10+ 런타임에서만 지원됩니다. 프로젝트에 명시적인 Python 버전 요구사항이 정의되지 않았으며, 코드베이스 전체에서 Optional 스타일을 일관되게 사용하고 있어 PEP 604 구문은 호환성 문제를 야기할 수 있습니다.

다음 줄들을 Optional 스타일로 통일하세요:

  • 401번: hint: dict | Nonehint: Optional[dict]
  • 409번: hint: dict | None = Nonehint: Optional[dict] = None
  • 487번: hint: dict | Nonetuple[str|None, str|None, str|None]Optional[dict]Optional[tuple[str, str, str]]
🧰 Tools
🪛 Ruff (0.15.1)

[warning] 409-409: Unused function argument: user_text

(ARG001)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@LLM/OSS/Open_AI_OSS.py` around lines 401 - 409, The type-hint syntax using
PEP 604 (`dict | None`, `tuple[str|None, ...]`) breaks compatibility with older
Python and is inconsistent with the codebase; update the function signatures to
use typing.Optional instead: change `_hint_matches_line(label: str, body: str,
hint: dict | None)` to `hint: Optional[dict]`, change
`_fallback_phone_from_sub_answer(user_text: str, sub_answer: str, hint: dict |
None = None)` to `hint: Optional[dict] = None`, and update the later function
that uses `hint: dict | None` and `tuple[str|None, str|None, str|None]` to
`hint: Optional[dict]` and `Optional[tuple[str, str, str]]` respectively; ensure
`Optional` and any required types are imported from typing at the top of the
module.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@LLM/OSS/Open_AI_OSS.py`:
- Around line 803-810: The dept clarification step can block schedule queries
because decide_mode routes many queries to "fast" and dept_clarification_message
(invoking _find_dept_candidates) may return a clarification even for schedule
questions; ensure schedule-related queries bypass clarification by checking
looks_like_schedule(user_text) before calling dept_clarification_message (or
alternatively, after deciding mode keep the current clarification order but
short-circuit clarification when schedule_search or looks_like_schedule
indicates a schedule query). Update the fast-mode branch around
dept_clarification_message, schedule_search, and looks_like_schedule so that if
looks_like_schedule(user_text) (or schedule_search(user_text, top_k=...) returns
a positive signal) you skip dept_clarification_message and proceed to
schedule_search/render_chatty_schedule.

---

Duplicate comments:
In `@LLM/OSS/Open_AI_OSS.py`:
- Around line 426-457: The two issues: the PEP 604 union syntax "dict | None" in
_hint_matches_line and _fallback_phone_from_sub_answer breaks on <3.10 runtimes,
and the parameter user_text in _fallback_phone_from_sub_answer is unused (Ruff
ARG001). Fix by either adding from __future__ import annotations at the top of
the file to make "dict | None" safe across Python 3.7+ or replace occurrences of
"dict | None" with typing.Optional[dict] (and import Optional) to preserve
compatibility; and remove or rename the unused parameter in
_fallback_phone_from_sub_answer (change user_text to _user_text to silence the
linter, or remove it from the signature) and update its call sites accordingly
(the caller that passes user_text must be adjusted to stop passing that argument
if you remove it).

Comment thread LLM/OSS/Open_AI_OSS.py
@Yu-JeSeung
Yu-JeSeung merged commit b0606b6 into main Feb 19, 2026
1 check passed
@Yu-JeSeung
Yu-JeSeung deleted the feat/chatbot-service branch February 19, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant