diff --git a/src/app/news/__init__.py b/src/app/news/__init__.py index 080c3ef..94873fd 100644 --- a/src/app/news/__init__.py +++ b/src/app/news/__init__.py @@ -45,13 +45,32 @@ class NewsAPIsTool(NewsWrapper, Toolkit): ], ) - # TODO Pensare se ha senso restituire gli articoli da TUTTI i wrapper o solo dal primo che funziona - # la modifica รจ banale, basta usare try_call_all invece di try_call def get_top_headlines(self, limit: int = 100) -> list[Article]: return self.wrapper_handler.try_call(lambda w: w.get_top_headlines(limit)) def get_latest_news(self, query: str, limit: int = 100) -> list[Article]: return self.wrapper_handler.try_call(lambda w: w.get_latest_news(query, limit)) + def get_top_headlines_aggregated(self, limit: int = 100) -> dict[str, list[Article]]: + """ + Calls get_top_headlines on all wrappers/providers and returns a dictionary mapping their names to their articles. + Args: + limit (int): Maximum number of articles to retrieve from each provider. + Returns: + dict[str, list[Article]]: A dictionary mapping providers names to their list of Articles + """ + return self.wrapper_handler.try_call_all(lambda w: w.get_top_headlines(limit)) + + def get_latest_news_aggregated(self, query: str, limit: int = 100) -> dict[str, list[Article]]: + """ + Calls get_latest_news on all wrappers/providers and returns a dictionary mapping their names to their articles. + Args: + query (str): The search query to find relevant news articles. + limit (int): Maximum number of articles to retrieve from each provider. + Returns: + dict[str, list[Article]]: A dictionary mapping providers names to their list of Articles + """ + return self.wrapper_handler.try_call_all(lambda w: w.get_latest_news(query, limit)) + NEWS_INSTRUCTIONS = """ **TASK:** You are a specialized **Crypto News Analyst**. Your goal is to fetch the latest news or top headlines related to cryptocurrencies, and then **analyze the sentiment** of the content to provide a concise report to the team leader. Prioritize 'crypto' or specific cryptocurrency names (e.g., 'Bitcoin', 'Ethereum') in your searches. @@ -59,6 +78,8 @@ NEWS_INSTRUCTIONS = """ **AVAILABLE TOOLS:** 1. `get_latest_news(query: str, limit: int)`: Get the 'limit' most recent news articles for a specific 'query'. 2. `get_top_headlines(limit: int)`: Get the 'limit' top global news headlines. +3. `get_latest_news_aggregated(query: str, limit: int)`: Get aggregated latest news articles for a specific 'query'. +4. `get_top_headlines_aggregated(limit: int)`: Get aggregated top global news headlines. **USAGE GUIDELINE:** * Always use `get_latest_news` with a relevant crypto-related query first. diff --git a/src/app/social/reddit.py b/src/app/social/reddit.py index e0b4928..904448d 100644 --- a/src/app/social/reddit.py +++ b/src/app/social/reddit.py @@ -4,8 +4,8 @@ from praw.models import Submission, MoreComments from .base import SocialWrapper, SocialPost, SocialComment MAX_COMMENTS = 5 -# TODO mettere piu' subreddit? -# scelti da https://lkiconsulting.io/marketing/best-crypto-subreddits/ +# metterne altri se necessario. +# fonti: https://lkiconsulting.io/marketing/best-crypto-subreddits/ SUBREDDITS = [ "CryptoCurrency", "Bitcoin", diff --git a/src/app/utils/market_aggregation.py b/src/app/utils/market_aggregation.py index d0cdfb3..f20e4fb 100644 --- a/src/app/utils/market_aggregation.py +++ b/src/app/utils/market_aggregation.py @@ -63,9 +63,6 @@ def aggregate_product_info(products: dict[str, list[ProductInfo]]) -> list[Produ product.price = (prices / volume_sum) if volume_sum > 0 else 0.0 aggregated_products.append(product) - - confidence = _calculate_confidence(product_list, sources) # TODO necessary? - return aggregated_products def _calculate_confidence(products: list[ProductInfo], sources: list[str]) -> float: