address parsing of product

Google Gemini always wants to return in MarkDown, so let's fix that.
This commit is contained in:
buzz-lightsnack-2007 2024-04-13 21:14:14 +08:00
parent 4e05c31dd0
commit 902da8f8fc

View file

@ -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);