Add per-service system prompts with AI Settings tab view

Each feature service owns its system prompt in its config JSON on the
shared volume. The AI Settings page now has General and System Prompts
tabs — admins can view and edit any service's prompts at runtime with
changes taking effect within 30 s (config cache TTL).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
curo1305
2026-04-17 15:11:40 +02:00
parent 3a501f7e05
commit 1d01cc3b0e
9 changed files with 522 additions and 146 deletions
+12 -3
View File
@@ -4,7 +4,11 @@ import json
import httpx
from app.core.config import settings
from app.services.prompts import SYSTEM_PROMPT, USER_PROMPT_TEMPLATE
from app.services.config_reader import (
_DEFAULT_SYSTEM_PROMPT,
_DEFAULT_USER_TEMPLATE,
load_doc_config,
)
_client = httpx.AsyncClient(timeout=120.0)
@@ -19,9 +23,14 @@ async def classify_document(text: str) -> dict:
Returns the parsed JSON result dict.
Raises AIServiceError on HTTP errors or unexpected response shapes.
"""
config = await load_doc_config()
prompts = config.get("system_prompts", {})
system_prompt = prompts.get("system") or _DEFAULT_SYSTEM_PROMPT
user_template = prompts.get("user_template") or _DEFAULT_USER_TEMPLATE
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": USER_PROMPT_TEMPLATE.format(text=text[:50_000])},
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_template.format(text=text[:50_000])},
]
try: