由于gemini兼容了openai格式,因此去除了专门的gemini选项,简化代码

This commit is contained in:
IndieKKY
2025-05-05 23:13:07 +08:00
parent 3ad198948f
commit 2cd633cbd4
11 changed files with 31 additions and 141 deletions

View File

@@ -36,16 +36,3 @@ 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()
}

View File

@@ -1,5 +1,5 @@
import {TASK_EXPIRE_TIME} from '../consts/const'
import {handleChatCompleteTask, handleGeminiChatCompleteTask} from './openaiService'
import {handleChatCompleteTask} from './openaiService'
export const tasksMap = new Map<string, Task>()
@@ -11,9 +11,6 @@ export const handleTask = async (task: Task) => {
case 'chatComplete':
await handleChatCompleteTask(task)
break
case 'geminiChatComplete':
await handleGeminiChatCompleteTask(task)
break
default:
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
throw new Error(`任务类型不支持: ${task.def.type}`)