From 902da8f8fc0822678480562296c066730567c27c Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Sat, 13 Apr 2024 21:14:14 +0800 Subject: [PATCH] address parsing of product Google Gemini always wants to return in MarkDown, so let's fix that. --- scripts/product.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/product.js b/scripts/product.js index e62933c..742b1c4 100644 --- a/scripts/product.js +++ b/scripts/product.js @@ -105,7 +105,12 @@ export default class product { PROMPT.push({"text": JSON.stringify(this.details)}); // Return the analysis - this.analysis = JSON.stringify(await analyzer.generate(PROMPT)); + await analyzer.generate(PROMPT); + + // Remove all markdown formatting. + if (analyzer.candidate) { + this.analysis = JSON.parse(analyzer.candidate.replace(/(```json|```|`)/g, '')); + }; }; return(this.analysis);