- 251017: 완료 섹션 간소화, 상세 내용 제거, 남은 작업만 기록 - 251023: 상세 구현 내용 제거, Phase별 필요 작업만 기록 - 251225: DB 스키마 상세 SQL 제거, 테이블 구조만 요약, Phase별 필요 작업만 기록 - 원칙 준수: 구현 완료 섹션 삭제, troubleshooting 링크만, 아키텍처/Phase/필요작업만
2.2 KiB
2.2 KiB
프롬프트 동적 관리 시스템 계획
날짜: 2025-12-25 작성자: happybell80 상태: 미구현
목표
프롬프트 DB화를 통한 동적 변경 및 개인화 구현
DB 스키마 설계
테이블: prompt_templates
- scope_level: 'global', 'robeing', 'user', 'task'
- scope_id: robeing_id, user_id, task_type 등
- prompt_type: 'system', 'chat', 'extract', 'calendar_confirm', 'ir_analysis' 등
- content: JSONB (템플릿 내용 + 변수 정의)
- version, is_active, created_at, updated_at
프롬프트 분류 기준
계층적 범위(Scope)
- Global: 모든 사용자 공통 기본 프롬프트
- Robeing: 특정 로빙 공통
- User: 사용자별 개인화
- Task: 작업 타입별
병합 로직
- Global → Robeing → User 순서로 조회
- 각 레벨별 개별 쿼리 후 애플리케이션에서 병합
구현 Phase
Phase 1: DB 스키마 및 기본 인프라
rb8001/app/state/repositories/prompt_repository.py(신규): prompt_templates 테이블 생성, PromptService 클래스 (조회, 병합, 캐싱)- 기본 프롬프트 마이그레이션 (하드코딩 → DB)
Phase 2: 핵심 프롬프트 DB화
rb8001/app/services/llm/gemini_handler.py,rb8001/app/services/llm/llm_service.py: 시스템 프롬프트 DB 조회로 변경- 작업 타입별 프롬프트 (chat, extract, calendar_confirm) DB화
- 폴백 로직: DB 조회 실패 시 기존
_get_system_prompt()메서드 사용
Phase 3: 개인화 및 동적 프롬프트
rb8001/app/services/llm/prompt_service.py(신규): 사용자별 프롬프트 오버라이드, 감정 기반 동적 프롬프트 조합, 변수 치환 시스템
Phase 4: A/B 테스트 및 모니터링
- 프롬프트 버전 관리, A/B 테스트 지원, 롤백 기능
참고 문서
book/300_architecture/313_Gemini_프롬프트_설계_원칙.md- Gemini 프롬프트 설계 원칙 (필수 참고)ideas/250828_dynamic_system_prompt_memory.md- 동적 시스템 프롬프트 메모리 시스템troubleshooting/250806_happybell80_동적프롬프트구현.md- 동적 프롬프트 구현 기록book/300_architecture/311_백엔드_구조_원칙.md- 계층 분리 원칙