From 79655633d0a389a10be1e857cd397183bc29548c Mon Sep 17 00:00:00 2001 From: Mathias Scheider Date: Fri, 2 Oct 2026 22:37:27 +0200 Subject: [PATCH] black --- src/photools3/cli.py | 1 + src/photools3/llm_session.py | 56 ++++++++++++++++----------------- src/photools3/models.py | 2 +- test/test_llm_session_mocked.py | 4 ++- 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/src/photools3/cli.py b/src/photools3/cli.py index a5d2020..b6b93f2 100644 --- a/src/photools3/cli.py +++ b/src/photools3/cli.py @@ -69,6 +69,7 @@ def _run_keywords_extraction(file_path: Path) -> Any: photo = Photo(file_path) return session.call([photo]) + def _run_qa(file_path: Path) -> Any: """Handles the core logic of loading the photo and calling the LLM.""" session = LlmSessionQuality() diff --git a/src/photools3/llm_session.py b/src/photools3/llm_session.py index 95bd3ff..76d54fc 100644 --- a/src/photools3/llm_session.py +++ b/src/photools3/llm_session.py @@ -138,38 +138,38 @@ class LlmSessionCaptionsAndKeywords(LlmSession): model_id=model_id, ) + class LlmSessionQuality(LlmSession): def __init__(self, temperature: float = settings.llm_default_temperature): super().__init__( - system_prompt=( - "You are a helpful photographer's assistant that helps to identify " - "photos that can be sorted out due to qulity issues:\n" - "- Your answer is a simple string that must strictly comply with this scheme: " - "'{flag}|{reason}', " - "where {flag} and {reason} are placeholders for possible values " - "that are explained in the following points.\n" - "- {flag} is the general image quality assessment." - "It can have the following values:\n" - " - `not_ok`: photo lacks basic quality and should almost certainly be deleted.\n" - " - `review`: photo has some quality issues, not severe but might be deleted.\n" - " - `ok`: no issues, photo can be kept.\n" - "- {reason} is the reason for the photo being flagged as `not_ok` or `review`. " - "Thus, for any photo that is not `ok`, one or more reasons have to be given. " - "If there is more than one reason, give a comma-separated list: " - "'{flag}|{reason1},{flag}|{reason2},...'. " - "Possible reasons for a lower-than-`ok` assessment are:\n" - " - `blur`: Obviously mis-focussed or motion-blurred.\n" - " - `exposure`: severly under- or over-exposed.\n" - " - `style`: photo has severe style issues (beyond paersonal taste)\n" - ), - temperature=temperature - ) + system_prompt=( + "You are a helpful photographer's assistant that helps to identify " + "photos that can be sorted out due to qulity issues:\n" + "- Your answer is a simple string that must strictly comply with this scheme: " + "'{flag}|{reason}', " + "where {flag} and {reason} are placeholders for possible values " + "that are explained in the following points.\n" + "- {flag} is the general image quality assessment." + "It can have the following values:\n" + " - `not_ok`: photo lacks basic quality and should almost certainly be deleted.\n" + " - `review`: photo has some quality issues, not severe but might be deleted.\n" + " - `ok`: no issues, photo can be kept.\n" + "- {reason} is the reason for the photo being flagged as `not_ok` or `review`. " + "Thus, for any photo that is not `ok`, one or more reasons have to be given. " + "If there is more than one reason, give a comma-separated list: " + "'{flag}|{reason1},{flag}|{reason2},...'. " + "Possible reasons for a lower-than-`ok` assessment are:\n" + " - `blur`: Obviously mis-focussed or motion-blurred.\n" + " - `exposure`: severly under- or over-exposed.\n" + " - `style`: photo has severe style issues (beyond paersonal taste)\n" + ), + temperature=temperature, + ) def call(self, photos: list[Photo], model_id=None): return super().call( - prompt="Assess the quality of the following photos to help me decide which ones to sort out", - photos=photos, - model_id=model_id, - ) - + prompt="Assess the quality of the following photos to help me decide which ones to sort out", + photos=photos, + model_id=model_id, + ) diff --git a/src/photools3/models.py b/src/photools3/models.py index ff158a5..63a0138 100644 --- a/src/photools3/models.py +++ b/src/photools3/models.py @@ -102,7 +102,7 @@ class LlmResponseCaptionsAndKeywords(BaseModel): "A list of keywords that properly tag the photo. " "Allowed keywords: " + str(load_valid_keywords()) - .replace("'", "\"") + .replace("'", '"') .replace("{", "[") .replace("}", "]") ) diff --git a/test/test_llm_session_mocked.py b/test/test_llm_session_mocked.py index b37a58b..c6b9bb0 100644 --- a/test/test_llm_session_mocked.py +++ b/test/test_llm_session_mocked.py @@ -61,7 +61,9 @@ def test_llm_session_captions_and_keywords_mocked(test_photo): mock_choice = MagicMock() mock_message = MagicMock() - mock_message.content = '{"caption": "A mocked caption", "tags": ["architektur"]}' + mock_message.content = ( + '{"caption": "A mocked caption", "tags": ["architektur"]}' + ) mock_choice.message = mock_message mock_response.choices = [mock_choice]