From 0e8da31b9ad03779aaa7b3a4e9cd3a8fa442a483 Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Sat, 11 May 2024 22:53:21 +0800 Subject: [PATCH] rewrite comment on file to generative part converter --- scripts/AI/gemini.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/AI/gemini.js b/scripts/AI/gemini.js index cf52055..929b9f1 100644 --- a/scripts/AI/gemini.js +++ b/scripts/AI/gemini.js @@ -52,7 +52,7 @@ export default class gemini { PROMPT.push({"text": String(prompt)}); } else if (Array.isArray(prompt)) { while (PROMPT.length < prompt.length) { - if ((typeof prompt[PROMPT.length]).includes(`obj`) && prompt[PROMPT.length] != null && !Array.isArray(prompt[PROMPT.length])) { + if ((typeof prompt[PROMPT.length]).includes(`obj`) && prompt[PROMPT.length] && !Array.isArray(prompt[PROMPT.length])) { PROMPT.push(prompt[PROMPT.length]); } else { PROMPT.push({"text": prompt[PROMPT.length]}); @@ -64,7 +64,13 @@ export default class gemini { REQUEST[`contents`] = []; - // Function below by Google (https://ai.google.dev/tutorials/get_started_web) + /* + Add the blob to a generative part. + + Function below by Google (https://ai.google.dev/tutorials/get_started_web) + @param {Blob} image the image to add + @return {Object} the generative part + */ async function fileToGenerativePart(image) { image = {"blob": image}; image[`type`] = image[`blob`].type;