diff --git a/dsLightRag/Routes/TeacherHelperRoute.py b/dsLightRag/Routes/TeacherHelperRoute.py
index 7c1ddf62..b40c0fa7 100644
--- a/dsLightRag/Routes/TeacherHelperRoute.py
+++ b/dsLightRag/Routes/TeacherHelperRoute.py
@@ -59,6 +59,16 @@ async def generate_dao_xue_an(request: Request):
# 获取难度参数(默认为"默认难度")
difficulty = params.get("difficulty", "默认难度")
+ # 难度级别中英文映射
+ difficulty_map = {
+ "basic": "基础",
+ "intermediate": "提高",
+ "advanced": "进阶",
+ "默认难度": "默认难度"
+ }
+ # 转换为中文难度名称
+ chinese_difficulty = difficulty_map.get(difficulty, difficulty)
+
# 生成唯一文件名
timestamp = datetime.now().strftime("%Y%m%d%H%M%S")
@@ -68,7 +78,7 @@ async def generate_dao_xue_an(request: Request):
temp_md_path = temp_md.name
# 使用Pandoc转换为Word
- docx_filename = f"导学案_{difficulty}_{timestamp}.docx"
+ docx_filename = f"导学案_{chinese_difficulty}_{timestamp}.docx"
docx_path = os.path.join(save_dir, docx_filename)
try:
diff --git a/dsLightRag/Routes/__pycache__/TeacherHelperRoute.cpython-310.pyc b/dsLightRag/Routes/__pycache__/TeacherHelperRoute.cpython-310.pyc
index ced5b0a3..98bebfe4 100644
Binary files a/dsLightRag/Routes/__pycache__/TeacherHelperRoute.cpython-310.pyc and b/dsLightRag/Routes/__pycache__/TeacherHelperRoute.cpython-310.pyc differ
diff --git a/dsLightRag/static/teacherHelper/index.html b/dsLightRag/static/teacherHelper/index.html
index dfda8f8c..64ea1935 100644
--- a/dsLightRag/static/teacherHelper/index.html
+++ b/dsLightRag/static/teacherHelper/index.html
@@ -466,13 +466,32 @@
userPrompt = `${userPrompt}\n\n${difficultyPrompts[difficulty]}`;
}
- // 发送请求(保持原有代码不变)
+ // 获取难度参数
+ let difficulty = "默认难度";
+ if (resourceType === 'daoXueAn') {
+ const difficultySelector = document.getElementById('daoXueAnDifficulty');
+ difficulty = difficultySelector.querySelector('.difficulty-btn.active').dataset.difficulty;
+ } else if (resourceType === 'zuoYe') {
+ const difficultySelector = document.getElementById('zuoYeDifficulty');
+ difficulty = difficultySelector.querySelector('.difficulty-btn.active').dataset.difficulty;
+ }
+
+ // 构建请求参数
+ const requestData = {
+ resourceType: resourceType,
+ userPrompt: userPrompt,
+ difficulty: difficulty, // 添加此行传递难度参数
+ };
+ // 添加调试日志
+ console.log('请求参数:', requestData);
+ console.log('难度值:', difficulty);
const response = await fetch(`/api/teacher/${resourceType}`, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
system_prompt: systemPrompt,
- user_prompt: userPrompt // 发送拼接后的提示词
+ user_prompt: userPrompt, // 发送拼接后的提示词
+ difficulty:difficulty
})
});
@@ -502,7 +521,9 @@
if (cleanLine.includes('[下载链接]')) {
const url = cleanLine.split('[下载链接]')[1].trim();
- const fileName = `${getResourceName(resourceType)}_${new Date().toLocaleDateString().replace(/\//g, '-')}.docx`;
+ console.log(url);
+ // 从URL中提取文件名(最后一个/后面的部分)
+ const fileName = url.split('/').pop();
resultContainer.innerHTML += `下载${getResourceName(resourceType)}\n`;
shouldHideLoading = true;
} else if (cleanLine.includes('[转换失败]')) {
@@ -527,15 +548,9 @@
}
}
- // 重置状态
- function resetState(loadingElement, generateButton) {
- loadingElement.style.display = 'none';
- generateButton.disabled = false;
- generateButton.classList.remove('btn-disabled');
- generateButton.innerHTML = `生成${getResourceName(resourceType).replace(/^./, c => c.toLowerCase())}`;
- }
+
function showComingSoon() {
- alert("敬请期待");
+ alert("敬请期待");
}