From 5be05a384625628afa1a7a1f1de2786268e51338 Mon Sep 17 00:00:00 2001 From: happybell80 Date: Sun, 31 Aug 2025 16:11:53 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20=EC=B5=9C=EC=A2=85=20=ED=95=B4=EA=B2=B0?= =?UTF-8?q?=20=EB=B0=A9=EC=95=88=20-=20=EA=B8=B0=EC=A1=B4=20handle=5Fmessa?= =?UTF-8?q?ge()=20=ED=99=9C=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - router._call_internal_llm() 대신 handle_message() 호출 - 이미 모든 기능 구현됨 (최근 대화, 스킬 라우팅, 저장) - main.py에서 2줄 수정으로 완료 --- ...1_rb8001_postgresql_context_integration.md | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) 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. 주의사항