Mistral: Change tool call id algorithm

This commit is contained in:
Cohee 2024-10-06 20:24:07 +03:00
parent 927c2418e0
commit 4f46a8ff10

View File

@ -1,5 +1,6 @@
require('./polyfill.js'); require('./polyfill.js');
const { getConfigValue } = require('./util.js'); const { getConfigValue } = require('./util.js');
const crypto = require('crypto');
const PROMPT_PLACEHOLDER = getConfigValue('promptPlaceholder', 'Let\'s get started.'); const PROMPT_PLACEHOLDER = getConfigValue('promptPlaceholder', 'Let\'s get started.');
@ -522,7 +523,7 @@ function convertMistralMessages(messages, charName = '', userName = '') {
lastMsg.prefix = true; lastMsg.prefix = true;
} }
const sanitizeToolId = (id) => id.replace(/[^a-zA-Z0-9]/g, '').slice(0, 9); const sanitizeToolId = (id) => crypto.hash('sha512', id, 'base64').slice(0, 9);
// Doesn't support completion names, so prepend if not already done by the frontend (e.g. for group chats). // Doesn't support completion names, so prepend if not already done by the frontend (e.g. for group chats).
messages.forEach(msg => { messages.forEach(msg => {