diff --git a/.gitignore b/.gitignore index a46d914..ef167a0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /bin /gui/styles/external/ /config/config.json +test.js diff --git a/scripts/gemini.js b/scripts/AI/gemini.js similarity index 95% rename from scripts/gemini.js rename to scripts/AI/gemini.js index 6ec48d1..640edf8 100644 --- a/scripts/gemini.js +++ b/scripts/AI/gemini.js @@ -2,6 +2,7 @@ // Import the file module. // import file from `./net.js`; +// Don't forget to set the class as export default. export default class gemini { #key; #request; @@ -10,8 +11,9 @@ export default 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 @@ export default 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); }; diff --git a/scripts/product.js b/scripts/product.js new file mode 100644 index 0000000..7d8b295 --- /dev/null +++ b/scripts/product.js @@ -0,0 +1,27 @@ +/* ask.js +Ask product information to Google Gemini. */ + +// Import the storage management module. +const secretariat = await import(chrome.runtime.getURL("scripts/secretariat.js")); + +// Don't forget to set the class as export default. +class product { + /* Initialize a new product with its details. + + @param {object} details the product details + */ + constructor (details) { + }; + + /* Get the product information. + + @param {object} options the options + @returns {object} the analysis + */ + analyze(options) { + const gemini = (await import('./AI/gemini.js')).default; + let analyzer = new gemini ((typeof(options).includes(`obj`) && !Array.isArray(options) && options != null) ? options[`API Key`] : await secretariat.read([`settings`,`analysis`,`api`,`key`], 1), `gemini-pro`); + + + } +};