From f53d937782c3e33676cf98facf5c6485b134c621 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Mon, 1 Jan 2024 18:31:17 +0200 Subject: [PATCH] Fix mistral undefined name --- public/script.js | 2 +- src/endpoints/backends/chat-completions.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/script.js b/public/script.js index 9a478aac7..f7a795083 100644 --- a/public/script.js +++ b/public/script.js @@ -2024,7 +2024,7 @@ function formatGenerationTimer(gen_started, gen_finished, tokenCount) { tokenCount > 0 ? `Token rate: ${Number(tokenCount / seconds).toFixed(1)} t/s` : '', ].join('\n'); - if (isNaN(seconds)) { + if (isNaN(seconds) || seconds < 0) { return { timerValue: '', timerTitle }; } diff --git a/src/endpoints/backends/chat-completions.js b/src/endpoints/backends/chat-completions.js index 712ed4485..6996f5698 100644 --- a/src/endpoints/backends/chat-completions.js +++ b/src/endpoints/backends/chat-completions.js @@ -443,7 +443,7 @@ async function sendMistralAIRequest(request, response) { const messages = Array.isArray(request.body.messages) ? request.body.messages : []; const lastMsg = messages[messages.length - 1]; if (messages.length > 0 && lastMsg && (lastMsg.role === 'system' || lastMsg.role === 'assistant')) { - if (lastMsg.role === 'assistant') { + if (lastMsg.role === 'assistant' && lastMsg.name) { lastMsg.content = lastMsg.name + ': ' + lastMsg.content; } else if (lastMsg.role === 'system') { lastMsg.content = '[INST] ' + lastMsg.content + ' [/INST]';