mirror of
https://github.com/MrSleeps/jellyfin-scene-search.git
synced 2026-11-14 22:11:27 +00:00
Allow Jellyfin tag context in captions
This commit is contained in:
@@ -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],
|
||||
}
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user