Skip to content

Commit 6e6a744

Browse files
authored
[feature] Restock LLM fallback: make the 8000 char content limit configurable, change to 15,000 chars by default #4213 (#4257)
1 parent 4a1c1ad commit 6e6a744

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

changedetectionio/processors/restock_diff/plugins/llm_restock.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
`inject_datastore_into_plugins()` in pluggy_interface.py.
1111
"""
1212
import json
13+
import os
1314
import re
1415
from loguru import logger
1516
from changedetectionio.pluggy_interface import hookimpl
@@ -86,7 +87,11 @@
8687
'No markdown, no backticks, no explanation — pure JSON only.'
8788
)
8889

89-
_MAX_CONTENT_CHARS = 8_000
90+
# Max characters of page content (JSON-LD + stripped text) sent to the LLM.
91+
# Some retailers (e.g. Amazon.de) place the buy-box price well past 8k chars,
92+
# so this is env-configurable. Larger values increase input-token cost per
93+
# check and may exceed local-model context windows (bump Ollama num_ctx to match).
94+
_MAX_CONTENT_CHARS = int(os.getenv('LLM_RESTOCK_MAX_CONTENT_CHARS', 15_000))
9095

9196

9297
def _extract_jsonld(html_content: str) -> str:

docker-compose.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,14 @@ services:
7171
# - DISABLE_VERSION_CHECK=true
7272
#
7373
# Disable all LLM / AI features, prompts etc
74-
# - LLM_FEATURES_DISABLED=true
74+
# - LLM_FEATURES_DISABLED=true
75+
#
76+
# How much of the page text the AI reads when finding the price/stock, default 15000 characters.
77+
# Raise it if the price is missed (some shops put it far down the page).
78+
# Using a local model (Ollama)? It may only read the first part unless you raise its context size
79+
# (num_ctx) to about 8192 or more, otherwise it can miss the price.
80+
# In Ollama: run `ollama run <model>` then `/set parameter num_ctx 8192`
81+
# - LLM_RESTOCK_MAX_CONTENT_CHARS=15000
7582
#
7683
# A valid timezone name to run as (for scheduling watch checking) see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
7784
# - TZ=America/Los_Angeles

0 commit comments

Comments
 (0)