mirror of
https://github.com/hwanny1128/HGZero.git
synced 2025-12-06 12:36:23 +00:00
80 lines
2.5 KiB
Python
80 lines
2.5 KiB
Python
"""요약 생성용 프롬프트"""
|
|
|
|
|
|
def get_summary_prompt(text: str, language: str = "ko", style: str = "bullet", max_length: int = None):
|
|
"""
|
|
텍스트 요약을 위한 프롬프트 생성
|
|
|
|
Args:
|
|
text: 요약할 텍스트
|
|
language: 요약 언어 (ko/en)
|
|
style: 요약 스타일 (bullet/paragraph)
|
|
max_length: 최대 요약 길이 (단어 수)
|
|
|
|
Returns:
|
|
tuple: (system_prompt, user_prompt)
|
|
"""
|
|
|
|
# 언어별 설정
|
|
if language == "ko":
|
|
lang_instruction = "한국어로 요약을 작성하세요."
|
|
bullet_prefix = "•"
|
|
style_name = "불릿 포인트" if style == "bullet" else "단락형"
|
|
else:
|
|
lang_instruction = "Write the summary in English."
|
|
bullet_prefix = "•"
|
|
style_name = "bullet points" if style == "bullet" else "paragraph"
|
|
|
|
# 길이 제한 설정
|
|
length_instruction = ""
|
|
if max_length:
|
|
if language == "ko":
|
|
length_instruction = f"\n- 요약은 {max_length}단어 이내로 작성하세요."
|
|
else:
|
|
length_instruction = f"\n- Keep the summary within {max_length} words."
|
|
|
|
system_prompt = f"""당신은 전문적인 텍스트 요약 전문가입니다.
|
|
주어진 텍스트를 명확하고 간결하게 요약하는 것이 당신의 임무입니다.
|
|
|
|
요약 원칙:
|
|
1. 핵심 정보를 빠뜨리지 않고 포함
|
|
2. 중복되는 내용은 제거
|
|
3. 원문의 의미를 왜곡하지 않음
|
|
4. {style_name} 형식으로 작성
|
|
5. {lang_instruction}{length_instruction}
|
|
|
|
응답은 반드시 다음 JSON 형식으로 제공하세요:
|
|
{{
|
|
"summary": "요약 내용",
|
|
"key_points": ["핵심 포인트 1", "핵심 포인트 2", ...],
|
|
"analysis": {{
|
|
"main_topics": ["주요 주제들"],
|
|
"sentiment": "positive/negative/neutral",
|
|
"importance_level": "high/medium/low"
|
|
}}
|
|
}}"""
|
|
|
|
if style == "bullet":
|
|
style_instruction = f"""
|
|
불릿 포인트 형식 지침:
|
|
- 각 포인트는 '{bullet_prefix}'로 시작
|
|
- 하나의 포인트는 한 문장으로 구성
|
|
- 가장 중요한 정보부터 나열
|
|
- 3-7개의 주요 포인트로 구성"""
|
|
else:
|
|
style_instruction = """
|
|
단락형 형식 지침:
|
|
- 자연스러운 문장으로 연결
|
|
- 논리적 흐름을 유지
|
|
- 적절한 접속사 사용
|
|
- 2-3개의 단락으로 구성"""
|
|
|
|
user_prompt = f"""다음 텍스트를 요약해주세요:
|
|
|
|
{text}
|
|
|
|
{style_instruction}
|
|
|
|
JSON 형식으로 응답하세요."""
|
|
|
|
return system_prompt, user_prompt |