From 2f01e13d36e0926a5b00ad7f896962b842c4088c Mon Sep 17 00:00:00 2001 From: happybell80 Date: Sun, 31 Aug 2025 15:58:00 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20PostgreSQL=20=ED=86=B5=ED=95=A9=20?= =?UTF-8?q?=EA=B3=84=ED=9A=8D=20-=20=EC=8B=A4=EC=A0=9C=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EA=B5=AC=EC=A1=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - main.py 엔드포인트들이 router._call_internal_llm() 직접 호출 - router.handle_message()는 사용되지 않음 - 해결 방안 2가지 제시: 구조 변경 vs 각 엔드포인트 수정 --- ...1_rb8001_postgresql_context_integration.md | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/plans/250831_rb8001_postgresql_context_integration.md b/plans/250831_rb8001_postgresql_context_integration.md index 5f6a0e3..b6ce98f 100644 --- a/plans/250831_rb8001_postgresql_context_integration.md +++ b/plans/250831_rb8001_postgresql_context_integration.md @@ -21,8 +21,12 @@ - PostgreSQL 조회 함수: 없음 (ConversationLog 모델만 정의) ### 수정 필요 부분 -- **파일**: `/home/heejae/rb8001/app/router/router.py` -- **함수**: `route_message()` 내 LLM 컨텍스트 구성 부분 +- **파일**: `/home/heejae/rb8001/main.py` +- **엔드포인트 실제 구조**: + - `/api/message` (라인 51-103): Frontend용, `router._call_internal_llm()` 직접 호출 + - `/api/slack/events` (라인 157-160): Slack용, `slack_handler()` 호출 + - `/complete` (라인 106-140): skill-slack용, `router._call_internal_llm()` 직접 호출 +- **핵심 문제**: router.handle_message()는 아무도 호출 안 함, 최근 대화 조회 코드가 실행 안 됨 ## 3. 구현 계획 @@ -31,10 +35,14 @@ - 함수명: `get_recent_conversations(user_id, limit=10)` - 쿼리: `SELECT message, response, timestamp FROM conversation_logs WHERE user_id = %s ORDER BY timestamp DESC` -### 3.2 중요: gemini_handler.py 수정 필요 -- **문제**: router.py에서 전달한 context 딕셔너리는 무시됨 (gemini_handler.py:87) -- **해결**: gemini_handler.py에서 context['recent_conversations'] 사용하도록 수정 -- **프롬프트**: `{system}{memory}{recent_chats}\n\n사용자: {message}` +### 3.2 해결 방안 (2가지 중 선택) +- **방안 1**: main.py 엔드포인트들이 `router.handle_message()` 호출하도록 변경 + - 장점: 한 곳에서 최근 대화 조회 관리 + - 단점: 큰 구조 변경 필요 +- **방안 2**: 각 엔드포인트(`/api/message`, `/api/slack/events`)에서 직접 최근 대화 조회 + - 장점: 기존 구조 유지 + - 단점: 중복 코드 발생 +- **gemini_handler.py**: 어느 방안이든 context['recent_conversations'] 활용 필요 ## 4. 주의사항