diff --git a/src/app/agents/__init__.py b/src/app/agents/__init__.py index 558381e..eb1c2b0 100644 --- a/src/app/agents/__init__.py +++ b/src/app/agents/__init__.py @@ -107,5 +107,4 @@ class AppModels(Enum): tools=tools, delay_between_retries=5, # seconds output_schema=output # se si usa uno schema di output, lo si passa qui - # TODO Eventuali altri parametri da mettere all'agente anche se si possono comunque assegnare dopo la creazione ) diff --git a/src/app/markets/__init__.py b/src/app/markets/__init__.py index 3764f18..cb012d4 100644 --- a/src/app/markets/__init__.py +++ b/src/app/markets/__init__.py @@ -65,6 +65,8 @@ class MarketAPIsTool(BaseWrapper, Toolkit): asset_ids (list[str]): Lista di asset_id da cercare. Returns: list[ProductInfo]: Lista di ProductInfo aggregati. + Raises: + Exception: If all wrappers fail to provide results. """ all_products = self.wrappers.try_call_all(lambda w: w.get_products(asset_ids)) return aggregate_product_info(all_products) @@ -78,6 +80,8 @@ class MarketAPIsTool(BaseWrapper, Toolkit): limit (int): Numero massimo di dati storici da restituire. Returns: list[Price]: Lista di Price aggregati. + Raises: + Exception: If all wrappers fail to provide results. """ all_prices = self.wrappers.try_call_all(lambda w: w.get_historical_prices(asset_id, limit)) return aggregate_history_prices(all_prices) diff --git a/src/app/news/__init__.py b/src/app/news/__init__.py index 02ccadf..4adda9d 100644 --- a/src/app/news/__init__.py +++ b/src/app/news/__init__.py @@ -59,6 +59,8 @@ class NewsAPIsTool(NewsWrapper, Toolkit): 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 + Raises: + Exception: If all wrappers fail to provide results. """ return self.wrapper_handler.try_call_all(lambda w: w.get_top_headlines(limit)) @@ -70,5 +72,7 @@ class NewsAPIsTool(NewsWrapper, Toolkit): 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 + Raises: + Exception: If all wrappers fail to provide results. """ return self.wrapper_handler.try_call_all(lambda w: w.get_latest_news(query, limit)) diff --git a/src/app/news/news_api.py b/src/app/news/news_api.py index ae47e20..db1358d 100644 --- a/src/app/news/news_api.py +++ b/src/app/news/news_api.py @@ -24,7 +24,7 @@ class NewsApiWrapper(NewsWrapper): self.client = newsapi.NewsApiClient(api_key=api_key) self.category = "business" # Cryptocurrency is under business - self.language = "en" # TODO Only English articles for now? + self.language = "en" self.max_page_size = 100 def __calc_pages(self, limit: int, page_size: int) -> tuple[int, int]: diff --git a/src/app/social/__init__.py b/src/app/social/__init__.py index a2b90d9..c2a7c7c 100644 --- a/src/app/social/__init__.py +++ b/src/app/social/__init__.py @@ -33,10 +33,21 @@ class SocialAPIsTool(SocialWrapper, Toolkit): name="Socials Toolkit", tools=[ self.get_top_crypto_posts, + self.get_top_crypto_posts_aggregated, ], ) - # TODO Pensare se ha senso restituire i post 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_crypto_posts(self, limit: int = 5) -> list[SocialPost]: return self.wrapper_handler.try_call(lambda w: w.get_top_crypto_posts(limit)) + + def get_top_crypto_posts_aggregated(self, limit_per_wrapper: int = 5) -> dict[str, list[SocialPost]]: + """ + Calls get_top_crypto_posts on all wrappers/providers and returns a dictionary mapping their names to their posts. + Args: + limit_per_wrapper (int): Maximum number of posts to retrieve from each provider. + Returns: + dict[str, list[SocialPost]]: A dictionary where keys are wrapper names and values are lists of SocialPost objects. + Raises: + Exception: If all wrappers fail to provide results. + """ + return self.wrapper_handler.try_call_all(lambda w: w.get_top_crypto_posts(limit_per_wrapper))