Make AI model configurable per feature, and split news grading/formatting models

Every AI-calling feature (content correction, the @ai modifier, quiz grading,
SEO metadata generation, the AI Usage Analyzer, and DeepSearch) can now name
its own model via admin-editable configuration, defaulting to the gateway's
default model when left blank. The gateway a feature talks to stays fixed to
the internal endpoint either way, only the model name is a knob, so the best
model can be picked per task.

Also splits the news service's shared AI grading/formatting config into two
independent endpoint/model/key pairs: reformatting no longer requires
repointing (and thereby breaking) the free, scoring-only grading model.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FZ5x6KZTxZjbJqsEkxGbxG
This commit is contained in:
2026-09-03 08:47:57 +02:00
co-authored by Claude Sonnet 5
parent 81d6aa68b6
commit 8ae3f628c7
22 changed files with 211 additions and 52 deletions
+13 -1
View File
@@ -9,7 +9,8 @@ import shutil
import sys
from pathlib import Path
from devplacepy.config import BASE_DIR, DEEPSEARCH_DIR
from devplacepy.config import BASE_DIR, DEEPSEARCH_DIR, INTERNAL_MODEL
from devplacepy.services.base import ConfigField
from devplacepy.services.deepsearch.store import VectorStore
from devplacepy.services.jobs.base import JobService
@@ -33,6 +34,16 @@ class DeepsearchService(JobService):
def __init__(self):
super().__init__(name="deepsearch", interval_seconds=2)
self.config_fields = list(self.config_fields) + [
ConfigField(
"deepsearch_model",
"AI model",
type="str",
default="",
help="Model sent to the internal AI gateway for query planning and report synthesis. Blank uses the gateway default model.",
group="DeepSearch",
),
]
def session_dir(self, uid: str) -> Path:
return DEEPSEARCH_DIR / uid
@@ -53,6 +64,7 @@ class DeepsearchService(JobService):
json.dumps({"state": "running"}), encoding="utf-8"
)
payload["collection"] = self.collection_name(uid)
payload["model"] = self.get_config()["deepsearch_model"] or INTERNAL_MODEL
payload["cached_hashes"] = self._cached_hashes(database)
payload_path = output_dir / "payload.json"
payload_path.write_text(json.dumps(payload), encoding="utf-8")