fix: fix using different model

This commit is contained in:
Fred Liang
2023-12-25 05:12:21 +08:00
parent a9d7253143
commit 5c638251f8
3 changed files with 38 additions and 13 deletions

View File

@@ -1,7 +1,7 @@
import { NextRequest, NextResponse } from "next/server";
import { auth } from "../../auth";
import { getServerSideConfig } from "@/app/config/server";
import { GEMINI_BASE_URL, Google } from "@/app/constant";
import { GEMINI_BASE_URL, Google, ModelProvider } from "@/app/constant";
async function handle(
req: NextRequest,
@@ -39,7 +39,7 @@ async function handle(
10 * 60 * 1000,
);
const authResult = auth(req);
const authResult = auth(req, ModelProvider.GeminiPro);
if (authResult.error) {
return NextResponse.json(authResult, {
status: 401,
@@ -50,6 +50,7 @@ async function handle(
const token = bearToken.trim().replaceAll("Bearer ", "").trim();
const key = token ? token : serverConfig.googleApiKey;
if (!key) {
return NextResponse.json(
{
@@ -63,7 +64,6 @@ async function handle(
}
const fetchUrl = `${baseUrl}/${path}?key=${key}`;
const fetchOptions: RequestInit = {
headers: {
"Content-Type": "application/json",