From 15615ccf6f9cb0c05ca54b6c8dff73e017f5f4d8 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Fri, 25 Sep 2026 09:32:02 +0200 Subject: [PATCH] LLM - Disable by default the fetching of price mappings from GitHub on startup --- changedetectionio/__init__.py | 18 ++++++++++++++++++ docker-compose.yml | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/changedetectionio/__init__.py b/changedetectionio/__init__.py index f2722c535..bc8c566fb 100644 --- a/changedetectionio/__init__.py +++ b/changedetectionio/__init__.py @@ -77,6 +77,24 @@ if 'MALLOC_ARENA_MAX' not in os.environ: except Exception: pass + +def configure_litellm_pricing_source(): + # On first import litellm fetches its model pricing/context-window map from GitHub's 'main' + # branch: an outbound request nobody asked for, up to a 5s stall on offline installs, and + # unpinned data. Default to the map bundled with the installed litellm instead. + # LITELLM_FETCH_PRICING_FROM_GITHUB=true opts back in; an explicit LITELLM_LOCAL_MODEL_COST_MAP + # (litellm's own switch) always wins. Must run before the first 'import litellm'. + try: + fetch_from_github = strtobool(os.getenv('LITELLM_FETCH_PRICING_FROM_GITHUB', 'false')) + except ValueError: + # Runs at package import, so a typo must not stop the app from starting + logger.warning("LITELLM_FETCH_PRICING_FROM_GITHUB is not a valid true/false value, using false") + fetch_from_github = False + os.environ.setdefault('LITELLM_LOCAL_MODEL_COST_MAP', 'False' if fetch_from_github else 'True') + + +configure_litellm_pricing_source() + # Set spawn as global default (safety net - all our code uses explicit contexts anyway) # Skip in tests to avoid breaking pytest-flask's LiveServer fixture (uses unpicklable local functions) if 'pytest' not in sys.modules: diff --git a/docker-compose.yml b/docker-compose.yml index 17615aa4f..aee47caad 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -89,6 +89,10 @@ services: # In Ollama: run `ollama run ` then `/set parameter num_ctx 8192` # - LLM_RESTOCK_MAX_CONTENT_CHARS=15000 # + # Fetch the latest LLM model pricing (used for the estimated cost counter) from GitHub, default false. + # When false the pricing list that ships with this version is used, so no outbound request is made. (Off by default for privacy) + # - LITELLM_FETCH_PRICING_FROM_GITHUB=false + # # A valid timezone name to run as (for scheduling watch checking) see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones # - TZ=America/Los_Angeles #