From 33f13a237a79bd953e85992f1abef558c5b83fdb Mon Sep 17 00:00:00 2001 From: "H. Saw" <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Thu, 11 Apr 2024 06:35:25 +0000 Subject: [PATCH] add API version flag I'm not sure what exactly is the name of that thing (the one with v1beta). --- scripts/AI/gemini.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/AI/gemini.js b/scripts/AI/gemini.js index f933ba7..640edf8 100644 --- a/scripts/AI/gemini.js +++ b/scripts/AI/gemini.js @@ -2,7 +2,8 @@ // Import the file module. // import file from `./net.js`; -class gemini { +// Don't forget to set the class as export default. +export default class gemini { #key; #request; @@ -10,8 +11,9 @@ class gemini { @param {string} key the API key. Remember to not commit your API keys. @param {string} model the model to use + @param {object} version the API and bot version */ - constructor (key, model) { + constructor (key, model, version = {"API": "v1beta"}) { if ((key) ? (((typeof key).includes(`str`)) ? !(key.trim()) : true) : true) { throw new Error(`The API key is required.`); }; @@ -31,7 +33,7 @@ class gemini { this.model[`name`] = ((typeof model).includes(`str`) && model) ? ((model.includes(`models/`)) ? model : `models/`.concat(model)) : 'gemini-pro'; // Set the request location. - this.#request[`location`] = `https://generativelanguage.googleapis.com/v1beta/`.concat(this.model.name); + this.#request[`location`] = `https://generativelanguage.googleapis.com/`.concat(((version != null && !Array.isArray(version) && typeof(version).includes(`obj`)) ? version[`API`] : false) ? version[`API`] : `v1beta`, `/`, this.model.name); }; @@ -178,5 +180,3 @@ class gemini { return(analyze(RESPONSE_RAW)); } }; - -module.exports = gemini;