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