Use Gemini Pro Vision to support images
This commit is contained in:
		
							parent
							
								
									9ee327c90b
								
							
						
					
					
						commit
						69949096b7
					
				
					 1 changed files with 5 additions and 8 deletions
				
			
		|  | @ -93,22 +93,19 @@ export default class product { | ||||||
| 		if ((this.analysis && this.analysis != null && this.analysis != undefined) ? !((typeof this.analysis).contains(`obj`) && !Array.isArray(this.analysis)) : true) { | 		if ((this.analysis && this.analysis != null && this.analysis != undefined) ? !((typeof this.analysis).contains(`obj`) && !Array.isArray(this.analysis)) : true) { | ||||||
| 			// Analyze the data. 
 | 			// Analyze the data. 
 | ||||||
| 			const gemini = (await import(chrome.runtime.getURL("scripts/AI/gemini.js"))).default; | 			const gemini = (await import(chrome.runtime.getURL("scripts/AI/gemini.js"))).default; | ||||||
| 			let analyzer = new gemini (await secretariat.read([`settings`,`analysis`,`api`,`key`]), `gemini-pro`); | 			let analyzer = new gemini (await secretariat.read([`settings`,`analysis`,`api`,`key`]), `gemini-pro-vision`); | ||||||
| 			 | 			 | ||||||
| 			// Analyze the data. 
 | 			// Analyze the data. 
 | ||||||
| 			let PROMPT = []; | 			let PROMPT = []; | ||||||
| 
 | 
 | ||||||
| 			// Add the "system" prompt. 
 | 			// Add the prompt. 
 | ||||||
| 			PROMPT.push({"text": texts.localized(`AI_message_prompt`)}); | 			PROMPT.push({"text": (texts.localized(`AI_message_prompt`)).concat(JSON.stringify(this.details))}); | ||||||
| 			 | 			 | ||||||
| 			// This is the user prompt. 
 | 			// Run the analysis. 
 | ||||||
| 			PROMPT.push({"text": JSON.stringify(this.details)}); |  | ||||||
| 	 |  | ||||||
| 			// Return the analysis
 |  | ||||||
| 			await analyzer.generate(PROMPT); | 			await analyzer.generate(PROMPT); | ||||||
| 
 | 
 | ||||||
| 			// Remove all markdown formatting. 
 |  | ||||||
| 			if (analyzer.candidate) { | 			if (analyzer.candidate) { | ||||||
|  | 				// Remove all markdown formatting. 
 | ||||||
| 				this.analysis = JSON.parse(analyzer.candidate.replace(/(```json|```|`)/g, '')); | 				this.analysis = JSON.parse(analyzer.candidate.replace(/(```json|```|`)/g, '')); | ||||||
| 			}; | 			}; | ||||||
| 		}; | 		}; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue