feat(settings): add background model picker with KV cache performance warning

Exposes OLLAMA_BACKGROUND_MODEL as a per-user setting in General settings,
alongside the Chat Model selector. Includes an inline warning when the same
model is selected for both, explaining the KV cache performance impact.

All background task callers (title generation, tag suggestions, project
summaries, RSS classification) now read background_model from user settings,
falling back to OLLAMA_BACKGROUND_MODEL env var.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-03 10:44:08 -04:00
parent fa38978745
commit 3bd0dc6879
6 changed files with 36 additions and 7 deletions
@@ -24,6 +24,7 @@ from fabledassistant.services.generation_buffer import (
)
from fabledassistant.services.llm import ChatChunk, build_context, generate_completion, stream_chat, stream_chat_with_tools, summarize_history_for_context
from fabledassistant.services.chat import update_conversation_title
from fabledassistant.services.settings import get_setting
from fabledassistant.services.logging import log_generation
from fabledassistant.services.tools import get_tools_for_user, execute_tool
from fabledassistant.services.research import run_research_pipeline
@@ -116,7 +117,7 @@ _TOOL_LABELS: dict[str, str] = {
}
async def _generate_title(messages: list[dict], model: str) -> str:
async def _generate_title(messages: list[dict], user_id: int) -> str:
"""Ask the LLM for a concise conversation title."""
# Build conversation text like summarize_conversation_as_note
conv_lines = []
@@ -138,7 +139,8 @@ async def _generate_title(messages: list[dict], model: str) -> str:
},
{"role": "user", "content": "\n\n".join(conv_lines)},
]
title = await generate_completion(prompt_messages, Config.OLLAMA_BACKGROUND_MODEL, max_tokens=30)
bg_model = await get_setting(user_id, "background_model", Config.OLLAMA_BACKGROUND_MODEL)
title = await generate_completion(prompt_messages, bg_model, max_tokens=30)
title = title.strip().strip('"\'').strip()
return title[:100] if title else ""
@@ -483,7 +485,7 @@ async def run_generation(
async def _bg_title() -> None:
try:
title = await _generate_title(title_messages, model)
title = await _generate_title(title_messages, user_id)
if title:
await update_conversation_title(user_id, conv_id, title)
except Exception: