docs: 현재 상태 정확히 반영 - 완료/미완성 구분
- 감정 노출 제거: 부분 완료 (핸들러 미연동) - system_instruction 생성만 완료, 사용 안됨 - 구현 계획 4단계로 구체화 - 라인 번호 최신 코드 기준 수정 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
4b2544c88b
commit
a7107f051c
@ -29,10 +29,12 @@
|
||||
|
||||
## 해결 방안
|
||||
|
||||
### 1. 감정 정보 노출 제거 (완료)
|
||||
### 1. 감정 정보 노출 제거 (부분 완료)
|
||||
- 커밋: 51e45d3
|
||||
- system_instruction을 context에 포함
|
||||
- 사용자에게 감정 분석 결과 절대 노출 금지
|
||||
- llm_service.py:87-98에서 system_instruction 생성
|
||||
- context['system_instruction']에 포함
|
||||
- **문제**: 핸들러(gemini/openai/claude)가 system_instruction 미사용
|
||||
- **결과**: 직접 노출은 제거되었으나 톤 조절 미적용
|
||||
|
||||
### 2. Top-p (Nucleus Sampling) 도입 (예정)
|
||||
|
||||
@ -55,29 +57,29 @@ fear 45% + sadness 30% = 75% (> 70%)
|
||||
|
||||
### 3. 구현 계획
|
||||
|
||||
#### 핵심 파일 위치
|
||||
- emotion/base.py:19-50 (EmotionState 구조)
|
||||
- emotion_llm.py:26-98 (analyze_user_emotion)
|
||||
- llm_service.py:86-94 (프롬프트 조절)
|
||||
- database.py:172-177 (DB 저장)
|
||||
#### 현재 상태 (코드 확인 완료)
|
||||
- EmotionState: base.py:19-24 (4개 필드)
|
||||
- 감정 분석: emotion_llm.py:26-98
|
||||
- 프롬프트 조절: llm_service.py:87-98 (system_instruction 생성만)
|
||||
- DB 저장: database.py:172-177 (top_label, top_p)
|
||||
- **미완성**: 핸들러가 system_instruction 무시
|
||||
|
||||
#### emotion_llm.py:26-98 수정
|
||||
- Top-p 70% 로직 추가
|
||||
- 복합 감정 리스트 반환 (EmotionState 확장 또는 별도)
|
||||
#### 1단계: 핸들러 수정 (필수)
|
||||
- gemini_handler.py:59-150의 chat() 메서드
|
||||
- context['system_instruction'] 읽어서 프롬프트에 포함
|
||||
- openai/claude 핸들러도 동일 수정
|
||||
|
||||
#### llm_service.py:86-94 수정
|
||||
- 단일/복합 감정 구분
|
||||
- 복합 감정별 system_instruction 매핑
|
||||
- fear+sadness: "조심스럽고 따뜻하게"
|
||||
- anger+disgust: "침착하고 객관적으로"
|
||||
#### 2단계: Top-p 로직 추가
|
||||
- emotion_llm.py:26-98에 Top-p 70% 계산
|
||||
- EmotionState 확장 또는 별도 반환
|
||||
|
||||
#### database.py:172-177 수정
|
||||
- top_label (VARCHAR) → top_emotions (JSONB array)
|
||||
- top_p (FLOAT) → cumulative_p (FLOAT)
|
||||
#### 3단계: 복합 감정 처리
|
||||
- llm_service.py:87-98 복합 감정 매핑
|
||||
- fear+sadness: "조심스럽고 따뜻하게"
|
||||
|
||||
#### EmotionState 확장 검토
|
||||
- 현재: emotion_dist, entropy, dominant, confidence
|
||||
- 추가 필요: top_emotions (List[str]), cumulative_p (float)
|
||||
#### 4단계: DB 스키마 변경
|
||||
- top_label → top_emotions (JSONB)
|
||||
- top_p → cumulative_p
|
||||
|
||||
## 참고 문헌
|
||||
- Top-p Sampling: https://en.wikipedia.org/wiki/Top-p_sampling
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user