feat: LLM 解耦 bot、RSS 外置与内容过滤
daily 自建 Cursor bridge;DAILY_LLM_PROVIDER 控制后端;config/feeds.yaml 与 sensitive_words 可配置。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
47
scripts/gen_feeds_defaults.py
Normal file
47
scripts/gen_feeds_defaults.py
Normal file
@@ -0,0 +1,47 @@
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
from daily.news.feeds_types import NewsCategory, NewsFeed
|
||||
|
||||
data = yaml.safe_load(Path("config/feeds.yaml").read_text(encoding="utf-8"))
|
||||
|
||||
|
||||
def parse_feed(raw: dict) -> NewsFeed:
|
||||
return NewsFeed(
|
||||
name=raw["name"],
|
||||
url=raw["url"],
|
||||
slow=bool(raw.get("slow")),
|
||||
ai_filter=bool(raw.get("ai_filter")),
|
||||
)
|
||||
|
||||
|
||||
def parse_cat(raw: dict) -> NewsCategory:
|
||||
return NewsCategory(
|
||||
id=raw["id"],
|
||||
name=raw["name"],
|
||||
icon=raw["icon"],
|
||||
feeds=tuple(parse_feed(item) for item in raw["feeds"]),
|
||||
)
|
||||
|
||||
|
||||
intl = tuple(parse_cat(item) for item in data["intl"]["categories"])
|
||||
cn = tuple(parse_cat(item) for item in data["cn"]["categories"])
|
||||
keywords = tuple(data["cn"]["title_keywords"])
|
||||
|
||||
lines = [
|
||||
'"""Built-in RSS defaults when config/feeds.yaml is missing or invalid."""',
|
||||
"",
|
||||
"from __future__ import annotations",
|
||||
"",
|
||||
"from daily.news.feeds_types import NewsCategory, NewsFeed",
|
||||
"",
|
||||
f"CN_AI_TITLE_KEYWORDS: tuple[str, ...] = {keywords!r}",
|
||||
"",
|
||||
f"CN_NEWS_CATEGORIES: tuple[NewsCategory, ...] = {cn!r}",
|
||||
"",
|
||||
f"NEWS_CATEGORIES: tuple[NewsCategory, ...] = {intl!r}",
|
||||
"",
|
||||
]
|
||||
Path("daily/news/feeds_defaults.py").write_text("\n".join(lines), encoding="utf-8")
|
||||
print("written")
|
||||
Reference in New Issue
Block a user