INNER CODE UNIT · Python
_restore_persisted_settings
mouseart2025/AI-Reader-V2 · backend/src/api/main.py:41
async def _restore_persisted_settings() -> None:
"""Restore LLM mode and settings from app_settings on startup."""
from src.db.sqlite_db import get_connection
try:
conn = await get_connection()
try:
settings: dict[str, str] = {}
for key in ("llm_mode", "ollama_default_model", "llm_max_tokens",
"cloud_base_url", "cloud_model"):
row = await conn.execute(
"SELECT value FROM app_settings WHERE key=?", (key,),
)
result = await row.fetchone()
if result and result[0]:
settings[key] = result[0]
finally:
await conn.close()