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;