Refactor AI daily report pipeline
This commit is contained in:
24
ai_daily_report/sources/registry.py
Normal file
24
ai_daily_report/sources/registry.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Callable
|
||||
|
||||
from ai_daily_report.models import SourceConfig
|
||||
from ai_daily_report.sources.aihot import fetch_aihot
|
||||
from ai_daily_report.sources.juya import fetch_juya
|
||||
from ai_daily_report.sources.rss import fetch_rss
|
||||
|
||||
|
||||
SourceFetcher = Callable[[SourceConfig, str, Callable[[str, int], str]], list[dict]]
|
||||
|
||||
SOURCE_FETCHERS: dict[str, SourceFetcher] = {
|
||||
"aihot": fetch_aihot,
|
||||
"rss": fetch_rss,
|
||||
"juya_rss": fetch_juya,
|
||||
}
|
||||
|
||||
|
||||
def get_source_fetcher(source_type: str) -> SourceFetcher:
|
||||
if source_type not in SOURCE_FETCHERS:
|
||||
raise KeyError(f"Unknown source type: {source_type}")
|
||||
return SOURCE_FETCHERS[source_type]
|
||||
|
||||
Reference in New Issue
Block a user