Cap generated keywords and simplify LLM correction retries.

This commit is contained in:
2026-10-18 13:11:13 +02:00
parent 0ad504e4c9
commit 68bb2dc28c
9 changed files with 329 additions and 120 deletions
+13 -8
View File
@@ -22,18 +22,23 @@ llm_api_key=your-api-key
llm_default_temperature=0.2
metadata_prefix=photools3:
LOG_LEVEL=DEBUG
LLM_FLUSH_EVERY_PHOTOS=50
LLM_REQUEST_TIMEOUT_SECONDS=10
LLM_MAX_COMPLETION_TOKENS=1024
LLM_MAX_RETRIES=5
LLM_MAX_KEYWORDS=15
```
Keyword suggestions are restricted to the vocabulary in `config/keywords.txt`.
`LOG_LEVEL=DEBUG` enables detailed per-request and per-photo timings. The flush
interval uses LM Studio's native model-management API to unload and reload the
model after every 50 attempted batch photos. This requires LM Studio's native
`/api/v1` model-management API. Set `LLM_FLUSH_EVERY_PHOTOS=0` to disable it;
use `0` for non-LM-Studio OpenAI-compatible providers.
`LLM_MAX_RETRIES` controls how many corrective retry requests are allowed after
the initial LLM response; `5` means up to 6 requests for a photo.
`LOG_LEVEL=DEBUG` enables detailed per-request and per-photo timings.
`LLM_MAX_RETRIES` controls retries for malformed or structurally invalid
responses; `5` means up to 6 requests for a photo. A valid response with
unsupported keywords gets at most one targeted correction retry, then remaining
invalid keywords are discarded.
Each request is limited by `LLM_REQUEST_TIMEOUT_SECONDS`; a timeout reloads the
LM Studio model before retrying. `LLM_MAX_COMPLETION_TOKENS` caps the generated
response length. When all retries are exhausted, the model is reloaded before
the failed photo is reported. `LLM_MAX_KEYWORDS` sets the maximum number of
distinct keywords requested and stored per photo; excess keywords are discarded.
## Generate metadata