Llm client quality #14

Merged
mathias2784 merged 5 commits from llm-client-quality into master 2026-10-02 21:31:22 +00:00
4 changed files with 33 additions and 30 deletions
Showing only changes of commit 79655633d0 - Show all commits
+1
View File
@@ -69,6 +69,7 @@ def _run_keywords_extraction(file_path: Path) -> Any:
photo = Photo(file_path) photo = Photo(file_path)
return session.call([photo]) return session.call([photo])
def _run_qa(file_path: Path) -> Any: def _run_qa(file_path: Path) -> Any:
"""Handles the core logic of loading the photo and calling the LLM.""" """Handles the core logic of loading the photo and calling the LLM."""
session = LlmSessionQuality() session = LlmSessionQuality()
+2 -2
View File
@@ -138,6 +138,7 @@ class LlmSessionCaptionsAndKeywords(LlmSession):
model_id=model_id, model_id=model_id,
) )
class LlmSessionQuality(LlmSession): class LlmSessionQuality(LlmSession):
def __init__(self, temperature: float = settings.llm_default_temperature): def __init__(self, temperature: float = settings.llm_default_temperature):
@@ -163,7 +164,7 @@ class LlmSessionQuality(LlmSession):
" - `exposure`: severly under- or over-exposed.\n" " - `exposure`: severly under- or over-exposed.\n"
" - `style`: photo has severe style issues (beyond paersonal taste)\n" " - `style`: photo has severe style issues (beyond paersonal taste)\n"
), ),
temperature=temperature temperature=temperature,
) )
def call(self, photos: list[Photo], model_id=None): def call(self, photos: list[Photo], model_id=None):
@@ -172,4 +173,3 @@ class LlmSessionQuality(LlmSession):
photos=photos, photos=photos,
model_id=model_id, model_id=model_id,
) )
+1 -1
View File
@@ -102,7 +102,7 @@ class LlmResponseCaptionsAndKeywords(BaseModel):
"A list of keywords that properly tag the photo. " "A list of keywords that properly tag the photo. "
"Allowed keywords: " "Allowed keywords: "
+ str(load_valid_keywords()) + str(load_valid_keywords())
.replace("'", "\"") .replace("'", '"')
.replace("{", "[") .replace("{", "[")
.replace("}", "]") .replace("}", "]")
) )
+3 -1
View File
@@ -61,7 +61,9 @@ def test_llm_session_captions_and_keywords_mocked(test_photo):
mock_choice = MagicMock() mock_choice = MagicMock()
mock_message = 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_choice.message = mock_message
mock_response.choices = [mock_choice] mock_response.choices = [mock_choice]