From 6cbb98cccd2e24b9c6b68556cb3319f7359aa83a Mon Sep 17 00:00:00 2001 From: arthuridea w <2337583+arthuridea@users.noreply.github.com> Date: Wed, 27 Dec 2023 16:54:34 +0800 Subject: [PATCH] fix:adjust checkbox selection status check. --- src/LLMServiceHub/wwwroot/js/index.js | 2 +- src/LLMServiceHub/wwwroot/js/index.min.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/LLMServiceHub/wwwroot/js/index.js b/src/LLMServiceHub/wwwroot/js/index.js index f92ee3b..8f00097 100644 --- a/src/LLMServiceHub/wwwroot/js/index.js +++ b/src/LLMServiceHub/wwwroot/js/index.js @@ -119,7 +119,7 @@ let sendBtnClickEventHandler = function (e) { console.log(`MODEL: ${key} -> ${availableLLM}`); if (!availableLLM){ - return false; + return; } let rndStr = Math.random().toString(36).slice(-8); let request = conversations[key]; diff --git a/src/LLMServiceHub/wwwroot/js/index.min.js b/src/LLMServiceHub/wwwroot/js/index.min.js index 734c8e8..1198733 100644 --- a/src/LLMServiceHub/wwwroot/js/index.min.js +++ b/src/LLMServiceHub/wwwroot/js/index.min.js @@ -1,4 +1,4 @@ -function dateFormat(n,t){let i;const r={"Y+":t.getFullYear().toString(),"m+":(t.getMonth()+1).toString(),"d+":t.getDate().toString(),"H+":t.getHours().toString(),"M+":t.getMinutes().toString(),"S+":t.getSeconds().toString()};for(let t in r)i=new RegExp("("+t+")").exec(n),i&&(n=n.replace(i[1],i[1].length==1?r[t]:r[t].padStart(i[1].length,"0")));return n}function syncCurrentVal(n,t){$(`#${n}-val`).val(t);conversations.ConvErnieTurbo[n]=parseFloat(t);conversations.ConvErnie3_5[n]=parseFloat(t);conversations.ConvErnie4_0[n]=parseFloat(t);$(".llm-model-config").each(function(n,t){let r=$(t).data("llm-name"),i=conversations[r];$(t).html(`温度:${i.temperature};多样性:${i.top_p};惩罚系数:${i.penalty_score};`)})}function exportBlob(n,t){const u=new Blob([n],{type:"text/plain"}),r=URL.createObjectURL(u),i=document.createElement("a");i.href=r;i.download=t;document.body.appendChild(i);i.click();document.body.removeChild(i);URL.revokeObjectURL(r)}let m_t=.95,m_tp=.8,m_ps=1,conversations={ConvErnieTurbo:{temperature:m_t||.95,top_p:m_tp||.8,penalty_score:m_ps||1,stream:!1,conversation_id:"conv-turbo",message:"",model:2,user_id:"7ffe3194-2bf0-48ba-8dbd-e888d7d556d3"},ConvErnie3_5:{temperature:m_t||.95,top_p:m_tp||.8,penalty_score:m_ps||1,stream:!1,conversation_id:"conv-3_5",message:"",model:1,user_id:"7ffe3194-2bf0-48ba-8dbd-e888d7d556d3"},ConvErnie4_0:{temperature:m_t||.95,top_p:m_tp||.8,penalty_score:m_ps||1,stream:!1,conversation_id:"conv-4_0",message:"",model:3,user_id:"7ffe3194-2bf0-48ba-8dbd-e888d7d556d3"}};$("#r-temperature").val(m_t);$("#temperature-val").val(m_t);$("#r-top_p").val(m_tp);$("#top_p-val").val(m_tp);$("#r-penalty_score").val(m_ps);$("#penalty_score-val").val(m_ps);$(".llm-model-config").html(`温度:${m_t};多样性:${m_tp};惩罚系数:${m_ps};`);$(".llm-range-picker").on("change",function(){let n=$(this),t=$(n).val(),i=$(n).data("sync-key");syncCurrentVal(i,t)});$(".btn-discard-llm-setting").on("click",function(){let i=$(this),n=$(i).data("val"),t=$(i).data("rel-key");console.log(n);console.log(t);$(`#r-${t}`).val(n);syncCurrentVal(t,n)});let sendBtnClickEventHandler=function(n){let t=$("#ipt-message").val();$("#ipt-message").val("");$(Object.keys(conversations)).each(function(n,i){var f=$("#chk-"+i).is(":checked");if(console.log(`MODEL: ${i} -> ${f}`),!f)return!1;let e=Math.random().toString(36).slice(-8),r=conversations[i],o="#wrapper_"+i;r.message=t;r.conversation_id=`${r.conversation_id}_${e}`;let u=$(o);if(u){let s=dateFormat("HH:MM:SS",new Date),n=`rpl_${e}`,f;switch(i){case"ConvErnieTurbo":f="ernie_turbo";break;case"ConvErnie3_5":f="ernie_3_5";break;case"ConvErnie4_0":f="ernie_4_0"}const h=` +function dateFormat(n,t){let i;const r={"Y+":t.getFullYear().toString(),"m+":(t.getMonth()+1).toString(),"d+":t.getDate().toString(),"H+":t.getHours().toString(),"M+":t.getMinutes().toString(),"S+":t.getSeconds().toString()};for(let t in r)i=new RegExp("("+t+")").exec(n),i&&(n=n.replace(i[1],i[1].length==1?r[t]:r[t].padStart(i[1].length,"0")));return n}function syncCurrentVal(n,t){$(`#${n}-val`).val(t);conversations.ConvErnieTurbo[n]=parseFloat(t);conversations.ConvErnie3_5[n]=parseFloat(t);conversations.ConvErnie4_0[n]=parseFloat(t);$(".llm-model-config").each(function(n,t){let r=$(t).data("llm-name"),i=conversations[r];$(t).html(`温度:${i.temperature};多样性:${i.top_p};惩罚系数:${i.penalty_score};`)})}function exportBlob(n,t){const u=new Blob([n],{type:"text/plain"}),r=URL.createObjectURL(u),i=document.createElement("a");i.href=r;i.download=t;document.body.appendChild(i);i.click();document.body.removeChild(i);URL.revokeObjectURL(r)}let m_t=.95,m_tp=.8,m_ps=1,conversations={ConvErnieTurbo:{temperature:m_t||.95,top_p:m_tp||.8,penalty_score:m_ps||1,stream:!1,conversation_id:"conv-turbo",message:"",model:2,user_id:"7ffe3194-2bf0-48ba-8dbd-e888d7d556d3"},ConvErnie3_5:{temperature:m_t||.95,top_p:m_tp||.8,penalty_score:m_ps||1,stream:!1,conversation_id:"conv-3_5",message:"",model:1,user_id:"7ffe3194-2bf0-48ba-8dbd-e888d7d556d3"},ConvErnie4_0:{temperature:m_t||.95,top_p:m_tp||.8,penalty_score:m_ps||1,stream:!1,conversation_id:"conv-4_0",message:"",model:3,user_id:"7ffe3194-2bf0-48ba-8dbd-e888d7d556d3"}};$("#r-temperature").val(m_t);$("#temperature-val").val(m_t);$("#r-top_p").val(m_tp);$("#top_p-val").val(m_tp);$("#r-penalty_score").val(m_ps);$("#penalty_score-val").val(m_ps);$(".llm-model-config").html(`温度:${m_t};多样性:${m_tp};惩罚系数:${m_ps};`);$(".llm-range-picker").on("change",function(){let n=$(this),t=$(n).val(),i=$(n).data("sync-key");syncCurrentVal(i,t)});$(".btn-discard-llm-setting").on("click",function(){let i=$(this),n=$(i).data("val"),t=$(i).data("rel-key");console.log(n);console.log(t);$(`#r-${t}`).val(n);syncCurrentVal(t,n)});let sendBtnClickEventHandler=function(n){let t=$("#ipt-message").val();$("#ipt-message").val("");$(Object.keys(conversations)).each(function(n,i){var f=$("#chk-"+i).is(":checked");if(console.log(`MODEL: ${i} -> ${f}`),f){let e=Math.random().toString(36).slice(-8),r=conversations[i],o="#wrapper_"+i;r.message=t;r.conversation_id=`${r.conversation_id}_${e}`;let u=$(o);if(u){let s=dateFormat("HH:MM:SS",new Date),n=`rpl_${e}`,f;switch(i){case"ConvErnieTurbo":f="ernie_turbo";break;case"ConvErnie3_5":f="ernie_3_5";break;case"ConvErnie4_0":f="ernie_4_0"}const h=`
@@ -39,7 +39,7 @@ function dateFormat(n,t){let i;const r={"Y+":t.getFullYear().toString(),"m+":(t.
- `;$(h).appendTo($(u));$(c).appendTo($(u));let o=$(u).closest(".scrollable"),l=$(o).height();$(o).scrollTop(l);console.log("sending request with:");console.log(r);$.ajax(apiEndpoint,{method:"POST",dataType:"json",contentType:"application/json",data:JSON.stringify(r)}).done(function(t){if(console.log(t),t){$(`#reply_time_${n}`).html(dateFormat("HH:MM:SS",new Date));var i=t.aigc_message;const r=new EasyTyper({output:"",isEnd:!1,speed:20,singleBack:!1,sleep:0,type:"normal",backSpeed:40,sentencePause:!0},marked.parse(i),()=>{},t=>{$("#reply_"+n).html(`${t}`);let i=$(u).closest(".scrollable"),r=$(i).prop("scrollTop")+$("#reply_"+n).height();$(i).scrollTop(r)})}}).fail(function(t){console.log(t);$("#reply_"+n).html("发生错误")})}});n.preventDefault()};$(document).on("keyup",function(n){var t=n||window.event,i=t.which||t.keyCode||t.charCode;i==13&&sendBtnClickEventHandler(n)});$(".btn-send-message").on("click",sendBtnClickEventHandler);$(".btn-export").on("click",function(){let t=dateFormat("YYYYmmddHHMMSS",new Date),r=$(this).closest(".card"),u=$(this).data("key")+"-"+t+".txt",f=$(r).find(".chat-bubble"),n=[];n.push(`--------------${t}------------- + `;$(h).appendTo($(u));$(c).appendTo($(u));let o=$(u).closest(".scrollable"),l=$(o).height();$(o).scrollTop(l);console.log("sending request with:");console.log(r);$.ajax(apiEndpoint,{method:"POST",dataType:"json",contentType:"application/json",data:JSON.stringify(r)}).done(function(t){if(console.log(t),t){$(`#reply_time_${n}`).html(dateFormat("HH:MM:SS",new Date));var i=t.aigc_message;const r=new EasyTyper({output:"",isEnd:!1,speed:20,singleBack:!1,sleep:0,type:"normal",backSpeed:40,sentencePause:!0},marked.parse(i),()=>{},t=>{$("#reply_"+n).html(`${t}`);let i=$(u).closest(".scrollable"),r=$(i).prop("scrollTop")+$("#reply_"+n).height();$(i).scrollTop(r)})}}).fail(function(t){console.log(t);$("#reply_"+n).html("发生错误")})}}});n.preventDefault()};$(document).on("keyup",function(n){var t=n||window.event,i=t.which||t.keyCode||t.charCode;i==13&&sendBtnClickEventHandler(n)});$(".btn-send-message").on("click",sendBtnClickEventHandler);$(".btn-export").on("click",function(){let t=dateFormat("YYYYmmddHHMMSS",new Date),r=$(this).closest(".card"),u=$(this).data("key")+"-"+t+".txt",f=$(r).find(".chat-bubble"),n=[];n.push(`--------------${t}------------- `);$(f).each(function(t,i){let r=$(i).find(".chat-bubble-author").text(),u=$(i).find(".chat-bubble-date").text(),f=$(i).find(".chat-bubble-body").text();n.push(`[${r}] ${u} `);n.push(f.trim());n.push("\r\n-------------------------------\r\n")});let i=n.join("");console.log(i);exportBlob(i,u)}); \ No newline at end of file