create product analyzer function
This commit is contained in:
		
							parent
							
								
									33f13a237a
								
							
						
					
					
						commit
						0ae1a831f8
					
				
					 1 changed files with 27 additions and 0 deletions
				
			
		
							
								
								
									
										27
									
								
								scripts/product.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								scripts/product.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -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`); | ||||
| 
 | ||||
| 
 | ||||
| 	} | ||||
| }; | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue