From 1a52314812538a155cb4a8743f5b65cd5ff285d3 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 7 Mar 2025 11:29:14 +0000 Subject: [PATCH] MistalAI: Add custom stop strings Closes #3627 --- public/scripts/openai.js | 1 + src/endpoints/backends/chat-completions.js | 1 + 2 files changed, 2 insertions(+) diff --git a/public/scripts/openai.js b/public/scripts/openai.js index 33dc24978..b79783c05 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -2072,6 +2072,7 @@ async function sendOpenAIRequest(type, messages, signal) { if (isMistral) { generate_data['safe_prompt'] = false; // already defaults to false, but just incase they change that in the future. + generate_data['stop'] = getCustomStoppingStrings(); // Mistral shouldn't have limits on stop strings. } if (isCustom) { diff --git a/src/endpoints/backends/chat-completions.js b/src/endpoints/backends/chat-completions.js index 09e062dfb..7a19257f6 100644 --- a/src/endpoints/backends/chat-completions.js +++ b/src/endpoints/backends/chat-completions.js @@ -586,6 +586,7 @@ async function sendMistralAIRequest(request, response) { 'stream': request.body.stream, 'safe_prompt': request.body.safe_prompt, 'random_seed': request.body.seed === -1 ? undefined : request.body.seed, + 'stop': Array.isArray(request.body.stop) && request.body.stop.length > 0 ? request.body.stop : undefined, }; if (Array.isArray(request.body.tools) && request.body.tools.length > 0) {