diff --git a/bots/scheduler.py b/bots/scheduler.py index 6db88d3..08fc182 100644 --- a/bots/scheduler.py +++ b/bots/scheduler.py @@ -156,6 +156,24 @@ def _build_openclaw_prompt(topic_data: dict) -> tuple[str, str]: source = topic_data.get('source_url') or topic_data.get('source') or '' published_at = topic_data.get('published_at', '') is_english = topic_data.get('is_english', False) + + # sources 배열 → 프롬프트용 텍스트 + SOURCES 섹션 + sources_list = topic_data.get('sources', []) + sources_prompt_lines = [] + sources_section_lines = [] + for s in sources_list: + url = s.get('url', '') + title = s.get('title', '') + date = s.get('date', published_at) + if url: + sources_prompt_lines.append(f"- {title} ({url})") + sources_section_lines.append(f"{url} | {title} | {date}") + # 단일 source_url도 포함 + if source and not any(source in l for l in sources_section_lines): + sources_section_lines.append(f"{source} | 참고 출처 | {published_at}") + sources_prompt_text = '\n'.join(sources_prompt_lines) if sources_prompt_lines else '없음 (AI 자체 지식 활용)' + sources_section_text = '\n'.join(sources_section_lines) if sources_section_lines else f"{source} | 참고 출처 | {published_at}" + system = ( "비전문가도 쉽게 읽을 수 있는 친근한 톤으로 블로그 글을 쓴다. " "자기소개나 인사말 없이 바로 주제로 들어간다. " @@ -169,12 +187,12 @@ def _build_openclaw_prompt(topic_data: dict) -> tuple[str, str]: "제목도 한국어로 매력적으로 새로 작성하라." ) lang_note = "\n⚠️ 영문 원문입니다. 단순 번역이 아닌, 한국 독자 맥락으로 재작성해주세요." if is_english else "" - prompt = f"""다음 글감을 바탕으로 한국어 블로그 원고를 작성해줘.{lang_note} + sources_note = "\n\n📰 참고 자료 (글 작성 시 참고하되, 내용을 직접 인용하지 말고 재해석해서 활용):\n" + sources_prompt_text if sources_prompt_lines else "" + prompt = f"""다음 글감을 바탕으로 한국어 블로그 원고를 작성해줘.{lang_note}{sources_note} 주제: {topic} 코너: {corner} 설명: {description} -출처: {source} 발행시점 참고: {published_at} 출력 형식은 아래 섹션만 정확히 사용해. @@ -206,7 +224,7 @@ def _build_openclaw_prompt(topic_data: dict) -> tuple[str, str]: 키워드1, 키워드2 ---SOURCES--- -{source} | 참고 출처 | {published_at} +{sources_section_text} ---DISCLAIMER--- 필요 시 짧은 면책문구