fix: keep teacher runtime prompts within interface boundary
This commit is contained in:
@@ -1,13 +1,21 @@
|
||||
import type { TeacherRequest } from '../../shared/coding-teacher';
|
||||
import { parseTeacherReply } from '../../shared/teacher-reply';
|
||||
|
||||
const MAX_CURRENT_QUICK_REPLIES = 3;
|
||||
|
||||
export function teacherReplyInstructions(): string {
|
||||
return '本轮界面接收一个 JSON 对象 {"reply":string,"quickReplies":string[]}。reply 是回复正文,可使用 Markdown;quickReplies 是可选的后续回复建议,没有建议时用空数组。只使用这两个字段。依据已配置职责帮助学生整理想法、理解关系、承接已确认的共识;区分学生已确认内容与智能体建议、待定想法。回复的语言、风格、长度、前缀和建议内容遵循当前智能体的云端配置。';
|
||||
return `本轮界面接收一个 JSON 对象 {"reply":string,"quickReplies":string[]}。reply 是回复正文,可使用 Markdown;quickReplies 是可选的快捷回复,最多 ${MAX_CURRENT_QUICK_REPLIES} 条,每条为非空字符串,没有快捷回复时用空数组。只使用这两个字段。回复的内容、语言、风格、长度和前缀遵循当前智能体的云端配置。`;
|
||||
}
|
||||
|
||||
/** The original response remains available for diagnosis when parsing is incomplete. */
|
||||
export function applyTeacherReply(request: TeacherRequest, raw: string): void {
|
||||
const parsed = parseTeacherReply(raw);
|
||||
// Apply the current UI contract only to new replies; archived replies keep
|
||||
// their original cards through the compatibility parser and topic store.
|
||||
if (parsed.quickReplies.length > MAX_CURRENT_QUICK_REPLIES) {
|
||||
parsed.quickReplies = [];
|
||||
parsed.parseError ??= '快捷回复超过当前界面最多 3 条的限制,正文已保留,快捷回复未展示。';
|
||||
}
|
||||
request.response = parsed.reply;
|
||||
request.suggestedQuestions = parsed.quickReplies;
|
||||
if (parsed.parseError) {
|
||||
|
||||
Reference in New Issue
Block a user