mirror of
https://github.com/MrSleeps/jellyfin-scene-search.git
synced 2026-11-19 00:03:36 +00:00
Evict alternate Ollama model before each caption queue
This commit is contained in:
@@ -343,6 +343,19 @@ def _route_rows(rows: list, *, verbose: bool = False) -> tuple[list[tuple], int]
|
||||
return routed, missing
|
||||
|
||||
|
||||
def _unload_ollama_model(model: str) -> None:
|
||||
captioner = OllamaCaptioner(
|
||||
settings.ollama_url,
|
||||
model,
|
||||
settings.caption_timeout_seconds,
|
||||
max_tokens=settings.caption_max_tokens,
|
||||
)
|
||||
try:
|
||||
captioner.unload()
|
||||
except Exception as exc:
|
||||
print(f"WARN could not unload {model}: {exc}")
|
||||
|
||||
|
||||
def _caption_queue(
|
||||
label: str,
|
||||
routed_rows: list[tuple],
|
||||
@@ -463,12 +476,17 @@ def cmd_caption(args: argparse.Namespace) -> None:
|
||||
print(f"Specialist prompt: {settings.caption_specialist_prompt_file}")
|
||||
print(f"Ollama: {settings.ollama_url}")
|
||||
|
||||
if general_rows:
|
||||
_unload_ollama_model(settings.caption_specialist_model)
|
||||
general_done, general_failed = _caption_queue(
|
||||
"General queue",
|
||||
general_rows,
|
||||
settings.caption_general_model,
|
||||
general_prompt,
|
||||
)
|
||||
|
||||
if specialist_rows:
|
||||
_unload_ollama_model(settings.caption_general_model)
|
||||
specialist_done, specialist_failed = _caption_queue(
|
||||
"Specialist queue",
|
||||
specialist_rows,
|
||||
|
||||
Reference in New Issue
Block a user