Mypy integration #18

Merged
mathias2784 merged 3 commits from mypy-integration into master 2026-10-10 18:37:09 +00:00
3 changed files with 12 additions and 19 deletions
Showing only changes of commit f4b6efe097 - Show all commits
+4
View File
@@ -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"
+7 -18
View File
@@ -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,
)
+1 -1
View File
@@ -22,4 +22,4 @@ class Settings(BaseSettings):
metadata_prefix: str
settings = Settings() # type: ignore[reportCallIssue]
settings = Settings() # type: ignore[call-arg]