diff --git a/.env.template b/.env.template index 551be0e..1c24a3d 100644 --- a/.env.template +++ b/.env.template @@ -11,7 +11,8 @@ METACULUS_TOKEN= # Right now only used for free semantic similarity calculation in Deduplicator, but defaults to OpenAI if not filled in HUGGINGFACE_API_KEY= -# Only needed in Streamlit Cloud in order to save responses to a database and track usage +# Only needed if saving responses to a database (e.g. in Streamlit Cloud) +# Right now its hardcoded for a specific database, later this should be made more interchangeable CODA_API_KEY= # Disable if in Streamlit Cloud diff --git a/.github/workflows/hourly-run-main.yaml b/.github/workflows/hourly-run-main.yaml index 367205e..462ccc0 100644 --- a/.github/workflows/hourly-run-main.yaml +++ b/.github/workflows/hourly-run-main.yaml @@ -43,4 +43,5 @@ jobs: EXA_API_KEY: ${{ secrets.EXA_API_KEY }} ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} HUGGINGFACE_API_KEY: ${{ secrets.HUGGINGFACE_API_KEY }} + CODA_API_KEY: ${{ secrets.CODA_API_KEY }} PYTHONPATH: . diff --git a/.github/workflows/hourly-run-template.yaml b/.github/workflows/hourly-run-template.yaml index b66579e..657cf92 100644 --- a/.github/workflows/hourly-run-template.yaml +++ b/.github/workflows/hourly-run-template.yaml @@ -40,4 +40,5 @@ jobs: METACULUS_TOKEN: ${{ secrets.METACULUS_TOKEN }} PERPLEXITY_API_KEY: ${{ secrets.PERPLEXITY_API_KEY }} EXA_API_KEY: ${{ secrets.EXA_API_KEY }} + CODA_API_KEY: ${{ secrets.CODA_API_KEY }} PYTHONPATH: . diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml index 01bd4a8..0d579de 100644 --- a/.github/workflows/pre-commit.yaml +++ b/.github/workflows/pre-commit.yaml @@ -1,4 +1,4 @@ -name: pre-commit +name: Pre-Commit on: pull_request: diff --git a/pyproject.toml b/pyproject.toml index 710269c..3333f56 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "forecasting-tools" -version = "0.2.1" +version = "0.2.2" description = "AI forecasting and research tools to help humans reason about and forecast the future" authors = ["Benjamin Wilson "] license = "MIT" diff --git a/scripts/run_forecasts_for_ai_tournament.py b/scripts/run_forecasts_for_ai_tournament.py index 768766d..55cf8eb 100644 --- a/scripts/run_forecasts_for_ai_tournament.py +++ b/scripts/run_forecasts_for_ai_tournament.py @@ -13,6 +13,8 @@ sys.path.append(top_level_dir) dotenv.load_dotenv() +import logging + from forecasting_tools.forecasting.forecast_bots.main_bot import MainBot from forecasting_tools.forecasting.forecast_bots.template_bot import ( TemplateBot, @@ -24,6 +26,8 @@ from forecasting_tools.forecasting.helpers.metaculus_api import MetaculusApi from forecasting_tools.util.custom_logger import CustomLogger +logger = logging.getLogger(__name__) + def get_forecaster(bot_type: str, allow_rerun: bool) -> TemplateBot | MainBot: bot_classes = { @@ -59,11 +63,16 @@ async def run_morning_forecasts(bot_type: str, allow_rerun: bool) -> None: forecaster = get_forecaster(bot_type, allow_rerun) TOURNAMENT_ID = MetaculusApi.AI_COMPETITION_ID_Q4 reports = await forecaster.forecast_on_tournament(TOURNAMENT_ID) - for report in reports: - await asyncio.sleep(5) - ForecastDatabaseManager.add_forecast_report_to_database( - report, ForecastRunType.REGULAR_FORECAST - ) + + if os.environ.get("CODA_API_KEY"): + for report in reports: + await asyncio.sleep(5) + try: + ForecastDatabaseManager.add_forecast_report_to_database( + report, ForecastRunType.REGULAR_FORECAST + ) + except Exception as e: + logger.error(f"Error adding forecast report to database: {e}") if __name__ == "__main__":