feat(ai-writing): 各阶段模型调用自动容错,失败时换下一个模型继续
参考多智能体会商的容错思路:意图解析/大纲/正文/审核四个 LLM 环节失败时,按 config.yaml models 顺序换下一个模型重跑该环节, 并通过 model_switch 事件在前端时间线提示「『X』模型<原因>, 已自动切换到『Y』继续」。正文逐章节、审核逐维度独立切换, 已生成的章节/维度保留;意图解析成功的模型还会写回 state 供下游阶段沿用,避免每阶段重复经历同一次失败。 - nodes/_model_fallback.py: 候选模型链 + 异常分类 + model_switch 事件构造(沿用 ROUNDTABLE_MODEL_FALLBACK[_MAX] env 开关) - intent_parser/writer_outline/writer_draft/editor: 失败循环换模型 - 前端 types/reducer/timeline: 新增 model_switch 事件类型,按 stage 复位对应流式缓冲并以 amber 系统提示渲染 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
23743ee193
commit
b59cbd51d9
9 files changed
+598
-144
No files matched your search
@@ -19,6 +19,7 @@ const DISPLAYED_TYPES = new Set([
|
||||
'await_user',
|
||||
'resumed',
|
||||
'notice',
|
||||
'model_switch',
|
||||
'done',
|
||||
'error',
|
||||
]);
|
||||
|
||||
@@ -13,6 +13,7 @@ interface TimelineStepProps {
|
||||
function statusOf(event: ProgressEvent, isLast: boolean): StepStatus {
|
||||
if (event.type === 'error') return 'error';
|
||||
if (event.type === 'notice') return 'warning';
|
||||
if (event.type === 'model_switch') return 'warning';
|
||||
if (event.type === 'await_user') return 'paused';
|
||||
// step_start 只有在列表末尾(后续事件还未到达)时才显示转圈,否则已有后续事件说明该步骤已完成
|
||||
if (event.type === 'step_start') return isLast ? 'running' : 'done';
|
||||
@@ -30,8 +31,11 @@ const AGENT_COLOR: Record<string, string> = {
|
||||
|
||||
export function TimelineStep({ event, isLast, children }: TimelineStepProps) {
|
||||
const status = statusOf(event, isLast ?? true);
|
||||
// notice=非致命告警(如 ES 波动、模型兜底),error=致命错误,两者都展示「标题 + 真实原因」
|
||||
const isAlert = event.type === 'error' || event.type === 'notice';
|
||||
// notice=非致命告警(如 ES 波动、模型兜底),error=致命错误,model_switch=模型自动容错切换(amber 同 notice)
|
||||
const isAlert =
|
||||
event.type === 'error' ||
|
||||
event.type === 'notice' ||
|
||||
event.type === 'model_switch';
|
||||
const isError = event.type === 'error';
|
||||
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user