feat(ai): 新增 AI 模块并集成至备课/错题集/试卷/改题四大业务场景
- 新增 src/modules/ai 独立模块,遵循三层架构(actions → services → shared/lib/ai) - 通过 AiClientProvider + useAiClient 实现 React Context 依赖注入,业务组件零直接 import - 6 个 Server Actions 均调用 requirePermission() 权限校验,返回 ActionState<T> - withAiTracking 统一埋点,覆盖 chat/similar_question/grading_assist/lesson_content/question_variant/weakness_analysis - 集成场景:作业批改 AiGradingAssist、错题集 AiErrorBookAnalysis、备课 AiLessonContentGenerator、试卷 AiQuestionVariantGenerator - 全量 i18n(en/zh-CN ai.json),Error Boundary + Skeleton 边界处理 - 同步架构图 004/005,新增审计报告 ai-module-audit-report.md
This commit is contained in:
109
src/shared/i18n/messages/en/ai.json
Normal file
109
src/shared/i18n/messages/en/ai.json
Normal file
@@ -0,0 +1,109 @@
|
||||
{
|
||||
"chat": {
|
||||
"title": "AI Assistant",
|
||||
"placeholder": "Ask anything...",
|
||||
"inputLabel": "Message input",
|
||||
"send": "Send",
|
||||
"thinking": "AI is thinking...",
|
||||
"maxReached": "Maximum messages reached",
|
||||
"clear": "Clear conversation"
|
||||
},
|
||||
"provider": {
|
||||
"label": "AI Provider",
|
||||
"placeholder": "Select provider",
|
||||
"loading": "Loading providers...",
|
||||
"default": "Default",
|
||||
"description": "Select the AI configuration for this operation.",
|
||||
"manage": "Manage",
|
||||
"manageTitle": "AI Provider Settings",
|
||||
"manageDescription": "Create a new provider or update existing configuration."
|
||||
},
|
||||
"suggestion": {
|
||||
"title": "AI Suggestions",
|
||||
"generate": "Generate Suggestions",
|
||||
"regenerate": "Regenerate",
|
||||
"loading": "AI is thinking...",
|
||||
"empty": "No suggestions available",
|
||||
"error": "Failed to generate suggestions",
|
||||
"loaded": "Suggestions loaded",
|
||||
"selected": "Suggestion selected",
|
||||
"select": "Select",
|
||||
"difficulty": "Difficulty"
|
||||
},
|
||||
"grading": {
|
||||
"title": "AI Grading Suggestion",
|
||||
"suggestedScore": "Suggested Score",
|
||||
"confidence": "Confidence",
|
||||
"feedback": "Feedback",
|
||||
"reasoning": "Reasoning",
|
||||
"applyScore": "Apply Score",
|
||||
"applyFeedback": "Apply Feedback",
|
||||
"loading": "AI is grading...",
|
||||
"error": "AI grading failed",
|
||||
"notAvailable": "AI grading not available for this question type"
|
||||
},
|
||||
"errorBook": {
|
||||
"similarQuestions": "Similar Questions",
|
||||
"weaknessAnalysis": "Weakness Analysis",
|
||||
"studyPlan": "Study Plan",
|
||||
"recommendedResources": "Recommended Resources",
|
||||
"weakAreas": "Weak Areas",
|
||||
"severity": {
|
||||
"high": "High",
|
||||
"medium": "Medium",
|
||||
"low": "Low"
|
||||
}
|
||||
},
|
||||
"lessonPrep": {
|
||||
"generateContent": "Generate Content",
|
||||
"generateActivity": "Suggest Activity",
|
||||
"generateAssessment": "Generate Assessment",
|
||||
"generateQuestion": "Generate Discussion Question",
|
||||
"loading": "Generating...",
|
||||
"error": "Content generation failed"
|
||||
},
|
||||
"exam": {
|
||||
"generate": "Generate",
|
||||
"generating": "Generating...",
|
||||
"preview": "Preview",
|
||||
"queue": "Add to Queue",
|
||||
"queueRunning": "Running",
|
||||
"queueQueued": "Queued",
|
||||
"backgroundTasks": "Background Tasks",
|
||||
"taskStatus": {
|
||||
"queued": "Queued",
|
||||
"running": "Running",
|
||||
"success": "Completed",
|
||||
"failed": "Failed"
|
||||
},
|
||||
"openPreview": "Open Preview",
|
||||
"sourceText": "Source Exam Text",
|
||||
"sourceTextPlaceholder": "Paste the full exam text to parse into questions.",
|
||||
"sourceTextDesc": "AI will extract questions and structure from this text.",
|
||||
"generationTitle": "AI Generation",
|
||||
"generationDesc": "Paste the exam text and generate a structured preview."
|
||||
},
|
||||
"error": {
|
||||
"invalidInput": "Invalid input data",
|
||||
"chatFailed": "AI request failed",
|
||||
"suggestionFailed": "AI suggestion failed",
|
||||
"gradingFailed": "AI grading failed",
|
||||
"contentFailed": "Content generation failed",
|
||||
"variantFailed": "Question variant generation failed",
|
||||
"analysisFailed": "Weakness analysis failed",
|
||||
"boundaryTitle": "AI Feature Error",
|
||||
"boundaryDescription": "An error occurred while processing AI request. Please try again.",
|
||||
"retry": "Retry",
|
||||
"unauthorized": "You do not have permission to use AI features",
|
||||
"providerNotConfigured": "AI provider not configured. Please contact administrator."
|
||||
},
|
||||
"capability": {
|
||||
"chat": "AI Chat",
|
||||
"examGenerate": "AI Exam Generation",
|
||||
"gradingAssist": "AI Grading Assist",
|
||||
"lessonContent": "AI Lesson Content",
|
||||
"questionVariant": "AI Question Variant",
|
||||
"similarQuestion": "AI Similar Questions",
|
||||
"weaknessAnalysis": "AI Weakness Analysis"
|
||||
}
|
||||
}
|
||||
109
src/shared/i18n/messages/zh-CN/ai.json
Normal file
109
src/shared/i18n/messages/zh-CN/ai.json
Normal file
@@ -0,0 +1,109 @@
|
||||
{
|
||||
"chat": {
|
||||
"title": "AI 助手",
|
||||
"placeholder": "请输入您的问题...",
|
||||
"inputLabel": "消息输入",
|
||||
"send": "发送",
|
||||
"thinking": "AI 正在思考...",
|
||||
"maxReached": "已达到最大消息数",
|
||||
"clear": "清空对话"
|
||||
},
|
||||
"provider": {
|
||||
"label": "AI 服务商",
|
||||
"placeholder": "选择服务商",
|
||||
"loading": "加载服务商中...",
|
||||
"default": "默认",
|
||||
"description": "选择本次操作使用的 AI 配置。",
|
||||
"manage": "管理",
|
||||
"manageTitle": "AI 服务商设置",
|
||||
"manageDescription": "新建服务商或更新已有配置。"
|
||||
},
|
||||
"suggestion": {
|
||||
"title": "AI 建议",
|
||||
"generate": "生成建议",
|
||||
"regenerate": "重新生成",
|
||||
"loading": "AI 思考中...",
|
||||
"empty": "暂无建议",
|
||||
"error": "生成建议失败",
|
||||
"loaded": "建议已加载",
|
||||
"selected": "已选择建议",
|
||||
"select": "选择",
|
||||
"difficulty": "难度"
|
||||
},
|
||||
"grading": {
|
||||
"title": "AI 批改建议",
|
||||
"suggestedScore": "建议分数",
|
||||
"confidence": "置信度",
|
||||
"feedback": "反馈",
|
||||
"reasoning": "评分依据",
|
||||
"applyScore": "应用分数",
|
||||
"applyFeedback": "应用反馈",
|
||||
"loading": "AI 批改中...",
|
||||
"error": "AI 批改失败",
|
||||
"notAvailable": "此题型不支持 AI 批改"
|
||||
},
|
||||
"errorBook": {
|
||||
"similarQuestions": "相似题目",
|
||||
"weaknessAnalysis": "薄弱点分析",
|
||||
"studyPlan": "学习计划",
|
||||
"recommendedResources": "推荐资源",
|
||||
"weakAreas": "薄弱领域",
|
||||
"severity": {
|
||||
"high": "高",
|
||||
"medium": "中",
|
||||
"low": "低"
|
||||
}
|
||||
},
|
||||
"lessonPrep": {
|
||||
"generateContent": "生成内容",
|
||||
"generateActivity": "建议活动",
|
||||
"generateAssessment": "生成评估",
|
||||
"generateQuestion": "生成讨论题",
|
||||
"loading": "生成中...",
|
||||
"error": "内容生成失败"
|
||||
},
|
||||
"exam": {
|
||||
"generate": "生成",
|
||||
"generating": "生成中...",
|
||||
"preview": "预览",
|
||||
"queue": "加入队列",
|
||||
"queueRunning": "运行中",
|
||||
"queueQueued": "排队中",
|
||||
"backgroundTasks": "后台任务",
|
||||
"taskStatus": {
|
||||
"queued": "排队中",
|
||||
"running": "生成中",
|
||||
"success": "已完成",
|
||||
"failed": "失败"
|
||||
},
|
||||
"openPreview": "打开预览",
|
||||
"sourceText": "试卷原文",
|
||||
"sourceTextPlaceholder": "粘贴试卷文本以解析为题目",
|
||||
"sourceTextDesc": "AI 将从文本中提取题目和结构。",
|
||||
"generationTitle": "AI 生成",
|
||||
"generationDesc": "粘贴试卷文本并生成结构化预览。"
|
||||
},
|
||||
"error": {
|
||||
"invalidInput": "输入数据无效",
|
||||
"chatFailed": "AI 请求失败",
|
||||
"suggestionFailed": "AI 建议失败",
|
||||
"gradingFailed": "AI 批改失败",
|
||||
"contentFailed": "内容生成失败",
|
||||
"variantFailed": "题目变体生成失败",
|
||||
"analysisFailed": "薄弱点分析失败",
|
||||
"boundaryTitle": "AI 功能错误",
|
||||
"boundaryDescription": "处理 AI 请求时发生错误,请重试。",
|
||||
"retry": "重试",
|
||||
"unauthorized": "您没有使用 AI 功能的权限",
|
||||
"providerNotConfigured": "AI 服务商未配置,请联系管理员。"
|
||||
},
|
||||
"capability": {
|
||||
"chat": "AI 对话",
|
||||
"examGenerate": "AI 出题",
|
||||
"gradingAssist": "AI 辅助批改",
|
||||
"lessonContent": "AI 备课内容",
|
||||
"questionVariant": "AI 题目变体",
|
||||
"similarQuestion": "AI 相似题",
|
||||
"weaknessAnalysis": "AI 薄弱点分析"
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,13 @@ export type EventName =
|
||||
| "homework.submitted"
|
||||
| "homework.graded"
|
||||
| "homework.auto_save_failed"
|
||||
// AI 模块监控事件
|
||||
| "ai.chat"
|
||||
| "ai.similar_question"
|
||||
| "ai.grading_assist"
|
||||
| "ai.lesson_content"
|
||||
| "ai.question_variant"
|
||||
| "ai.weakness_analysis"
|
||||
|
||||
/** 埋点事件负载 */
|
||||
export interface TrackEventPayload {
|
||||
|
||||
Reference in New Issue
Block a user