From 4f46a8ff10ae68a65742415304036267ea129e15 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sun, 6 Oct 2024 20:24:07 +0300 Subject: [PATCH] Mistral: Change tool call id algorithm --- src/prompt-converters.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/prompt-converters.js b/src/prompt-converters.js index fe9f8e88f..0d1412301 100644 --- a/src/prompt-converters.js +++ b/src/prompt-converters.js @@ -1,5 +1,6 @@ require('./polyfill.js'); const { getConfigValue } = require('./util.js'); +const crypto = require('crypto'); const PROMPT_PLACEHOLDER = getConfigValue('promptPlaceholder', 'Let\'s get started.'); @@ -522,7 +523,7 @@ function convertMistralMessages(messages, charName = '', userName = '') { 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). messages.forEach(msg => {