feat(P2a): 对话全量入库(Message表:user/assistant/judge+explain,含token用量)+ 提示词放宽(自由对话不强拉)+ 前端带token/kind+开场自由化
这个提交包含在:
+5
-4
@@ -312,7 +312,7 @@ function init(){
|
||||
if(e.key==='Enter' && !e.shiftKey){ e.preventDefault(); sendDialog(); }
|
||||
});
|
||||
// 初始欢迎 + 从后端加载题目(题面/选择题/公式小课堂/进度)
|
||||
addMsg('ai', '<b>👋 fluent-learn 工作台</b>:正在连接后端加载题目…');
|
||||
addMsg('ai', '<b>👋 你好,我是 fluent-learn 的 AI 助手。</b><br>直接打字问我任何问题都可以——学习、概念、方法、闲聊都行;写代码或 LaTeX 会自动切换到对应输入模式,随时提交判题。想聊什么都可以。');
|
||||
loadProblem();
|
||||
loadProgress();
|
||||
loadLatexChips(); // LaTeX 常用公式合集(按学科)
|
||||
@@ -635,7 +635,7 @@ function aiExplain(fromCard){
|
||||
var code=CM.getValue()||LAST_CODE; if(!code){toast('先写代码');return;}
|
||||
if(LAST_RID){
|
||||
addMsg('sys','🔍 已请求 AI 分析上次评测(rid='+LAST_RID+')…');
|
||||
fetch(API_BASE+'/api/chat/explain',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({rid:LAST_RID, mode:MODE==='strict'?'strict':'learning'})})
|
||||
fetch(API_BASE+'/api/chat/explain',{method:'POST',headers:authHeaders({'Content-Type':'application/json'}),body:JSON.stringify({rid:LAST_RID, mode:MODE==='strict'?'strict':'learning'})})
|
||||
.then(function(r){return r.json();}).then(function(d){
|
||||
if(d.reply){ addMsg('ai', mdRender(d.reply)); }
|
||||
else { localExplain(code); }
|
||||
@@ -657,8 +657,9 @@ function localExplain(code){
|
||||
},600);
|
||||
}
|
||||
function aiReply(text){
|
||||
fetch(API_BASE+'/api/chat',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({messages:[{role:'user',content:text}], mode:MODE==='strict'?'strict':'learning', problem_id:CUR_PROBLEM?CUR_PROBLEM.id:null})})
|
||||
var kind = MORPH==='code' ? 'code' : (MORPH==='latex' ? 'latex' : 'text');
|
||||
fetch(API_BASE+'/api/chat',{method:'POST',headers:authHeaders({'Content-Type':'application/json'}),
|
||||
body:JSON.stringify({messages:[{role:'user',content:text}], mode:MODE==='strict'?'strict':'learning', problem_id:CUR_PROBLEM?CUR_PROBLEM.id:null, kind:kind})})
|
||||
.then(function(r){return r.json();}).then(function(d){ if(d.reply) addMsg('ai', mdRender(d.reply)); else localReply(text); })
|
||||
.catch(function(){ localReply(text); });
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户