Add contextual teacher help entry and simplify consultation panel

This commit is contained in:
鲨鱼辣椒
2026-09-22 16:55:07 +08:00
parent 68e676cb62
commit 12d800ec51
11 changed files with 603 additions and 50 deletions

View File

@@ -3,6 +3,7 @@ import type {
TeacherDefinition,
TeacherReference,
TeacherRequest,
TeacherRequestIntent,
TeacherSourceContext,
} from '../../shared/coding-teacher';
import { TeacherError } from './config-client';
@@ -44,7 +45,8 @@ export function compileTeacherContext(
history: TeacherRequest[],
question: string,
references: TeacherReference[],
maxInputTokens = definition.limits.max_input_tokens
maxInputTokens = definition.limits.max_input_tokens,
intent: TeacherRequestIntent = 'question'
) {
const system: TeacherModelMessage = {
role: 'system',
@@ -69,6 +71,15 @@ export function compileTeacherContext(
ref.text
),
'当前问题:\n' + question,
...(intent === 'suggestions'
? [
'本轮交互要求(仅本轮):依据当前来源操作对话和本咨询历史,邀请学生选择一个可以一起讨论的问题。只返回 JSON 对象 {"intro":string,"questions":string[]},不要附加其他文字。intro 是简短、自然的邀请,不超过 400 字;questions 必须有 2–3 个互不重复、具体贴近当前进展的问题,每个不超过 120 字,用学生自己的口吻表达。问题应帮助学生思考或理解方法,而不是替学生安排待办。没有可用上下文时,坦诚说明目前还不了解项目,从学生想做什么、希望谁来用等构思切入;不要编造学生已经完成的功能、作品表现或项目进展,不要生成待办。',
]
: intent === 'guided-help'
? [
'本轮交互要求(仅本轮):学生暂时说不清想问什么。依据当前来源操作对话和本咨询历史,只发起一个具体、容易回答的交流起点,帮助学生开口。用正常、简短的中文文字回答,不返回 JSON,不列出多个问题或一串任务。没有可用上下文时,坦诚从构思切入,不假定学生已经完成了任何功能。',
]
: []),
].join('\n\n'),
};
const sourceMessages = [...source.messages];
@@ -93,7 +104,15 @@ export function compileTeacherContext(
'\n\n'
),
},
{ role: 'assistant' as const, content: request.response },
{
role: 'assistant' as const,
content: [
request.response,
...(request.suggestedQuestions?.length
? ['可以接着聊的问题:\n' + request.suggestedQuestions.map((text) => '- ' + text).join('\n')]
: []),
].join('\n\n'),
},
]),
current,
];