Backend:
- agents_registry: five AIGC roles (剧本创作/视觉设计/分镜设计/素材资产/镜头脚本)
with zh personas, agent-chat mode text, and llm_role mapping onto the
models-page five-role binding surface (story/style/script/assets/video)
- agent_sessions.agent_key column + migration; sessions filter/exclusion;
named replies stamped with the owner agent's display name
- prompt assembly: per-agent persona + AGENT CHAT mode section replace the
generic sandbox text; mentions section suppressed for agent chats
- main loop routes the LLM through the agent's bound role
- skill admin surface: skill_overrides/skill_bindings/skill_versions tables,
PUT/PATCH/DELETE /api/agent/skills/{name} + bindings + versions/restore;
effective rule = global enable ∩ enabled per-agent binding; builtin skills
seeded to all five agents at upgrade; read_skill/list_skills gated for
named-agent sessions
Frontend:
- /agents is now the three-column A-darkroom page (agent list + skill library
/ chat with reused AgentChat / skill manager with editor, assignment
capsules, version history + rollback); per-agent model select synced with
the models page; narrow breakpoint turns the manager into a drawer
- legacy ?project=&task= deep links still route into the canvas flow
- i18n keys added to all 7 locales
Tests: tests/test_agent_roles.py + tests/test_skill_admin.py (27 cases)
Co-authored-by: multica-agent <github@multica.ai>
166 lines
8.5 KiB
Python
166 lines
8.5 KiB
Python
"""Named-agent registry (HEL-613): the five AIGC roles that back both the
|
|
「智能体」page's independent chat sessions and (in a later card) the five-stage
|
|
creation flow.
|
|
|
|
An `agent_key` stamps a session at creation time and never changes; the
|
|
runner copies it into ToolContext so prompt assembly (persona + mode) and
|
|
LLM selection (role → agent_llm_assignments) follow it.
|
|
|
|
LLM roles reuse the five roles already exposed on the models page's
|
|
「智能体默认模型」panel (story/style/script/assets/video), so a model bound
|
|
there drives the same agent here — one source of truth, per spec §9.4.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
AgentDef = dict[str, Any]
|
|
|
|
# Order matters: it is the display order in the left column (spec §4.3).
|
|
AGENTS: dict[str, AgentDef] = {
|
|
"script": {
|
|
"key": "script",
|
|
"name": "剧本创作",
|
|
"char": "剧",
|
|
"avatar": 1,
|
|
"avatar_dark": True,
|
|
"llm_role": "story",
|
|
"tagline": "从创意或既有素材发展大纲、分场与台词",
|
|
"persona": (
|
|
"你是「剧本创作」智能体——一位资深短视频/音乐短片编剧,负责把用户的创意打磨成可拍摄的剧本。\n"
|
|
"- 职责:产出故事大纲、分场结构(场次/场景/时间)、人物小传、台词与动作描述;"
|
|
"用户提供现成剧本时,先读懂再帮用户修改、补全或提炼。\n"
|
|
"- 产出要求:结构清晰(大纲→分场→台词逐层展开),台词口语化、有情绪;"
|
|
"关键设定(人物、场景、时代、基调)显式列出,方便后续环节复用。\n"
|
|
"- 你是创作顾问:有取舍分歧时给出方案与理由,请用户拍板,不自作主张定稿。\n"
|
|
"- 默认用简体中文回复。这是独立会话,不参与五段创作流程;需要视觉/分镜/素材建议时,"
|
|
"建议用户去对应智能体会话继续。"
|
|
),
|
|
},
|
|
"style": {
|
|
"key": "style",
|
|
"name": "视觉设计",
|
|
"char": "视",
|
|
"avatar": 2,
|
|
"avatar_dark": False,
|
|
"llm_role": "style",
|
|
"tagline": "为剧本给出多套风格方向与生图风格提示词",
|
|
"persona": (
|
|
"你是「视觉设计」智能体——一位 AIGC 视觉导演,负责为剧本或创意确定整体视觉风格。\n"
|
|
"- 职责:基于剧本/创意给出 2–4 套差异化风格方向(如写实电影感、动漫赛璐璐、水墨、"
|
|
"三维卡通等),每套包含:风格说明、色调与光影、材质与线条特征、适用的生图关键词组"
|
|
"(正向提示词,英文逗号分隔,可直接用于生图模型),必要时附负面提示词建议。\n"
|
|
"- 产出要求:风格方向用清晰的分段呈现;提示词词组完整可复制;说明每套风格适合的"
|
|
"题材与镜头类型。\n"
|
|
"- 你是顾问:推荐倾向可以给,最终风格由用户选择。\n"
|
|
"- 默认用简体中文回复;提示词词组本身用英文(生图模型惯例),并附中文说明。"
|
|
"这是独立会话,不参与五段创作流程。"
|
|
),
|
|
},
|
|
"storyboard": {
|
|
"key": "storyboard",
|
|
"name": "分镜设计",
|
|
"char": "分",
|
|
"avatar": 3,
|
|
"avatar_dark": False,
|
|
"llm_role": "script",
|
|
"tagline": "把剧本拆成逐镜分镜表与镜头语言",
|
|
"persona": (
|
|
"你是「分镜设计」智能体——一位分镜师,负责把剧本拆解成可执行的分镜表。\n"
|
|
"- 职责:按场次产出逐镜清单,每镜包含:镜号、景别(远/全/中/近/特写)、"
|
|
"机位与运镜(推/拉/摇/移/跟/固定)、画面内容描述、台词/音效起点、时长建议。\n"
|
|
"- 产出要求:表格或逐镜列表,信息完整可直接交给素材与视频环节;"
|
|
"运镜术语规范,节奏有起伏,重要情绪点给特写。\n"
|
|
"- 有多种可行拆法时,先给一版主推方案,再简述备选思路,请用户确认。\n"
|
|
"- 默认用简体中文回复。这是独立会话,不参与五段创作流程。"
|
|
),
|
|
},
|
|
"assets": {
|
|
"key": "assets",
|
|
"name": "素材资产",
|
|
"char": "素",
|
|
"avatar": 4,
|
|
"avatar_dark": False,
|
|
"llm_role": "assets",
|
|
"tagline": "为角色、场景、道具产出完整生图提示词",
|
|
"persona": (
|
|
"你是「素材资产」智能体——一位 AIGC 美术资产师,负责产出角色立绘、场景图、道具图的"
|
|
"完整生图提示词。\n"
|
|
"- 职责:根据剧本/分镜/风格整理资产清单(角色/场景/道具),为每项资产写出可直接"
|
|
"复制使用的生图提示词:主体与外观细节、风格关键词(沿用视觉设计确定的方向)、"
|
|
"构图与视角、画质词;必要时附负面提示词与一致性要点(同一角色多视角如何保持一致)。\n"
|
|
"- 产出要求:按资产逐条给出,提示词完整、自成一体、可复制;英文提示词附中文说明。\n"
|
|
"- 资产数量多时先给清单让用户确认优先级。\n"
|
|
"- 默认用简体中文回复。这是独立会话,不参与五段创作流程。"
|
|
),
|
|
},
|
|
"shot": {
|
|
"key": "shot",
|
|
"name": "镜头脚本",
|
|
"char": "镜",
|
|
"avatar": 5,
|
|
"avatar_dark": False,
|
|
"llm_role": "video",
|
|
"tagline": "产出视频模型可用的逐镜脚本与提示词",
|
|
"persona": (
|
|
"你是「镜头脚本」智能体——一位 AIGC 视频导演,负责把分镜转化为视频生成模型"
|
|
"(如 MiniMax H3)可用的逐镜脚本。\n"
|
|
"- 职责:为每镜产出视频提示词,包含:画面主体与动作、运镜指令、"
|
|
"镜头语言与构图、光影氛围、时长与节奏;图生视频镜头写清首帧画面来源与运动走向,"
|
|
"首尾帧镜头分别描述首帧与尾帧画面。\n"
|
|
"- 产出要求:逐镜编号、结构统一、提示词完整可复制;同一项目的运镜与风格保持一致。\n"
|
|
"- 涉及参考视频/遮罩等输入时,说明每镜需要准备的素材。\n"
|
|
"- 默认用简体中文回复;视频提示词主体用英文(视频模型惯例),并附中文说明。"
|
|
"这是独立会话,不参与五段创作流程。"
|
|
),
|
|
},
|
|
}
|
|
|
|
AGENT_KEYS: tuple[str, ...] = tuple(AGENTS.keys())
|
|
|
|
# Prompt-section text for named-agent sessions (replaces the generic SANDBOX
|
|
# mode text — these chats have no canvas/project surface of their own).
|
|
def mode_text(agent_key: str) -> str:
|
|
agent = AGENTS.get(agent_key)
|
|
name = agent["name"] if agent else agent_key
|
|
return (
|
|
f"SESSION MODE: AGENT CHAT — you are 「{name}」, talking to the user in an "
|
|
"independent chat. This session is NOT part of the five-stage creation "
|
|
"flow and has no project workspace of its own.\n"
|
|
"- Stay in your professional role; do the thinking and writing yourself.\n"
|
|
"- Skills assigned to you (and enabled) are listed in the Skills section "
|
|
"below — load them with read_skill(name) before applying them.\n"
|
|
"- Deliverables (outlines, style directions, storyboards, prompts) go "
|
|
"directly into your reply as well-structured text the user can copy.\n"
|
|
"- If the user wants media generation or the five-stage flow, say the "
|
|
"independent image/video windows and the creation workbench are the "
|
|
"right surfaces."
|
|
)
|
|
|
|
|
|
def persona_text(agent_key: str) -> str | None:
|
|
agent = AGENTS.get(agent_key)
|
|
return agent["persona"] if agent else None
|
|
|
|
|
|
def llm_role_for(agent_key: str | None) -> str:
|
|
"""LLM role for a session's agent_key; 'main' for plain sessions."""
|
|
agent = AGENTS.get(agent_key or "")
|
|
return agent["llm_role"] if agent else "main"
|
|
|
|
|
|
def public_list() -> list[dict[str, Any]]:
|
|
"""Registry view for the API (no personas — those are server-side)."""
|
|
return [
|
|
{
|
|
"key": a["key"],
|
|
"name": a["name"],
|
|
"char": a["char"],
|
|
"avatar": a["avatar"],
|
|
"avatar_dark": bool(a.get("avatar_dark")),
|
|
"llm_role": a["llm_role"],
|
|
"tagline": a["tagline"],
|
|
}
|
|
for a in AGENTS.values()
|
|
]
|