1- import { GoogleGenerativeAI , system_prompt } from './dist/generative -ai-bundle.js' ;
1+ import { GoogleGenerativeAI , system_prompt } from './dist/geneartive -ai-bundle.js' ;
22
33let genModel = null ;
44
55// Initialize the model
66async function initializeModel ( ) {
77 try {
8- const GEMINI_API_KEY = "AIzaSyARc1EeyqVha3psd2ZSazZNvUYTCC8RuNA" ;
9-
8+ const result = await chrome . storage . sync . get ( [ 'GEMINI_API_KEY' ] ) ;
9+ const GEMINI_API_KEY = result . GEMINI_API_KEY ;
1010 if ( ! GEMINI_API_KEY ) {
1111 throw new Error ( 'API key not found' ) ;
1212 }
13-
1413 const genai = new GoogleGenerativeAI ( GEMINI_API_KEY ) ;
1514 genModel = genai . getGenerativeModel ( {
16- model : "gemini-1.5 -flash" ,
15+ model : "gemini-2.0 -flash-lite-preview-02-05 " ,
1716 systemInstruction : system_prompt
1817 } ) ;
1918 console . log ( "[background.js] Gemini model initialized successfully" ) ;
@@ -68,8 +67,14 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
6867 return true ; // Keep the message channel open for sendResponse
6968 }
7069} ) ;
71- // ... existing code ...
70+
71+
7272
7373// Initialize on install and startup
74- chrome . runtime . onInstalled . addListener ( initializeModel ) ;
75- chrome . runtime . onStartup . addListener ( initializeModel ) ;
74+ chrome . runtime . onStartup . addListener ( initializeModel ) ;
75+
76+ //! store your api key running this permanently in your browser:
77+
78+ // chrome.storage.sync.set({ GEMINI_API_KEY: 'your_api_key_here' }, () => {
79+ // console.log('API key saved to Chrome storage');
80+ // });
0 commit comments