diff --git a/pyproject.toml b/pyproject.toml index cb5a7c8..80ade47 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,10 @@ utils = { index = "gitea" } [tool.black] target-version = [ "py314" ] +[[tool.mypy.overrides]] +module = ["exiftool", "exiftool.*", "utils", "utils.*"] +ignore_missing_imports = true + [[tool.uv.index]] name = "gitea" url = "https://gitea.schneiderserver.site/api/packages/mathias2784/pypi/simple" diff --git a/src/photools3/llm_session.py b/src/photools3/llm_session.py index 430e2c4..7f16e27 100644 --- a/src/photools3/llm_session.py +++ b/src/photools3/llm_session.py @@ -4,7 +4,7 @@ import re import openai from openai import OpenAI -from pydantic import ValidationError +from pydantic import BaseModel, ValidationError from photools3.models import ( LlmMessageContent, @@ -25,7 +25,8 @@ logger = logging.getLogger(__name__) class LlmSession: base_url: str = str(settings.llm_api_base_url) api_key: str = settings.llm_api_key - response_model = LlmResponseGeneral + response_model: type[BaseModel] = LlmResponseGeneral + prompt: str = "" def __init__( self, system_prompt: str, temperature: float = settings.llm_default_temperature @@ -59,15 +60,15 @@ class LlmSession: def call( self, - prompt: str, photos: list[Photo], model_id=None, max_retries: int = 2, + prompt: str | None = None, ): if not model_id: model_id = self.models[0].id - request = self._build_request(prompt, photos, model_id) + request = self._build_request(prompt or self.prompt, photos, model_id) last_error = None for attempt in range(max_retries + 1): @@ -147,6 +148,7 @@ class LlmSession: class LlmSessionCaptionsAndKeywords(LlmSession): response_model = LlmResponseCaptionsAndKeywords + prompt = "Give me a caption and keyword for the following photo(s)" def __init__(self, temperature: float = settings.llm_default_temperature): super().__init__( @@ -159,16 +161,10 @@ class LlmSessionCaptionsAndKeywords(LlmSession): temperature=temperature, ) - def call(self, photos: list[Photo], model_id=None): - return super().call( - prompt="Give me a caption and keyword for the following photo(s)", - photos=photos, - model_id=model_id, - ) - class LlmSessionQuality(LlmSession): response_model = LlmResponseQuality + prompt = "Assess the quality of the following photos to help me decide which ones to sort out" def __init__(self, temperature: float = settings.llm_default_temperature): super().__init__( @@ -180,10 +176,3 @@ class LlmSessionQuality(LlmSession): ), 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, - ) diff --git a/src/photools3/settings.py b/src/photools3/settings.py index 22d65cb..2ceae41 100644 --- a/src/photools3/settings.py +++ b/src/photools3/settings.py @@ -22,4 +22,4 @@ class Settings(BaseSettings): metadata_prefix: str -settings = Settings() # type: ignore[reportCallIssue] +settings = Settings() # type: ignore[call-arg]