mirror of
https://github.com/hwanny1128/HGZero.git
synced 2026-06-13 07:09:09 +00:00
Merge: AI 요약 재생성 기능 및 포트 8087 통일
- AI 텍스트 요약 API 추가 (POST /api/v1/ai/summary/generate) - 불릿 포인트 및 단락형 스타일 지원 - 포트 8087로 통일 - 압축률, 핵심 포인트 추출 기능 포함 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2,9 +2,11 @@
|
||||
from fastapi import APIRouter
|
||||
from .transcripts import router as transcripts_router
|
||||
from .suggestions import router as suggestions_router
|
||||
from .summary import router as summary_router
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
# 라우터 등록
|
||||
router.include_router(transcripts_router, prefix="/transcripts", tags=["Transcripts"])
|
||||
router.include_router(suggestions_router, prefix="/ai/suggestions", tags=["AI Suggestions"])
|
||||
router.include_router(summary_router, prefix="/ai/summary", tags=["AI Summary"])
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
"""AI 요약 API 라우터"""
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from app.models.summary import SummaryRequest, SummaryResponse
|
||||
from app.services.claude_service import claude_service
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.post("/generate", response_model=SummaryResponse)
|
||||
async def generate_summary(request: SummaryRequest):
|
||||
"""
|
||||
텍스트 요약 생성 API
|
||||
|
||||
- **text**: 요약할 텍스트 (필수)
|
||||
- **language**: 요약 언어 (ko: 한국어, en: 영어) - 기본값: ko
|
||||
- **style**: 요약 스타일 (bullet: 불릿포인트, paragraph: 단락형) - 기본값: bullet
|
||||
- **max_length**: 최대 요약 길이 (단어 수) - 선택사항
|
||||
|
||||
Returns:
|
||||
요약 결과 (요약문, 핵심 포인트, 통계 정보)
|
||||
"""
|
||||
try:
|
||||
# 입력 검증
|
||||
if not request.text or len(request.text.strip()) == 0:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail="요약할 텍스트가 비어있습니다."
|
||||
)
|
||||
|
||||
if len(request.text) < 20:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail="텍스트가 너무 짧습니다. 최소 20자 이상의 텍스트를 입력해주세요."
|
||||
)
|
||||
|
||||
if len(request.text) > 10000:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail="텍스트가 너무 깁니다. 최대 10,000자까지 요약 가능합니다."
|
||||
)
|
||||
|
||||
# 언어 검증
|
||||
if request.language not in ["ko", "en"]:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail="지원하지 않는 언어입니다. 'ko' 또는 'en'만 사용 가능합니다."
|
||||
)
|
||||
|
||||
# 스타일 검증
|
||||
if request.style not in ["bullet", "paragraph"]:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail="지원하지 않는 스타일입니다. 'bullet' 또는 'paragraph'만 사용 가능합니다."
|
||||
)
|
||||
|
||||
# 최대 길이 검증
|
||||
if request.max_length and request.max_length < 10:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail="최대 길이는 10단어 이상이어야 합니다."
|
||||
)
|
||||
|
||||
logger.info(f"요약 요청 - 텍스트 길이: {len(request.text)}, 언어: {request.language}, 스타일: {request.style}")
|
||||
|
||||
# Claude 서비스 호출
|
||||
result = await claude_service.generate_summary(
|
||||
text=request.text,
|
||||
language=request.language,
|
||||
style=request.style,
|
||||
max_length=request.max_length
|
||||
)
|
||||
|
||||
return SummaryResponse(**result)
|
||||
|
||||
except HTTPException:
|
||||
raise
|
||||
except Exception as e:
|
||||
logger.error(f"요약 생성 중 오류 발생: {e}", exc_info=True)
|
||||
raise HTTPException(
|
||||
status_code=500,
|
||||
detail=f"요약 생성 중 오류가 발생했습니다: {str(e)}"
|
||||
)
|
||||
Reference in New Issue
Block a user