Files
makelore/electron/coding-teacher/reply.ts

24 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import type { TeacherRequest } from '../../shared/coding-teacher';
import { parseTeacherReply } from '../../shared/teacher-reply';
export function teacherReplyInstructions(): string {
return '本轮界面接收一个 JSON 对象 {"reply":string,"quickReplies":string[]}。reply 是回复正文,可使用 Markdown;quickReplies 是可选的后续回复建议,没有建议时用空数组。只使用这两个字段。字符串中的英文双引号、反斜杠和换行必须按 JSON 规则转义,确保整个对象是合法 JSON。依据已配置职责帮助学生整理想法、理解关系、承接已确认的共识;区分学生已确认内容与智能体建议、待定想法。回复的语言、风格、长度、前缀和建议内容遵循当前智能体的云端配置。';
}
/** The original response remains available for diagnosis when parsing is incomplete. */
export function applyTeacherReply(request: TeacherRequest, raw: string): void {
const parsed = parseTeacherReply(raw);
request.response = parsed.reply;
request.suggestedQuestions = parsed.quickReplies;
if (parsed.incomplete) request.replyIncomplete = true;
else delete request.replyIncomplete;
if (parsed.parseError) {
request.replyParseError = parsed.parseError;
} else {
delete request.replyParseError;
delete request.discussionError;
}
if (parsed.parseError || parsed.recovered) request.unparsedResponse = raw;
else delete request.unparsedResponse;
}