Add user_template to wrap user messages with sender context (name, id, username)
Configure via ai.prompt.user_template in config.json using {text}, {full_name},
{user_id}, {first_name}, {last_name}, {username} placeholders. Applied to both
history user messages and the current prompt. No-op when unset.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -65,6 +65,7 @@ class AIPromptConfig:
|
||||
root: Path
|
||||
system_file: str = "system.md"
|
||||
parts_dir: str = "parts"
|
||||
user_template: str | None = None
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
@@ -234,10 +235,13 @@ def _parse_ai_config(raw_ai: Any, *, root: Path) -> AIConfig | None:
|
||||
prompt_root = Path(str(prompt_raw.get("root", "prompts/ai"))).expanduser()
|
||||
if not prompt_root.is_absolute():
|
||||
prompt_root = (root / prompt_root).resolve()
|
||||
raw_user_template = prompt_raw.get("user_template")
|
||||
user_template = str(raw_user_template).strip() if raw_user_template else None
|
||||
prompt = AIPromptConfig(
|
||||
root=prompt_root,
|
||||
system_file=str(prompt_raw.get("system_file", "system.md")),
|
||||
parts_dir=str(prompt_raw.get("parts_dir", "parts")),
|
||||
user_template=user_template or None,
|
||||
)
|
||||
|
||||
default_model = str(raw_ai.get("default_model", "")).strip()
|
||||
|
||||
Reference in New Issue
Block a user