From c3a15708754c0665fa4bb5aee8ef6d8cc084bb72 Mon Sep 17 00:00:00 2001 From: happybell80 Date: Sun, 14 Sep 2025 19:55:01 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B9=A1=ED=94=84=EB=A1=9C=20=EB=89=B4?= =?UTF-8?q?=EC=8A=A4=20=EC=9A=A9=EC=96=B4=20=EC=B6=94=EC=B6=9C=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EA=B5=AC=ED=98=84=20=EB=AC=B8=EC=84=9C=20=EC=97=85?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - startup_news_skill.py 생성 및 구현 내용 문서화 - main.py 리팩토링 (732→683줄) 내용 반영 - 환경변수 및 구현 체크리스트 업데이트 --- ...프로뉴스_용어추출_기능추가.md | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/troubleshooting/250914_happybell80_깡프로뉴스_용어추출_기능추가.md b/troubleshooting/250914_happybell80_깡프로뉴스_용어추출_기능추가.md index 7f52978..c2fd400 100644 --- a/troubleshooting/250914_happybell80_깡프로뉴스_용어추출_기능추가.md +++ b/troubleshooting/250914_happybell80_깡프로뉴스_용어추출_기능추가.md @@ -47,9 +47,20 @@ ### startup_news_skill.py 신규 생성 ```python # rb8001/app/skills/startup_news_skill.py +import os +import logging +from typing import List, Dict +from slack_sdk import WebClient +from app.core.config import settings +from app.commands.skill_commands import SkillCommands +from app.llm.gemini_handler import GeminiHandler + +logger = logging.getLogger(__name__) + async def run_headlines_job(channel_id: str): # 1. JSON 포맷으로 헤드라인 수집 - result = await sc.fetch_naver_headlines(fmt="json") # slack → json + sc = SkillCommands() + result = await sc.fetch_naver_headlines(fmt="json") items = result.get("items", []) # 2. 용어 추출 (환경변수 체크) @@ -69,15 +80,8 @@ async def run_headlines_job(channel_id: str): 응답 형식: 용어1, 용어2, 용어3 """ - llm_result = await router._call_internal_llm( - message=terms_prompt, - user_id="system", - task_type="extract", - context={}, - channel="internal" - ) - - terms = llm_result.get("content", "").strip() + handler = GeminiHandler() + terms = await handler.extract_keywords(terms_prompt, max_keywords=5) # 3. skill-news에서 slack 포맷 가져오기 slack_result = await sc.fetch_naver_headlines(fmt="slack") @@ -104,8 +108,8 @@ async def run_headlines_job(channel_id: str): lines[insert_idx:insert_idx] = terms_section text = "\n".join(lines) - # 5. 자체 Slack 전송 (WebClient 직접 생성) - slack_client = WebClient(token=os.getenv("SLACK_BOT_TOKEN")) + # 5. 자체 Slack 전송 (Company-X 봇 토큰 사용 - 같은 채널) + slack_client = WebClient(token=os.getenv("COMPANYX_SLACK_BOT_TOKEN")) slack_client.chat_postMessage(channel=channel_id, text=text) ```