feat: add backup CLI commands, AI correction/modifier services, and timezone-aware date display
DevPlace CI / test (push) Failing after 25m18s
DevPlace CI / test (push) Failing after 25m18s
- Add `devplace backups` CLI subcommands (list, run, prune, clear) with job enqueueing and orphan cleanup - Introduce `BACKUPS_DIR` and `BACKUP_STAGING_DIR` config paths for backup storage - Implement `schedule_correction` and `schedule_modification` calls in content creation, comment creation, and comment editing flows - Add `DEFAULT_CORRECTION_PROMPT` and `DEFAULT_MODIFIER_PROMPT` config constants for AI content processing - Document timezone-aware date display using `local_dt`/`dt_ago` Jinja globals with client-side `Intl` localization - Update README with AI content correction/modifier support in direct messages via `@ai` inline instructions - Add `track_action(user["uid"], "vote")` call on upvote in `apply_vote`
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .spec import Action, Param
|
||||
|
||||
|
||||
def arg(
|
||||
name: str, description: str, required: bool = False, kind: str = "string"
|
||||
) -> Param:
|
||||
return Param(
|
||||
name=name,
|
||||
location="body",
|
||||
description=description,
|
||||
required=required,
|
||||
type=kind,
|
||||
)
|
||||
|
||||
|
||||
AI_MODIFIER_ACTIONS: tuple[Action, ...] = (
|
||||
Action(
|
||||
name="ai_modifier_get",
|
||||
method="LOCAL",
|
||||
path="",
|
||||
summary="Show the user's AI modifier setting and prompt",
|
||||
description=(
|
||||
"Returns whether the AI modifier is enabled for the user and the instruction in use. "
|
||||
"The modifier runs only when authored text contains an inline '@ai <instruction>' "
|
||||
"directive: it executes that instruction and replaces the marked part. Use this before "
|
||||
"changing the setting."
|
||||
),
|
||||
handler="ai_modifier",
|
||||
requires_auth=True,
|
||||
read_only=True,
|
||||
),
|
||||
Action(
|
||||
name="ai_modifier_set",
|
||||
method="LOCAL",
|
||||
path="",
|
||||
summary="Enable or disable the AI modifier and set its prompt",
|
||||
description=(
|
||||
"Turns the AI modifier on or off for the user. When enabled, prose the user authors "
|
||||
"(posts, comments, projects, gists, direct messages, profile bio) is rewritten using the "
|
||||
"supplied instruction and the user's own API key, but ONLY where the text contains an "
|
||||
"inline '@ai <instruction>' directive: that part is executed and the '@ai' marker removed. "
|
||||
"By default the modification runs synchronously (the save waits); pass sync=false to apply "
|
||||
"it in the background just after saving. Pass 'prompt' to change the instruction; omit it to "
|
||||
"keep the current one."
|
||||
),
|
||||
handler="ai_modifier",
|
||||
requires_auth=True,
|
||||
params=(
|
||||
arg(
|
||||
"enabled",
|
||||
"true to enable the AI modifier, false to disable it.",
|
||||
required=True,
|
||||
kind="boolean",
|
||||
),
|
||||
arg(
|
||||
"sync",
|
||||
"true to apply the modification synchronously (the save waits), false for background. "
|
||||
"Omit to keep the current mode.",
|
||||
kind="boolean",
|
||||
),
|
||||
arg(
|
||||
"prompt",
|
||||
"The modifier instruction (max 2000 chars). Omit to keep the current one.",
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
Reference in New Issue
Block a user