From ef137f68c4dfa3a3b975d1853c3b3cc283b60751 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sat, 25 May 2024 17:32:11 +0300 Subject: [PATCH] Fallback to Fuse if not parsed expression --- public/scripts/extensions/expressions/index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/public/scripts/extensions/expressions/index.js b/public/scripts/extensions/expressions/index.js index 508cfc6f4..7b405d2b7 100644 --- a/public/scripts/extensions/expressions/index.js +++ b/public/scripts/extensions/expressions/index.js @@ -1020,14 +1020,13 @@ async function getLlmPrompt(labels) { * @returns {string} The parsed emotion or the fallback expression. */ function parseLlmResponse(emotionResponse, labels) { - const fallbackExpression = getFallbackExpression(); - try { const parsedEmotion = JSON.parse(emotionResponse); const response = parsedEmotion?.emotion?.trim()?.toLowerCase(); if (!response || !labels.includes(response)) { - return fallbackExpression; + console.debug(`Parsed emotion response: ${response} not in labels: ${labels}`); + throw new Error('Emotion not in labels'); } return response;