diff --git a/plans/250831_rb8001_postgresql_context_integration.md b/plans/250831_rb8001_postgresql_context_integration.md index caab5a6..b75cd34 100644 --- a/plans/250831_rb8001_postgresql_context_integration.md +++ b/plans/250831_rb8001_postgresql_context_integration.md @@ -35,25 +35,23 @@ - 함수명: `get_recent_conversations(user_id, limit=10)` - 쿼리: `SELECT message, response, timestamp FROM conversation_logs WHERE user_id = %s ORDER BY timestamp DESC` -### 3.2 해결 방안 (단계적 접근) -- **즉시 적용 (Option 2)**: `_call_internal_llm()` 내부에서 최근 대화 조회 +### 3.2 최종 해결 방안 - 기존 handle_message() 활용 +- **최적 방안**: main.py 엔드포인트에서 `router.handle_message()` 호출 ```python - # router.py _call_internal_llm() 내부 - if not context.get("recent_conversations"): - context["recent_conversations"] = await get_recent_conversations(user_id) + # main.py /api/message (Frontend) + result = await router.handle_message(request.text, user_id, "frontend") + + # main.py /api/slack/events (Slack) + result = await router.handle_message(message, user_id, "slack") ``` - - 장점: 한 곳 수정으로 모든 경로 해결 - - 단점: 책임 분리 원칙 위반 + - **장점**: 이미 구현된 모든 기능 활용 (최근 대화 조회, 스킬 라우팅, 저장) + - **수정**: 단 2줄로 완료 + - **안전성**: 기존 테스트된 코드, channel 파라미터로 구분 -- **장기 개선 (Option 2.5)**: main.py 엔드포인트에서 context 준비 후 전달 - ```python - # main.py 각 엔드포인트 - recent_conversations = await get_recent_conversations(user_id) - context = {"recent_conversations": recent_conversations} - await router._call_internal_llm(..., context=context) - ``` - - 장점: 깔끔한 책임 분리, 기존 context 파라미터 활용 - - TODO 주석 추가: "리팩토링 - context는 호출하는 쪽에서 준비" +### 3.3 주의사항 +- Gmail 처리: "이메일" 키워드 감지 시 자동 처리 (의도된 기능) +- 슬래시 명령어: Frontend는 `/` 명령어 사용 안함 +- thread_ts: Frontend는 None 전달 ## 4. 주의사항