Allow Jellyfin tag context in captions

This commit is contained in:
Sleeps
2026-10-06 15:36:11 +01:00
parent 9e5dbc7c8e
commit 6c256f6cf9
+9 -2
View File
@@ -56,8 +56,15 @@ class OllamaCaptioner:
self.max_tokens = max_tokens
self.session = requests.Session()
def caption(self, image_path: Path) -> str:
def caption(self, image_path: Path, context_hint: str | None = None) -> str:
image_b64 = base64.b64encode(image_path.read_bytes()).decode("ascii")
prompt = self.prompt
if context_hint:
prompt = (
f"{prompt}\n\nMetadata context for this video: {context_hint}\n"
"Use this only as a vocabulary/context hint. Do not claim a tagged "
"detail is visible unless it is actually visible in the frame."
)
response = self.session.post(
f"{self.url}/api/chat",
json={
@@ -66,7 +73,7 @@ class OllamaCaptioner:
"messages": [
{
"role": "user",
"content": self.prompt,
"content": prompt,
"images": [image_b64],
}
],