Merge reply recovery and simplified consultation UI into ongoing chats

This commit is contained in:
鲨鱼辣椒
2026-09-28 18:05:39 +08:00
37 changed files with 2089 additions and 1940 deletions

View File

@@ -63,12 +63,12 @@ export function teacherHistoryMessages(history: TeacherRequest[]): TeacherSource
text: [...(request.projectId ? ['当时的项目:' + (request.projectName ?? request.projectId)] : []),
...request.references.map(ref => '明确引用:\n' + ref.text), request.text].join('\n\n'),
}]),
{
...(request.replyIncomplete ? [] : [{
id: 'teacher:' + request.id + ':assistant', role: 'assistant' as const,
text: [request.response, ...(request.suggestedQuestions?.length
? ['可以接着聊的问题:\n' + request.suggestedQuestions.map(text => '- ' + text).join('\n')]
: [])].join('\n\n'),
},
}]),
]);
}
// A bounded text estimate for the native model path, not an exact tokenizer or
@@ -113,7 +113,7 @@ export function compileTeacherContext(
const current: TeacherModelMessage = {
role: intent === 'check-in' ? 'system' : 'user',
content: intent === 'check-in'
? '本轮是一次项目进展提醒,不是用户提问。按照已配置的人设和职责,结合来源操作对话中已完成的文字和咨询历史回应,保持简短,不要求用户立即回答。仅依据已有证据,不重复上次提醒,不声称实际运行或试玩过作品。'
? '本轮是一次项目进展提醒,不是用户提问。按照已配置的人设和职责,结合来源操作对话中已完成的文字和咨询历史回应,表达方式遵循已配置的要求,不要求用户立即回答。仅依据已有证据,不重复上次提醒,不声称实际运行或试玩过作品。'
: [
...references.map(
(ref) =>
@@ -123,15 +123,11 @@ export function compileTeacherContext(
ref.text
),
'当前问题:\n' + question,
...(intent === 'suggestions'
...(intent === 'suggestions' || intent === 'guided-help'
? [
'本轮交互要求(仅本轮):依据当前来源操作对话和本咨询历史,邀请学生选择一个可以一起讨论的问题。只返回 JSON 对象 {"intro":string,"questions":string[]},不要附加其他文字。intro 是简短、自然的邀请,不超过 400 字;questions 必须有 2–3 个互不重复、具体贴近当前进展的问题,每个不超过 120 字,用学生自己的口吻表达。问题应符合已配置智能体的职责和当前项目上下文。没有可用上下文时,坦诚说明目前还不了解项目,从学生想做什么、希望谁来用等构思切入;不要编造学生已经完成的功能、作品表现或项目进展,不要生成待办。',
'本轮学生希望你帮忙找到交流起点。依据当前项目、来源操作对话和咨询历史,推荐一个具体切入点,并说明为何值得从这里聊;快捷回复围绕这个切入点帮助学生接话。没有可用上下文时,坦诚从构思切入,不假定学生已完成功能,不编造作品表现或项目进展。',
]
: intent === 'guided-help'
? [
'本轮交互要求(仅本轮):学生暂时说不清想问什么。依据当前来源操作对话和本咨询历史,只发起一个具体、容易回答的交流起点,帮助学生开口。' + (presentationInstructions ? '按本轮界面协议返回,reply使用简短中文,' : '用正常、简短的中文文字回答,不返回 JSON,') + '不列出多个问题或一串任务。没有可用上下文时,坦诚从构思切入,不假定学生已经完成了任何功能。',
]
: []),
: []),
].join('\n\n'),
};
const sourceMessages = source.messages.map(message => ({ ...message }));
@@ -202,7 +198,7 @@ export function compileTeacherContext(
throw new TeacherError(
422,
'teacher_configuration_too_long',
'智能体配置或当前整理内容超过上下文预算,请联系运营调整智能体配置或预算。'
'智能体配置或回复协议超过上下文预算,请联系运营调整智能体配置或预算。'
);
throw new TeacherError(
422,