# 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 20000 chars). Omit to keep the current one.",
),
),
),
)