Skip to content

Commit

Permalink
Fixed Coda integration with workflow (#14)
Browse files Browse the repository at this point in the history
* Added coda api key to workflows so runs can be saved to database

* Updated .env.template
  • Loading branch information
CodexVeritas authored Dec 19, 2024
1 parent 4d08f2d commit 232b6e9
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/hourly-run-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: .
1 change: 1 addition & 0 deletions .github/workflows/hourly-run-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: .
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: pre-commit
name: Pre-Commit

on:
pull_request:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "MIT"
Expand Down
19 changes: 14 additions & 5 deletions scripts/run_forecasts_for_ai_tournament.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 = {
Expand Down Expand Up @@ -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__":
Expand Down

0 comments on commit 232b6e9

Please sign in to comment.