mirror of
https://github.com/hwanny1128/HGZero.git
synced 2026-06-12 22:59:10 +00:00
feat: Meeting Service AI 통합 개발
✅ 구현 완료 - AI Python Service (FastAPI, Claude API, 8087 포트) - POST /api/v1/transcripts/consolidate - 참석자별 회의록 → AI 통합 분석 - 키워드/안건별 요약/Todo 추출 - Meeting Service AI 통합 - EndMeetingService (@Primary) - AIServiceClient (RestTemplate, 30초 timeout) - AI 분석 결과 저장 (meeting_analysis, todos) - 회의 상태 COMPLETED 처리 - DTO 구조 (간소화) - ConsolidateRequest/Response - MeetingEndDTO - Todo 제목만 포함 (담당자/마감일 제거) 📝 기술스택 - Python: FastAPI, anthropic 0.71.0, psycopg2 - Java: Spring Boot, RestTemplate - Claude: claude-3-5-sonnet-20241022 🔧 주요 이슈 해결 - 포트 충돌: 8086(feature/stt-ai) → 8087(feat/meeting-ai) - Bean 충돌: @Primary 추가 - YAML 문법: ai.service.url 구조 수정 - anthropic 라이브러리 업그레이드 📚 테스트 가이드 및 스크립트 작성 - claude/MEETING-AI-TEST-GUIDE.md - test-meeting-ai.sh 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
"""API v1 Router"""
|
||||
from fastapi import APIRouter
|
||||
from .transcripts import router as transcripts_router
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
# 라우터 등록
|
||||
router.include_router(transcripts_router, prefix="/transcripts", tags=["Transcripts"])
|
||||
@@ -0,0 +1,53 @@
|
||||
"""Transcripts API Router"""
|
||||
from fastapi import APIRouter, HTTPException, status
|
||||
import logging
|
||||
from app.models.transcript import ConsolidateRequest, ConsolidateResponse
|
||||
from app.services.transcript_service import transcript_service
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.post("/consolidate", response_model=ConsolidateResponse, status_code=status.HTTP_200_OK)
|
||||
async def consolidate_minutes(request: ConsolidateRequest):
|
||||
"""
|
||||
회의록 통합 요약
|
||||
|
||||
참석자별로 작성한 회의록을 AI가 통합하여 요약합니다.
|
||||
|
||||
- **meeting_id**: 회의 ID
|
||||
- **participant_minutes**: 참석자별 회의록 목록
|
||||
- **agendas**: 안건 목록 (선택)
|
||||
- **duration_minutes**: 회의 시간(분) (선택)
|
||||
|
||||
Returns:
|
||||
- 통합 요약, 키워드, 안건별 분석, Todo 자동 추출
|
||||
"""
|
||||
try:
|
||||
logger.info(f"POST /transcripts/consolidate - Meeting ID: {request.meeting_id}")
|
||||
|
||||
# 입력 검증
|
||||
if not request.participant_minutes:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="참석자 회의록이 비어있습니다"
|
||||
)
|
||||
|
||||
# 회의록 통합 처리
|
||||
response = await transcript_service.consolidate_minutes(request)
|
||||
|
||||
return response
|
||||
|
||||
except ValueError as e:
|
||||
logger.error(f"입력 값 오류: {e}")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=str(e)
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"회의록 통합 실패: {e}", exc_info=True)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
detail=f"회의록 통합 처리 중 오류가 발생했습니다: {str(e)}"
|
||||
)
|
||||
@@ -0,0 +1,57 @@
|
||||
"""환경 설정"""
|
||||
from pydantic_settings import BaseSettings
|
||||
from functools import lru_cache
|
||||
from typing import List
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
"""환경 설정 클래스"""
|
||||
|
||||
# 서버 설정
|
||||
app_name: str = "AI Service (Python)"
|
||||
host: str = "0.0.0.0"
|
||||
port: int = 8087 # feature/stt-ai 브랜치 AI Service(8086)와 충돌 방지
|
||||
|
||||
# Claude API
|
||||
claude_api_key: str = "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"
|
||||
claude_model: str = "claude-3-5-sonnet-20241022"
|
||||
claude_max_tokens: int = 250000
|
||||
claude_temperature: float = 0.7
|
||||
|
||||
# Redis
|
||||
redis_host: str = "20.249.177.114"
|
||||
redis_port: int = 6379
|
||||
redis_password: str = ""
|
||||
redis_db: int = 4
|
||||
|
||||
# Azure Event Hub
|
||||
eventhub_connection_string: str = "Endpoint=sb://hgzero-eventhub-ns.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=VUqZ9vFgu35E3c6RiUzoOGVUP8IZpFvlV+AEhC6sUpo="
|
||||
eventhub_name: str = "hgzero-eventhub-name"
|
||||
eventhub_consumer_group: str = "ai-transcript-group"
|
||||
|
||||
# CORS
|
||||
cors_origins: List[str] = [
|
||||
"http://localhost:8888",
|
||||
"http://localhost:8080",
|
||||
"http://localhost:3000",
|
||||
"http://127.0.0.1:8888",
|
||||
"http://127.0.0.1:8080",
|
||||
"http://127.0.0.1:3000"
|
||||
]
|
||||
|
||||
# 로깅
|
||||
log_level: str = "INFO"
|
||||
|
||||
# 분석 임계값
|
||||
min_segments_for_analysis: int = 10
|
||||
text_retention_seconds: int = 300 # 5분
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
case_sensitive = False
|
||||
|
||||
|
||||
@lru_cache()
|
||||
def get_settings() -> Settings:
|
||||
"""싱글톤 설정 인스턴스"""
|
||||
return Settings()
|
||||
@@ -0,0 +1,16 @@
|
||||
"""Data Models"""
|
||||
from .transcript import (
|
||||
ConsolidateRequest,
|
||||
ConsolidateResponse,
|
||||
AgendaSummary,
|
||||
ParticipantMinutes,
|
||||
ExtractedTodo
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"ConsolidateRequest",
|
||||
"ConsolidateResponse",
|
||||
"AgendaSummary",
|
||||
"ParticipantMinutes",
|
||||
"ExtractedTodo",
|
||||
]
|
||||
@@ -0,0 +1,69 @@
|
||||
"""Keyword Models"""
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import List
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class KeywordExtractRequest(BaseModel):
|
||||
"""주요 키워드 추출 요청"""
|
||||
meeting_id: str = Field(..., description="회의 ID")
|
||||
transcript_text: str = Field(..., description="전체 회의록 텍스트")
|
||||
max_keywords: int = Field(default=10, ge=1, le=20, description="최대 키워드 개수")
|
||||
|
||||
class Config:
|
||||
json_schema_extra = {
|
||||
"example": {
|
||||
"meeting_id": "550e8400-e29b-41d4-a716-446655440000",
|
||||
"transcript_text": "안건 1: 신제품 기획...\n타겟 고객을 20-30대로 설정...",
|
||||
"max_keywords": 10
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ExtractedKeyword(BaseModel):
|
||||
"""추출된 키워드"""
|
||||
keyword: str = Field(..., description="키워드")
|
||||
relevance_score: float = Field(..., ge=0.0, le=1.0, description="관련성 점수")
|
||||
frequency: int = Field(..., description="출현 빈도")
|
||||
category: str = Field(..., description="카테고리 (예: 기술, 전략, 일정 등)")
|
||||
|
||||
class Config:
|
||||
json_schema_extra = {
|
||||
"example": {
|
||||
"keyword": "신제품기획",
|
||||
"relevance_score": 0.95,
|
||||
"frequency": 15,
|
||||
"category": "전략"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class KeywordExtractResponse(BaseModel):
|
||||
"""주요 키워드 추출 응답"""
|
||||
meeting_id: str = Field(..., description="회의 ID")
|
||||
keywords: List[ExtractedKeyword] = Field(..., description="추출된 키워드 목록")
|
||||
total_count: int = Field(..., description="전체 키워드 개수")
|
||||
extracted_at: datetime = Field(default_factory=datetime.utcnow, description="추출 시각")
|
||||
|
||||
class Config:
|
||||
json_schema_extra = {
|
||||
"example": {
|
||||
"meeting_id": "550e8400-e29b-41d4-a716-446655440000",
|
||||
"keywords": [
|
||||
{
|
||||
"keyword": "신제품기획",
|
||||
"relevance_score": 0.95,
|
||||
"frequency": 15,
|
||||
"category": "전략"
|
||||
},
|
||||
{
|
||||
"keyword": "예산편성",
|
||||
"relevance_score": 0.88,
|
||||
"frequency": 12,
|
||||
"category": "재무"
|
||||
}
|
||||
],
|
||||
"total_count": 10,
|
||||
"extracted_at": "2025-01-23T10:30:00Z"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
"""Todo Models"""
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import List, Optional
|
||||
from datetime import datetime, date
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class PriorityLevel(str, Enum):
|
||||
"""우선순위"""
|
||||
HIGH = "HIGH"
|
||||
MEDIUM = "MEDIUM"
|
||||
LOW = "LOW"
|
||||
|
||||
|
||||
class TodoExtractRequest(BaseModel):
|
||||
"""Todo 자동 추출 요청"""
|
||||
meeting_id: str = Field(..., description="회의 ID")
|
||||
transcript_text: str = Field(..., description="전체 회의록 텍스트")
|
||||
participants: List[str] = Field(..., description="참석자 목록")
|
||||
|
||||
class Config:
|
||||
json_schema_extra = {
|
||||
"example": {
|
||||
"meeting_id": "550e8400-e29b-41d4-a716-446655440000",
|
||||
"transcript_text": "안건 1: 신제품 기획...\n결정사항: API 설계서는 박민수님이 1월 30일까지 작성...",
|
||||
"participants": ["김민준", "박서연", "이준호", "박민수"]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ExtractedTodo(BaseModel):
|
||||
"""추출된 Todo"""
|
||||
title: str = Field(..., description="Todo 제목")
|
||||
description: Optional[str] = Field(None, description="상세 설명")
|
||||
assignee: str = Field(..., description="담당자 이름")
|
||||
due_date: Optional[date] = Field(None, description="마감일")
|
||||
priority: PriorityLevel = Field(default=PriorityLevel.MEDIUM, description="우선순위")
|
||||
section_reference: str = Field(..., description="섹션 참조 (예: '결정사항 #1')")
|
||||
confidence_score: float = Field(..., ge=0.0, le=1.0, description="신뢰도 점수")
|
||||
|
||||
class Config:
|
||||
json_schema_extra = {
|
||||
"example": {
|
||||
"title": "API 설계서 작성",
|
||||
"description": "신규 프로젝트 API 설계서 작성 완료",
|
||||
"assignee": "박민수",
|
||||
"due_date": "2025-01-30",
|
||||
"priority": "HIGH",
|
||||
"section_reference": "결정사항 #1",
|
||||
"confidence_score": 0.92
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class TodoExtractResponse(BaseModel):
|
||||
"""Todo 자동 추출 응답"""
|
||||
meeting_id: str = Field(..., description="회의 ID")
|
||||
todos: List[ExtractedTodo] = Field(..., description="추출된 Todo 목록")
|
||||
total_count: int = Field(..., description="전체 Todo 개수")
|
||||
extracted_at: datetime = Field(default_factory=datetime.utcnow, description="추출 시각")
|
||||
|
||||
class Config:
|
||||
json_schema_extra = {
|
||||
"example": {
|
||||
"meeting_id": "550e8400-e29b-41d4-a716-446655440000",
|
||||
"todos": [
|
||||
{
|
||||
"title": "API 설계서 작성",
|
||||
"description": "신규 프로젝트 API 설계서 작성 완료",
|
||||
"assignee": "박민수",
|
||||
"due_date": "2025-01-30",
|
||||
"priority": "HIGH",
|
||||
"section_reference": "결정사항 #1",
|
||||
"confidence_score": 0.92
|
||||
}
|
||||
],
|
||||
"total_count": 5,
|
||||
"extracted_at": "2025-01-23T10:30:00Z"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
"""Transcript Models"""
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import List, Optional, Dict
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class ParticipantMinutes(BaseModel):
|
||||
"""참석자별 회의록"""
|
||||
user_id: str = Field(..., description="사용자 ID")
|
||||
user_name: str = Field(..., description="사용자 이름")
|
||||
content: str = Field(..., description="회의록 전체 내용 (MEMO 섹션)")
|
||||
|
||||
|
||||
class ConsolidateRequest(BaseModel):
|
||||
"""회의록 통합 요약 요청"""
|
||||
meeting_id: str = Field(..., description="회의 ID")
|
||||
participant_minutes: List[ParticipantMinutes] = Field(..., description="참석자별 회의록 목록")
|
||||
agendas: Optional[List[str]] = Field(None, description="안건 목록")
|
||||
duration_minutes: Optional[int] = Field(None, description="회의 시간(분)")
|
||||
|
||||
|
||||
class ExtractedTodo(BaseModel):
|
||||
"""추출된 Todo (제목만)"""
|
||||
title: str = Field(..., description="Todo 제목")
|
||||
|
||||
|
||||
class AgendaSummary(BaseModel):
|
||||
"""안건별 요약"""
|
||||
agenda_number: int = Field(..., description="안건 번호")
|
||||
agenda_title: str = Field(..., description="안건 제목")
|
||||
summary_short: str = Field(..., description="짧은 요약 (1줄)")
|
||||
discussion: str = Field(..., description="논의 주제")
|
||||
decisions: List[str] = Field(default_factory=list, description="결정 사항")
|
||||
pending: List[str] = Field(default_factory=list, description="보류 사항")
|
||||
todos: List[ExtractedTodo] = Field(default_factory=list, description="Todo 목록 (제목만)")
|
||||
|
||||
|
||||
class ConsolidateResponse(BaseModel):
|
||||
"""회의록 통합 요약 응답"""
|
||||
meeting_id: str = Field(..., description="회의 ID")
|
||||
keywords: List[str] = Field(..., description="주요 키워드")
|
||||
statistics: Dict[str, int] = Field(..., description="통계 정보")
|
||||
agenda_summaries: List[AgendaSummary] = Field(..., description="안건별 요약")
|
||||
generated_at: datetime = Field(default_factory=datetime.utcnow, description="생성 시각")
|
||||
@@ -0,0 +1,98 @@
|
||||
"""회의록 통합 요약 프롬프트"""
|
||||
|
||||
|
||||
def get_consolidate_prompt(participant_minutes: list, agendas: list = None) -> str:
|
||||
"""
|
||||
참석자별 회의록을 통합하여 요약하는 프롬프트 생성
|
||||
"""
|
||||
|
||||
# 참석자 회의록 결합
|
||||
participants_content = "\n\n".join([
|
||||
f"## {p['user_name']}님의 회의록:\n{p['content']}"
|
||||
for p in participant_minutes
|
||||
])
|
||||
|
||||
# 안건 정보 (있는 경우)
|
||||
agendas_info = ""
|
||||
if agendas:
|
||||
agendas_info = f"\n\n**사전 정의된 안건**:\n" + "\n".join([
|
||||
f"{i+1}. {agenda}" for i, agenda in enumerate(agendas)
|
||||
])
|
||||
|
||||
prompt = f"""당신은 회의록 작성 전문가입니다. 여러 참석자가 작성한 회의록을 통합하여 정확하고 체계적인 회의록을 생성해주세요.
|
||||
|
||||
# 입력 데이터
|
||||
|
||||
{participants_content}{agendas_info}
|
||||
|
||||
---
|
||||
|
||||
# 작업 지침
|
||||
|
||||
1. **주요 키워드 (keywords)**:
|
||||
- 회의에서 자주 언급된 핵심 키워드 5-10개 추출
|
||||
- 단어 또는 짧은 구문 (예: "신제품기획", "예산편성")
|
||||
|
||||
2. **통계 정보 (statistics)**:
|
||||
- agendas_count: 안건 개수 (내용 기반 추정)
|
||||
- todos_count: 추출된 Todo 총 개수
|
||||
|
||||
3. **안건별 요약 (agenda_summaries)**:
|
||||
회의 내용을 분석하여 안건별로 구조화:
|
||||
|
||||
각 안건마다:
|
||||
- **agenda_number**: 안건 번호 (1, 2, 3...)
|
||||
- **agenda_title**: 안건 제목 (간결하게)
|
||||
- **summary_short**: 1줄 요약 (20자 이내)
|
||||
- **discussion**: 논의 주제 (핵심 내용 3-5문장)
|
||||
- **decisions**: 결정 사항 배열 (해당 안건 관련)
|
||||
- **pending**: 보류 사항 배열 (추가 논의 필요 사항)
|
||||
- **todos**: Todo 배열 (제목만, 담당자/마감일/우선순위 없음)
|
||||
- title: Todo 제목만 추출 (예: "시장 조사 보고서 작성")
|
||||
|
||||
---
|
||||
|
||||
# 출력 형식
|
||||
|
||||
반드시 아래 JSON 형식으로만 응답하세요. 다른 텍스트는 포함하지 마세요.
|
||||
|
||||
```json
|
||||
{{
|
||||
"keywords": ["키워드1", "키워드2", "키워드3"],
|
||||
"statistics": {{
|
||||
"agendas_count": 숫자,
|
||||
"todos_count": 숫자
|
||||
}},
|
||||
"agenda_summaries": [
|
||||
{{
|
||||
"agenda_number": 1,
|
||||
"agenda_title": "안건 제목",
|
||||
"summary_short": "짧은 요약",
|
||||
"discussion": "논의 내용",
|
||||
"decisions": ["결정사항"],
|
||||
"pending": ["보류사항"],
|
||||
"todos": [
|
||||
{{
|
||||
"title": "Todo 제목"
|
||||
}}
|
||||
]
|
||||
}}
|
||||
]
|
||||
}}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# 중요 규칙
|
||||
|
||||
1. **정확성**: 참석자 회의록에 명시된 내용만 사용
|
||||
2. **객관성**: 추측이나 가정 없이 사실만 기록
|
||||
3. **완전성**: 모든 필드를 빠짐없이 작성
|
||||
4. **구조화**: 안건별로 명확히 분리
|
||||
5. **Todo 추출**: 제목만 추출 (담당자나 마감일 없어도 됨)
|
||||
6. **JSON만 출력**: 추가 설명 없이 JSON만 반환
|
||||
|
||||
이제 위 회의록들을 분석하여 통합 요약을 JSON 형식으로 생성해주세요.
|
||||
"""
|
||||
|
||||
return prompt
|
||||
@@ -0,0 +1,90 @@
|
||||
"""Claude API Service"""
|
||||
import anthropic
|
||||
import json
|
||||
import logging
|
||||
from typing import Dict, Any
|
||||
from app.config import get_settings
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
settings = get_settings()
|
||||
|
||||
|
||||
class ClaudeService:
|
||||
"""Claude API 호출 서비스"""
|
||||
|
||||
def __init__(self):
|
||||
self.client = anthropic.Anthropic(api_key=settings.claude_api_key)
|
||||
self.model = settings.claude_model
|
||||
self.max_tokens = settings.claude_max_tokens
|
||||
self.temperature = settings.claude_temperature
|
||||
|
||||
async def generate_completion(
|
||||
self,
|
||||
prompt: str,
|
||||
system_prompt: str = None
|
||||
) -> Dict[str, Any]:
|
||||
"""
|
||||
Claude API 호출하여 응답 생성
|
||||
|
||||
Args:
|
||||
prompt: 사용자 프롬프트
|
||||
system_prompt: 시스템 프롬프트 (선택)
|
||||
|
||||
Returns:
|
||||
Claude API 응답 (JSON 파싱)
|
||||
"""
|
||||
try:
|
||||
# 메시지 구성
|
||||
messages = [
|
||||
{
|
||||
"role": "user",
|
||||
"content": prompt
|
||||
}
|
||||
]
|
||||
|
||||
# API 호출
|
||||
logger.info(f"Claude API 호출 시작 - Model: {self.model}")
|
||||
|
||||
if system_prompt:
|
||||
response = self.client.messages.create(
|
||||
model=self.model,
|
||||
max_tokens=self.max_tokens,
|
||||
temperature=self.temperature,
|
||||
system=system_prompt,
|
||||
messages=messages
|
||||
)
|
||||
else:
|
||||
response = self.client.messages.create(
|
||||
model=self.model,
|
||||
max_tokens=self.max_tokens,
|
||||
temperature=self.temperature,
|
||||
messages=messages
|
||||
)
|
||||
|
||||
# 응답 텍스트 추출
|
||||
response_text = response.content[0].text
|
||||
logger.info(f"Claude API 응답 수신 완료 - Tokens: {response.usage.input_tokens + response.usage.output_tokens}")
|
||||
|
||||
# JSON 파싱
|
||||
# ```json ... ``` 블록 제거
|
||||
if "```json" in response_text:
|
||||
response_text = response_text.split("```json")[1].split("```")[0].strip()
|
||||
elif "```" in response_text:
|
||||
response_text = response_text.split("```")[1].split("```")[0].strip()
|
||||
|
||||
result = json.loads(response_text)
|
||||
|
||||
return result
|
||||
|
||||
except json.JSONDecodeError as e:
|
||||
logger.error(f"JSON 파싱 실패: {e}")
|
||||
logger.error(f"응답 텍스트: {response_text[:500]}...")
|
||||
raise ValueError(f"Claude API 응답을 JSON으로 파싱할 수 없습니다: {str(e)}")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Claude API 호출 실패: {e}")
|
||||
raise
|
||||
|
||||
|
||||
# 싱글톤 인스턴스
|
||||
claude_service = ClaudeService()
|
||||
@@ -0,0 +1,114 @@
|
||||
"""Transcript Service - 회의록 통합 처리"""
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from app.models.transcript import (
|
||||
ConsolidateRequest,
|
||||
ConsolidateResponse,
|
||||
AgendaSummary,
|
||||
ExtractedTodo
|
||||
)
|
||||
from app.services.claude_service import claude_service
|
||||
from app.prompts.consolidate_prompt import get_consolidate_prompt
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TranscriptService:
|
||||
"""회의록 통합 서비스"""
|
||||
|
||||
async def consolidate_minutes(
|
||||
self,
|
||||
request: ConsolidateRequest
|
||||
) -> ConsolidateResponse:
|
||||
"""
|
||||
참석자별 회의록을 통합하여 AI 요약 생성
|
||||
"""
|
||||
logger.info(f"회의록 통합 시작 - Meeting ID: {request.meeting_id}")
|
||||
logger.info(f"참석자 수: {len(request.participant_minutes)}")
|
||||
|
||||
try:
|
||||
# 1. 프롬프트 생성
|
||||
participant_data = [
|
||||
{
|
||||
"user_name": pm.user_name,
|
||||
"content": pm.content
|
||||
}
|
||||
for pm in request.participant_minutes
|
||||
]
|
||||
|
||||
prompt = get_consolidate_prompt(
|
||||
participant_minutes=participant_data,
|
||||
agendas=request.agendas
|
||||
)
|
||||
|
||||
# 2. Claude API 호출
|
||||
start_time = datetime.utcnow()
|
||||
ai_result = await claude_service.generate_completion(prompt)
|
||||
processing_time = (datetime.utcnow() - start_time).total_seconds() * 1000
|
||||
|
||||
logger.info(f"AI 처리 완료 - {processing_time:.0f}ms")
|
||||
|
||||
# 3. 응답 구성
|
||||
response = self._build_response(
|
||||
meeting_id=request.meeting_id,
|
||||
ai_result=ai_result,
|
||||
participants_count=len(request.participant_minutes),
|
||||
duration_minutes=request.duration_minutes
|
||||
)
|
||||
|
||||
logger.info(f"통합 요약 완료 - 안건 수: {len(response.agenda_summaries)}, Todo 수: {response.statistics['todos_count']}")
|
||||
|
||||
return response
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"회의록 통합 실패: {e}", exc_info=True)
|
||||
raise
|
||||
|
||||
def _build_response(
|
||||
self,
|
||||
meeting_id: str,
|
||||
ai_result: dict,
|
||||
participants_count: int,
|
||||
duration_minutes: int = None
|
||||
) -> ConsolidateResponse:
|
||||
"""AI 응답을 ConsolidateResponse로 변환"""
|
||||
|
||||
# 안건별 요약 변환
|
||||
agenda_summaries = []
|
||||
for agenda_data in ai_result.get("agenda_summaries", []):
|
||||
# Todo 변환 (제목만)
|
||||
todos = [
|
||||
ExtractedTodo(title=todo.get("title", ""))
|
||||
for todo in agenda_data.get("todos", [])
|
||||
]
|
||||
|
||||
agenda_summaries.append(
|
||||
AgendaSummary(
|
||||
agenda_number=agenda_data.get("agenda_number", 0),
|
||||
agenda_title=agenda_data.get("agenda_title", ""),
|
||||
summary_short=agenda_data.get("summary_short", ""),
|
||||
discussion=agenda_data.get("discussion", ""),
|
||||
decisions=agenda_data.get("decisions", []),
|
||||
pending=agenda_data.get("pending", []),
|
||||
todos=todos
|
||||
)
|
||||
)
|
||||
|
||||
# 통계 정보
|
||||
statistics = ai_result.get("statistics", {})
|
||||
statistics["participants_count"] = participants_count
|
||||
if duration_minutes:
|
||||
statistics["duration_minutes"] = duration_minutes
|
||||
|
||||
# 응답 생성
|
||||
return ConsolidateResponse(
|
||||
meeting_id=meeting_id,
|
||||
keywords=ai_result.get("keywords", []),
|
||||
statistics=statistics,
|
||||
agenda_summaries=agenda_summaries,
|
||||
generated_at=datetime.utcnow()
|
||||
)
|
||||
|
||||
|
||||
# 싱글톤 인스턴스
|
||||
transcript_service = TranscriptService()
|
||||
@@ -0,0 +1,58 @@
|
||||
"""AI Service FastAPI Application"""
|
||||
import uvicorn
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from app.config import get_settings
|
||||
from app.api.v1 import router as api_v1_router
|
||||
import logging
|
||||
|
||||
# 로깅 설정
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
||||
)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Settings
|
||||
settings = get_settings()
|
||||
|
||||
# FastAPI 앱 생성
|
||||
app = FastAPI(
|
||||
title=settings.app_name,
|
||||
description="AI-powered meeting minutes analysis service",
|
||||
version="1.0.0",
|
||||
docs_url="/api/docs",
|
||||
redoc_url="/api/redoc",
|
||||
openapi_url="/api/openapi.json"
|
||||
)
|
||||
|
||||
# CORS 미들웨어 설정
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=settings.cors_origins,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
# API 라우터 등록
|
||||
app.include_router(api_v1_router, prefix="/api/v1")
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
async def health_check():
|
||||
"""헬스 체크"""
|
||||
return {
|
||||
"status": "healthy",
|
||||
"service": settings.app_name
|
||||
}
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
uvicorn.run(
|
||||
"main:app",
|
||||
host=settings.host,
|
||||
port=settings.port,
|
||||
reload=True,
|
||||
log_level=settings.log_level.lower()
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
# FastAPI
|
||||
fastapi==0.115.0
|
||||
uvicorn[standard]==0.32.0
|
||||
pydantic==2.9.2
|
||||
pydantic-settings==2.6.0
|
||||
|
||||
# Claude API
|
||||
anthropic==0.39.0
|
||||
|
||||
# Utilities
|
||||
python-dotenv==1.0.1
|
||||
Reference in New Issue
Block a user