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
-36
View File
@@ -127,39 +127,3 @@ def test_process_batch_is_sequential_reuses_session_and_continues_after_error():
assert all(len(call.args[0]) == 1 for call in session.call.call_args_list)
assert writer_class.return_value.write.call_count == 2
session.close.assert_called_once()
def test_process_batch_flushes_after_configured_attempt_count(monkeypatch):
monkeypatch.setattr("photools3.processing.settings.llm_flush_every_photos", 2)
class FakePhoto:
def __init__(self, path):
self.path = path
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, traceback):
return None
response = LlmResponseCaptionsAndKeywords(caption="Ein Haus", tags=["architektur"])
session = MagicMock()
session.call.side_effect = [
response,
RuntimeError("temporary error"),
response,
response,
response,
]
paths = [Path(f"{i}.jpg") for i in range(5)]
with (
patch("photools3.processing._create_session", return_value=session),
patch("photools3.processing.Photo", FakePhoto),
patch("photools3.processing.MetadataWriter"),
):
outcomes = process_batch(paths, ProcessingMode.BOTH)
assert len(outcomes) == len(paths)
assert session.flush_model.call_count == 2
session.close.assert_called_once()