깡프로 뉴스 용어 추출 기능 구현 문서 업데이트

- startup_news_skill.py 생성 및 구현 내용 문서화
- main.py 리팩토링 (732→683줄) 내용 반영
- 환경변수 및 구현 체크리스트 업데이트
This commit is contained in:
happybell80 2025-09-14 19:55:01 +09:00
parent 2d84b87e8c
commit c3a1570875

View File

@ -47,9 +47,20 @@
### startup_news_skill.py 신규 생성 ### startup_news_skill.py 신규 생성
```python ```python
# rb8001/app/skills/startup_news_skill.py # 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): async def run_headlines_job(channel_id: str):
# 1. JSON 포맷으로 헤드라인 수집 # 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", []) items = result.get("items", [])
# 2. 용어 추출 (환경변수 체크) # 2. 용어 추출 (환경변수 체크)
@ -69,15 +80,8 @@ async def run_headlines_job(channel_id: str):
응답 형식: 용어1, 용어2, 용어3 응답 형식: 용어1, 용어2, 용어3
""" """
llm_result = await router._call_internal_llm( handler = GeminiHandler()
message=terms_prompt, terms = await handler.extract_keywords(terms_prompt, max_keywords=5)
user_id="system",
task_type="extract",
context={},
channel="internal"
)
terms = llm_result.get("content", "").strip()
# 3. skill-news에서 slack 포맷 가져오기 # 3. skill-news에서 slack 포맷 가져오기
slack_result = await sc.fetch_naver_headlines(fmt="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 lines[insert_idx:insert_idx] = terms_section
text = "\n".join(lines) text = "\n".join(lines)
# 5. 자체 Slack 전송 (WebClient 직접 생성) # 5. 자체 Slack 전송 (Company-X 봇 토큰 사용 - 같은 채널)
slack_client = WebClient(token=os.getenv("SLACK_BOT_TOKEN")) slack_client = WebClient(token=os.getenv("COMPANYX_SLACK_BOT_TOKEN"))
slack_client.chat_postMessage(channel=channel_id, text=text) slack_client.chat_postMessage(channel=channel_id, text=text)
``` ```