}
diff --git a/src/chrome/openaiService.ts b/src/chrome/openaiService.ts
index efda32a..d6b0af1 100644
--- a/src/chrome/openaiService.ts
+++ b/src/chrome/openaiService.ts
@@ -18,3 +18,16 @@ export const handleChatCompleteTask = async (task: Task) => {
throw new Error(`${task.resp.error.code as string??''} ${task.resp.error.message as string ??''}`)
}
}
+
+export const handleGeminiChatCompleteTask = async (task: Task) => {
+ const data = task.def.data
+ const resp = await fetch('https://generativelanguage.googleapis.com/v1/models/gemini-pro:generateContent', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ 'x-goog-api-key': task.def.extra.geminiApiKey,
+ },
+ body: JSON.stringify(data),
+ })
+ task.resp = await resp.json()
+}
diff --git a/src/chrome/taskService.ts b/src/chrome/taskService.ts
index d4c85e4..beb14f0 100644
--- a/src/chrome/taskService.ts
+++ b/src/chrome/taskService.ts
@@ -1,5 +1,5 @@
import {TASK_EXPIRE_TIME} from '../const'
-import {handleChatCompleteTask} from './openaiService'
+import {handleChatCompleteTask, handleGeminiChatCompleteTask} from './openaiService'
export const tasksMap = new Map