-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservice.py
More file actions
17 lines (15 loc) · 873 Bytes
/
service.py
File metadata and controls
17 lines (15 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from model import News
from news import check_news_from_all_sources
from strings import Source
from rss.abstract import RSSReader
from openai import OpenAI
from repository import create_news
from masks import categories_list_to_mask
async def gather_news_to_post(sources_instances: dict[Source, RSSReader], llm_client: OpenAI, summarizer_model: str, classifier_model: str) -> dict[Source, list[News]]:
news_to_post_all_sources = await check_news_from_all_sources(sources_instances, llm_client, summarizer_model, classifier_model)
for source, news in news_to_post_all_sources.items():
for news_entry in news:
# Set news as "old"
create_news(news_entry.title, news_entry.url, news_entry.full_text,
source, news_entry.neutral_text, categories_list_to_mask(news_entry.tags))
return news_to_post_all_sources