From dec0f2b41dbc2d74ee67045ebf238708dc0a918f Mon Sep 17 00:00:00 2001 From: happybell80 Date: Thu, 2 Oct 2025 16:08:03 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20=EC=88=9C=ED=99=98=20=EC=B0=B8=EC=A1=B0?= =?UTF-8?q?=20=EC=A0=9C=EA=B1=B0=20=EB=B0=8F=20=EA=B0=90=EC=A0=95=20DB=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=20=EC=88=98=EC=A0=95=20=EC=99=84=EB=A3=8C=20?= =?UTF-8?q?=EA=B8=B0=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 20251002_emotion_circular_reference_fix.md: 순환 참조 해결 과정 - 20251002_file_size_refactoring_plan.md: 불필요한 코드 제거 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- ...20251002_emotion_circular_reference_fix.md | 40 +++++++++++++++++++ .../20251002_file_size_refactoring_plan.md | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 troubleshooting/20251002_emotion_circular_reference_fix.md diff --git a/troubleshooting/20251002_emotion_circular_reference_fix.md b/troubleshooting/20251002_emotion_circular_reference_fix.md new file mode 100644 index 0000000..56f2751 --- /dev/null +++ b/troubleshooting/20251002_emotion_circular_reference_fix.md @@ -0,0 +1,40 @@ +# 순환 참조 제거 및 감정 DB 저장 수정 + +**작성일**: 2025-10-02 16:06 +**완료일**: 2025-10-02 16:10 +**커밋**: 29c0317 + +## 문제 + +### 1. 응답 시간 23.6초 +- Gemini API 429 quota 에러 반복 +- EMOTIONS 변수 참조 에러 14회 + +### 2. 순환 참조 발견 +- llm_service.py → emotion_llm.py → llm_service.py (순환) +- emotion_llm.py:137에서 LLMService() 생성 +- generate_response_with_emotion()에서 LLM 재호출 + +## 원인 +- emotion_llm.py가 LLM 호출 (계층 위반) +- 중복 LLM 호출: handler.chat + emotion_llm LLM + +## 해결 + +### emotion_llm.py +- generate_response_with_emotion() 제거 (100-199줄) +- save_emotion_to_db() 추가 (DB 저장만) + +### llm_service.py +- 감정 분석 → 프롬프트 조절 → LLM 호출 → DB 저장 (86-110줄) +- 순환 참조 해소: llm_service → emotion_llm (단방향) + +## 결과 +- 응답 시간: 23.6초 → 1.9초 +- 감정 DB 저장 정상 작동 +- 16:06:32 KST: surprise 39.53% + +## 교훈 +- 순환 참조는 성능 문제 직결 +- 계층 원칙 준수: LLM 호출은 llm_service만 +- emotion_llm은 분석 + DB 저장만 diff --git a/troubleshooting/20251002_file_size_refactoring_plan.md b/troubleshooting/20251002_file_size_refactoring_plan.md index e56f45b..eacada8 100644 --- a/troubleshooting/20251002_file_size_refactoring_plan.md +++ b/troubleshooting/20251002_file_size_refactoring_plan.md @@ -9,7 +9,7 @@ ### llm_service.py: 343줄 → 254줄 - models.py: Pydantic 모델 분리 (44줄) - special_handler.py: 특수 명령어 처리 (68줄) -- 주석 해제: line 134-138 (감정 DB 저장 활성화) +- 감정 DB 저장 활성화 ### router.py: 557줄 → 384줄 - message_router.py: 라우팅 헬퍼 (113줄)