From 4214c9d8940ac34ee866d87dbb342d39083a8a79 Mon Sep 17 00:00:00 2001 From: Karl-Johan Alm Date: Wed, 20 Nov 2024 15:12:42 +0900 Subject: [PATCH] trim chat template before hashing --- src/endpoints/backends/text-completions.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/endpoints/backends/text-completions.js b/src/endpoints/backends/text-completions.js index b3bd419e2..d8596e913 100644 --- a/src/endpoints/backends/text-completions.js +++ b/src/endpoints/backends/text-completions.js @@ -257,6 +257,7 @@ router.post('/chat_template', jsonParser, async function (request, response) { if (apiType === TEXTGEN_TYPES.LLAMACPP && props['chat_template'].endsWith('\u0000')) { props['chat_template'] = props['chat_template'].slice(0, -1); } + props['chat_template'] = props['chat_template'].trim(); props['chat_template_hash'] = createHash('sha256').update(props['chat_template']).digest('hex'); console.log(`We have chat template stuff: ${JSON.stringify(props)}`); return response.send(props);