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) ```