feat(skills): Scope B A2 — 4 竞品生成器注册表+上下文分派+端点接线
注册表 TOOLBOX +4 entry(continue/expand/de-ai/teardown,全 preview-only writes=[]); ContextStrategy +with_prior_chapter/text_input;ToolGenerateRequest +text 字段。 toolbox_context 分派新策略(续写→build_continuation_context、原文→build_text_input_context); 路由续写经 chapter_repo 读最新 accepted/draft 正文注入 builder(core 不 import apps/api,仿 accept_op)。 预览仅 commit ledger 不写业务表(#3);只声明 tier(#2);system_prompt 进缓存前缀(#9)。 单测:4 生成器 generate 预览 + 续写读前文/草稿路由 + 扩写/降AI text 路由 + 拆书结构化; 更新 registry/strategy 计数测试(15 工具 / 6 策略)。门禁绿:ruff/format/mypy 196 files/pytest 168(api)+32(skills)。
This commit is contained in:
@@ -24,16 +24,20 @@ from ww_shared import AppError, ErrorCode
|
||||
|
||||
from ww_skills.skill_permissions import KNOWN_TABLES
|
||||
|
||||
# 注入策略:决定为该生成器组哪些材料喂给网关(覆盖全部生成器,~4 种)。
|
||||
# 注入策略:决定为该生成器组哪些材料喂给网关(覆盖全部生成器)。
|
||||
# - brief_only:项目立意 + 用户一句话(脑洞/书名);
|
||||
# - with_project:+ 主线/卖点(简介);
|
||||
# - with_world:+ world_entities 卡(名字/金手指/词条——须契合世界观硬规则);
|
||||
# - with_outline_chapter:+ 指定章 outline beats(细纲/黄金开篇)。
|
||||
# - with_outline_chapter:+ 指定章 outline beats(细纲/黄金开篇);
|
||||
# - with_prior_chapter:+ 最新已写正文(续写——端点先读最新 accepted/draft 正文注入);
|
||||
# - text_input:+ 作者提供的原文(扩写/降AI率/拆书样本——经请求 text 字段注入)。
|
||||
ContextStrategy = Literal[
|
||||
"brief_only",
|
||||
"with_project",
|
||||
"with_world",
|
||||
"with_outline_chapter",
|
||||
"with_prior_chapter",
|
||||
"text_input",
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -20,20 +20,28 @@ from ww_agents import (
|
||||
blurb_spec,
|
||||
book_title_spec,
|
||||
brainstorm_spec,
|
||||
continue_spec,
|
||||
de_ai_spec,
|
||||
expand_spec,
|
||||
fine_outline_spec,
|
||||
glossary_spec,
|
||||
golden_finger_spec,
|
||||
name_spec,
|
||||
opening_spec,
|
||||
teardown_spec,
|
||||
)
|
||||
from ww_agents.schemas import (
|
||||
BlurbResult,
|
||||
BookTeardownResult,
|
||||
ContinuationResult,
|
||||
DeAiResult,
|
||||
DetailedOutlineResult,
|
||||
GlossaryResult,
|
||||
GoldenFingerResult,
|
||||
IdeaListResult,
|
||||
NameListResult,
|
||||
OpeningResult,
|
||||
PolishResult,
|
||||
TitleListResult,
|
||||
)
|
||||
|
||||
@@ -61,6 +69,16 @@ def _chapter_no_field() -> InputField:
|
||||
)
|
||||
|
||||
|
||||
# 原文输入(扩写/降AI率/拆书样本所需的大段正文)。
|
||||
_SOURCE_TEXT_FIELD = InputField(
|
||||
name="text",
|
||||
label="原文",
|
||||
type="textarea",
|
||||
required=True,
|
||||
help="待处理的正文/样本片段(扩写/降AI 的原文;拆书的章节样本)",
|
||||
)
|
||||
|
||||
|
||||
# 创作工具箱注册表:key → 描述符。legacy 3 + 新 8 = 11 条。
|
||||
TOOLBOX: dict[str, GeneratorTool] = {
|
||||
# ---- legacy(spec=None,前端走 legacy_route 跳现有页面)----
|
||||
@@ -179,6 +197,62 @@ TOOLBOX: dict[str, GeneratorTool] = {
|
||||
input_fields=[_chapter_no_field(), _BRIEF_FIELD],
|
||||
ingest=IngestSpec(table="outline"),
|
||||
),
|
||||
# ---- 竞品快赢(Scope B):续写 / 扩写 / 降AI率 / 拆书(全 preview-only,writes=[])----
|
||||
"continue": GeneratorTool(
|
||||
key="continue",
|
||||
title="续写生成器",
|
||||
subtitle="承接前文,无缝续写下文",
|
||||
spec=continue_spec,
|
||||
output_schema=ContinuationResult,
|
||||
context_strategy="with_prior_chapter",
|
||||
input_fields=[
|
||||
InputField(
|
||||
name="chapter_no",
|
||||
label="续写章号",
|
||||
type="number",
|
||||
required=False,
|
||||
help="续写的目标章号(读取该章已写正文承接;缺则按设定起笔)",
|
||||
),
|
||||
_BRIEF_FIELD,
|
||||
],
|
||||
),
|
||||
"expand": GeneratorTool(
|
||||
key="expand",
|
||||
title="扩写生成器",
|
||||
subtitle="在原文基础上丰富细节铺陈",
|
||||
spec=expand_spec,
|
||||
output_schema=PolishResult,
|
||||
context_strategy="text_input",
|
||||
input_fields=[_SOURCE_TEXT_FIELD, _BRIEF_FIELD],
|
||||
),
|
||||
"de-ai": GeneratorTool(
|
||||
key="de-ai",
|
||||
title="降 AI 率生成器",
|
||||
subtitle="去机翻腔,更自然的人写质感",
|
||||
spec=de_ai_spec,
|
||||
output_schema=DeAiResult,
|
||||
context_strategy="text_input",
|
||||
input_fields=[_SOURCE_TEXT_FIELD, _BRIEF_FIELD],
|
||||
),
|
||||
"teardown": GeneratorTool(
|
||||
key="teardown",
|
||||
title="拆书生成器",
|
||||
subtitle="拆解主题/原型/结构/钩子套路",
|
||||
spec=teardown_spec,
|
||||
output_schema=BookTeardownResult,
|
||||
context_strategy="text_input",
|
||||
input_fields=[
|
||||
InputField(
|
||||
name="kind",
|
||||
label="书名",
|
||||
type="text",
|
||||
required=False,
|
||||
help="待拆解作品的书名(供拆解对照)",
|
||||
),
|
||||
_SOURCE_TEXT_FIELD,
|
||||
_BRIEF_FIELD,
|
||||
],
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user