From 071ee6acf2f99327e49e96757b8d3238c918d659 Mon Sep 17 00:00:00 2001 From: mic Date: Sun, 15 Jun 2025 00:37:57 +0200 Subject: [PATCH] Refactor tag extraction in getTagsFromResponse to utilize extractJsonObject for improved JSON parsing. see #365 --- js/mzta-utils-prompt.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/mzta-utils-prompt.js b/js/mzta-utils-prompt.js index 80bb1c96..5271cb87 100644 --- a/js/mzta-utils-prompt.js +++ b/js/mzta-utils-prompt.js @@ -17,6 +17,7 @@ */ import { placeholdersUtils } from './mzta-placeholders.js'; +import { extractJsonObject } from './mzta-utils.js'; export const taPromptUtils = { @@ -97,7 +98,7 @@ export const taPromptUtils = { if(response_text && response_text.length > 0){ try { // Try to parse the response text as JSON - let response_json = JSON.parse(response_text.trim()); + let response_json = extractJsonObject(response_text.trim()); if(response_json && Array.isArray(response_json.tags)){ tags = response_json.tags; } else if(response_json && response_json.tags && typeof response_json.tags === 'string'){