Feat: [main] news-summary-bot 완성
All checks were successful
news-summary-bot-cicd / build_push_deploy (push) Successful in 11m43s
All checks were successful
news-summary-bot-cicd / build_push_deploy (push) Successful in 11m43s
This commit is contained in:
34
app/summarizer.py
Normal file
34
app/summarizer.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import anthropic
|
||||
|
||||
from app.config import settings
|
||||
|
||||
client = anthropic.Anthropic(api_key=settings.anthropic_api_key)
|
||||
|
||||
SYSTEM_PROMPT = """너는 뉴스/경제 유튜브 영상 요약 전문가야.
|
||||
영상 자막 텍스트를 받아서 아래 형식으로 요약해줘.
|
||||
|
||||
## 형식
|
||||
- **한줄 요약**: 영상의 핵심을 한 문장으로
|
||||
- **주요 내용**: 핵심 포인트를 3~7개 불릿으로 정리
|
||||
- **결론/시사점**: 영상이 전달하려는 메시지나 시사점
|
||||
|
||||
## 규칙
|
||||
- 한국어로 작성
|
||||
- 간결하고 명확하게
|
||||
- 자막의 오타나 말더듬은 무시하고 의미 중심으로 정리
|
||||
"""
|
||||
|
||||
|
||||
def summarize(transcript: str, title: str) -> str:
|
||||
message = client.messages.create(
|
||||
model="claude-sonnet-4-20250514",
|
||||
max_tokens=2048,
|
||||
system=SYSTEM_PROMPT,
|
||||
messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": f"영상 제목: {title}\n\n자막:\n{transcript}",
|
||||
}
|
||||
],
|
||||
)
|
||||
return message.content[0].text
|
||||
Reference in New Issue
Block a user