#2557 Put MistralAI prefix under a feature toggle

This commit is contained in:
Cohee 2024-07-27 19:57:40 +03:00
parent 8dd5d9321d
commit 5ad433c576
2 changed files with 8 additions and 1 deletions

View File

@ -93,6 +93,11 @@ openai:
deepl:
# Available options: default, more, less, prefer_more, prefer_less
formality: default
# -- MISTRAL API CONFIGURATION --
mistral:
# Enables prefilling of the reply with the last assistant message in the prompt
# CAUTION: The prefix is echoed into the completion. You may want to use regex to trim it out.
enablePrefix: false
# -- SERVER PLUGIN CONFIGURATION --
enableServerPlugins: false
# User session timeout *in seconds* (defaults to 24 hours).

View File

@ -1,4 +1,5 @@
require('./polyfill.js');
const { getConfigValue } = require('./util.js');
/**
* Convert a prompt from the ChatML objects to the format used by Claude.
@ -373,8 +374,9 @@ function convertMistralMessages(messages, charName = '', userName = '') {
}
// Make the last assistant message a prefill
const prefixEnabled = getConfigValue('mistral.enablePrefix', false);
const lastMsg = messages[messages.length - 1];
if (messages.length > 0 && lastMsg && (lastMsg.role === 'assistant')) {
if (prefixEnabled && messages.length > 0 && lastMsg?.role === 'assistant') {
lastMsg.prefix = true;
}