diff --git a/dist/main_bun.mjs b/dist/main_bun.mjs index ef6fa8a..094571c 100644 --- a/dist/main_bun.mjs +++ b/dist/main_bun.mjs @@ -84,7 +84,13 @@ function openAiMessageToGeminiMessage(messages) { return result; } function genModel(req) { - const model = ModelMapping[req.model] ?? "gemini-1.0-pro-latest"; + const defaultModel = (m) => { + if (m.startsWith("gemini")) { + return m; + } + return "gemini-1.5-flash-latest"; + }; + const model = ModelMapping[req.model] ?? defaultModel(req.model); let functions = req.tools?.filter((it) => it.type === "function")?.map((it) => it.function) ?? []; functions = functions.concat(req.functions ?? []); const responseMimeType = req.response_format?.type === "json_object" ? "application/json" : "text/plain"; diff --git a/dist/main_cloudflare-workers.mjs b/dist/main_cloudflare-workers.mjs index 1801114..e4b42e5 100644 --- a/dist/main_cloudflare-workers.mjs +++ b/dist/main_cloudflare-workers.mjs @@ -84,7 +84,13 @@ function openAiMessageToGeminiMessage(messages) { return result; } function genModel(req) { - const model = ModelMapping[req.model] ?? "gemini-1.0-pro-latest"; + const defaultModel = (m) => { + if (m.startsWith("gemini")) { + return m; + } + return "gemini-1.5-flash-latest"; + }; + const model = ModelMapping[req.model] ?? defaultModel(req.model); let functions = req.tools?.filter((it) => it.type === "function")?.map((it) => it.function) ?? []; functions = functions.concat(req.functions ?? []); const responseMimeType = req.response_format?.type === "json_object" ? "application/json" : "text/plain"; diff --git a/dist/main_deno.mjs b/dist/main_deno.mjs index 8b12c09..6387336 100644 --- a/dist/main_deno.mjs +++ b/dist/main_deno.mjs @@ -84,7 +84,13 @@ function openAiMessageToGeminiMessage(messages) { return result; } function genModel(req) { - const model = ModelMapping[req.model] ?? "gemini-1.0-pro-latest"; + const defaultModel = (m) => { + if (m.startsWith("gemini")) { + return m; + } + return "gemini-1.5-flash-latest"; + }; + const model = ModelMapping[req.model] ?? defaultModel(req.model); let functions = req.tools?.filter((it) => it.type === "function")?.map((it) => it.function) ?? []; functions = functions.concat(req.functions ?? []); const responseMimeType = req.response_format?.type === "json_object" ? "application/json" : "text/plain"; diff --git a/dist/main_node.mjs b/dist/main_node.mjs index e36e392..59f74e0 100644 --- a/dist/main_node.mjs +++ b/dist/main_node.mjs @@ -524,7 +524,13 @@ function openAiMessageToGeminiMessage(messages) { return result; } function genModel(req) { - const model = ModelMapping[req.model] ?? "gemini-1.0-pro-latest"; + const defaultModel = (m) => { + if (m.startsWith("gemini")) { + return m; + } + return "gemini-1.5-flash-latest"; + }; + const model = ModelMapping[req.model] ?? defaultModel(req.model); let functions = req.tools?.filter((it) => it.type === "function")?.map((it) => it.function) ?? []; functions = functions.concat(req.functions ?? []); const responseMimeType = req.response_format?.type === "json_object" ? "application/json" : "text/plain"; diff --git a/src/utils.ts b/src/utils.ts index 4c39d86..bbaf3f4 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -74,7 +74,14 @@ export function openAiMessageToGeminiMessage(messages: OpenAI.Chat.ChatCompletio } export function genModel(req: OpenAI.Chat.ChatCompletionCreateParams): [GeminiModel, GenerateContentRequest] { - const model: GeminiModel = ModelMapping[req.model] ?? "gemini-1.0-pro-latest" + const defaultModel = (m: string): GeminiModel => { + if (m.startsWith("gemini")) { + return m as GeminiModel + } + return "gemini-1.5-flash-latest" + } + + const model: GeminiModel = ModelMapping[req.model] ?? defaultModel(req.model) let functions: OpenAI.Chat.FunctionObject[] = req.tools?.filter((it) => it.type === "function")?.map((it) => it.function) ?? []