trim chat template before hashing

4214c9d8940ac34ee866d87dbb342d39083a8a79

Karl-Johan Alm <karljohan-alm@garage.co.jp>

Signed
1 files changed, +1 -0Ignore whitespace
src/endpoints/backends/text-completions.js+1 -0
@@ -257,6 +257,7 @@ router.post('/chat_template', jsonParser, async function (request, response) {
257 if (apiType === TEXTGEN_TYPES.LLAMACPP && props['chat_template'].endsWith('\u0000')) {257 if (apiType === TEXTGEN_TYPES.LLAMACPP && props['chat_template'].endsWith('\u0000')) {
258 props['chat_template'] = props['chat_template'].slice(0, -1);258 props['chat_template'] = props['chat_template'].slice(0, -1);
259 }259 }
260 props['chat_template'] = props['chat_template'].trim();
260 props['chat_template_hash'] = createHash('sha256').update(props['chat_template']).digest('hex');261 props['chat_template_hash'] = createHash('sha256').update(props['chat_template']).digest('hex');
261 console.log(`We have chat template stuff: ${JSON.stringify(props)}`);262 console.log(`We have chat template stuff: ${JSON.stringify(props)}`);
262 return response.send(props);263 return response.send(props);