Skip to content

Commit 7ac7c7b

Browse files
authored
Merge pull request #12 from Saarthakkj/gemini
Gemini integeration
2 parents 37e6ab3 + 98ccd39 commit 7ac7c7b

File tree

14 files changed

+501
-342
lines changed

14 files changed

+501
-342
lines changed

extension/background.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
import { GoogleGenerativeAI, system_prompt } from './dist/generative-ai-bundle.js';
1+
import {GoogleGenerativeAI , system_prompt} from './dist/geneartive-ai-bundle.js';
22

33
let genModel = null;
44

55
// Initialize the model
66
async 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

Comments
 (0)