@startuml !theme mono title AI Service 내부 시퀀스 - 논의사항제안 participant "SuggestionController" as Controller participant "DiscussionSuggestionService" as Service participant "LLMClient" as LLM participant "SuggestionRepository" as Repo participant "TranscriptRepository" as TranscriptRepo database "Azure OpenAI<>" as OpenAI database "PostgreSQL<>" as DB == 실시간 논의사항 제안 요청 == note over Controller TranscriptService로부터 호출 또는 API 직접 호출: POST /api/ai/suggestions/discussion Body: { "meetingId": "{meetingId}", "transcriptText": "최근 대화 내용" } end note Controller -> Service: suggestDiscussionTopics(meetingId, transcriptText) activate Service == 회의 맥락 정보 조회 == Service -> TranscriptRepo: getMeetingContext(meetingId) activate TranscriptRepo TranscriptRepo -> DB: SELECT meeting_info, agenda, participants\nFROM meeting_context activate DB DB --> TranscriptRepo: 회의 정보 deactivate DB TranscriptRepo --> Service: meetingContext deactivate TranscriptRepo Service -> TranscriptRepo: getPreviousDiscussions(meetingId) activate TranscriptRepo TranscriptRepo -> DB: SELECT discussed_topics\nFROM ai_transcripts\nWHERE meeting_id = {meetingId} activate DB DB --> TranscriptRepo: 이미 논의한 주제 목록 deactivate DB TranscriptRepo --> Service: discussedTopics deactivate TranscriptRepo == LLM 기반 논의사항 제안 생성 == Service -> Service: 제안 프롬프트 생성 note right 시스템 프롬프트: - 역할: 회의 퍼실리테이터 - 목표: 회의 안건 대비 빠진 논의 찾기 사용자 프롬프트: - 회의 안건: {agenda} - 이미 논의한 주제: {discussedTopics} - 현재 대화 내용: {transcriptText} - 참석자 정보: {participants} 지시사항: - 안건에 있지만 아직 안 다룬 항목 찾기 - 대화 흐름상 빠진 중요 논의 식별 - 추가하면 좋을 주제 제안 - 우선순위 부여 응답 형식: { "suggestions": [ { "topic": "논의 주제", "reason": "제안 이유", "priority": "HIGH|MEDIUM|LOW", "relatedAgenda": "관련 안건 항목", "estimatedTime": 분 단위 예상 시간 } ] } end note Service -> LLM: generateDiscussionSuggestions(prompt) activate LLM LLM -> OpenAI: POST /chat/completions activate OpenAI note right 요청 파라미터: - model: gpt-4o - temperature: 0.4 - response_format: json_object - max_tokens: 1500 end note OpenAI -> OpenAI: 회의 맥락 분석 note right 분석 단계: 1. 안건 항목별 진행 상황 체크 2. 이미 논의한 주제와 비교 3. 현재 대화 맥락 이해 4. 빠진 중요 논의 식별 5. 추가 제안 생성 6. 우선순위 결정 - HIGH: 안건 필수 항목 - MEDIUM: 중요하지만 선택적 - LOW: 추가 고려사항 end note OpenAI --> LLM: 논의사항 제안 목록 (JSON) deactivate OpenAI LLM --> Service: discussionSuggestions deactivate LLM == 제안 검증 및 필터링 == Service -> Service: 제안 품질 검증 note right 검증 기준: - 중복 제거 (이미 논의한 주제) - 관련성 검증 (회의 목적과 부합) - 우선순위별 정렬 - 최대 5개까지만 선택 (너무 많으면 오히려 방해) end note loop 각 제안마다 Service -> Service: 제안 메타데이터 보강 note right 추가 정보: - 생성 시각 - 제안 신뢰도 점수 - 회의 진행 시점 (분) - 상태: PENDING end note end == 제안 저장 == loop 각 검증된 제안마다 Service -> Repo: saveSuggestion(meetingId, suggestion) activate Repo Repo -> DB: INSERT INTO ai_suggestions activate DB note right 저장 데이터: - meeting_id - suggestion_type: 'DISCUSSION' - content: {topic, reason} - priority: HIGH/MEDIUM/LOW - related_agenda: "안건 항목" - estimated_time: 예상 시간 - confidence_score: 0.0-1.0 - status: PENDING - created_at end note DB --> Repo: suggestionId deactivate DB Repo --> Service: suggestionId deactivate Repo end == 응답 구성 == Service -> Service: 응답 데이터 구성 note right 프론트엔드 전달 형식: { "suggestions": [ { "id": "suggestion-uuid", "topic": "논의 주제", "reason": "제안 이유", "priority": "HIGH", "relatedAgenda": "관련 안건", "estimatedTime": 10, "canApply": true } ], "totalCount": 제안 개수, "displayHint": "오른쪽 탭에 표시" } end note Service --> Controller: 논의사항 제안 생성 완료 deactivate Service Controller --> Controller: 200 OK 응답 반환 note right 프론트엔드 처리: - 오른쪽 "추천" 탭에 표시 - "적용" 버튼 활성화 - 우선순위별 색상 표시 * HIGH: 빨강 * MEDIUM: 주황 * LOW: 초록 end note == 사용자가 제안 적용 시 == note over Controller 사용자가 "적용" 버튼 클릭 시: PUT /api/ai/suggestions/{suggestionId}/apply end note Controller -> Service: applySuggestion(suggestionId, meetingId) activate Service Service -> Repo: updateSuggestionStatus(suggestionId, "APPLIED") activate Repo Repo -> DB: UPDATE ai_suggestions\nSET status = 'APPLIED',\napplied_at = NOW() activate DB DB --> Repo: 업데이트 완료 deactivate DB Repo --> Service: 완료 deactivate Repo Service -> Service: 논의사항을 회의록에 추가하는 로직 실행 note right Meeting Service에 API 호출하여 새로운 논의 섹션 추가 end note Service --> Controller: 적용 완료 deactivate Service Controller --> Controller: 200 OK note over Controller, DB 처리 시간: - 맥락 정보 조회: 100-200ms - LLM 제안 생성: 2-3초 - 검증 및 필터링: 100-200ms - 저장 처리: 200-300ms 총 처리 시간: 약 3-4초 제안 정책: - 최대 5개까지만 제안 - 우선순위 HIGH가 1개 이상 - 이미 논의한 주제는 제외 - 제안은 회의 중 언제든 생성 가능 end note @enduml