From 30bca93eeea174d470d6d8c6eb054b6c3ca75131 Mon Sep 17 00:00:00 2001 From: hjoaquim Date: Tue, 2 Jan 2024 13:30:36 +0000 Subject: [PATCH] patch ultima --- .../ultima/openbb_ultima/__init__.py | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/openbb_platform/providers/ultima/openbb_ultima/__init__.py b/openbb_platform/providers/ultima/openbb_ultima/__init__.py index dba3055dd4f4..05470fb5f4a7 100644 --- a/openbb_platform/providers/ultima/openbb_ultima/__init__.py +++ b/openbb_platform/providers/ultima/openbb_ultima/__init__.py @@ -1,15 +1,26 @@ """Ultima provider module.""" +import warnings +from typing import Union + from openbb_core.provider.abstract.provider import Provider -from openbb_ultima.models.company_news import UltimaCompanyNewsFetcher -from openbb_ultima.models.sector_news import UltimaSectorNewsFetcher - -ultima_provider = Provider( - name="ultima", - website="https://www.ultimainsights.ai/openbb", - description="""Ultima harnesses the power of LLMs to deliver news before it hits the frontpage of Bloomberg.""", - credentials=["api_key"], - fetcher_dict={ - "CompanyNews": UltimaCompanyNewsFetcher, - "SectorNews": UltimaSectorNewsFetcher, - }, -) + +ultima_provider: Union[Provider, None] = None + +try: + from openbb_ultima.models.company_news import UltimaCompanyNewsFetcher + from openbb_ultima.models.sector_news import UltimaSectorNewsFetcher + + ultima_provider = Provider( + name="ultima", + website="https://www.ultimainsights.ai/openbb", + description="""Ultima harnesses the power of LLMs to deliver news before it hits the frontpage of Bloomberg.""", + credentials=["api_key"], + fetcher_dict={ + "CompanyNews": UltimaCompanyNewsFetcher, + "SectorNews": UltimaSectorNewsFetcher, + }, + ) +except ImportError: + warnings.warn( + "openbb-ultima is not installed. Please install openbb-ultima to use the Ultima provider." + )