mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-09-27 13:46:37 +08:00
fix: vercel edge function size limit
This commit is contained in:
parent
59dd3213f8
commit
b7e26ba18f
@ -2,7 +2,6 @@ import { getServerSideConfig } from "@/app/config/server";
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import { auth } from "../auth";
|
import { auth } from "../auth";
|
||||||
import { ModelProvider } from "@/app/constant";
|
import { ModelProvider } from "@/app/constant";
|
||||||
import { tavily } from "@tavily/core";
|
|
||||||
|
|
||||||
const serverConfig = getServerSideConfig();
|
const serverConfig = getServerSideConfig();
|
||||||
|
|
||||||
@ -46,12 +45,26 @@ async function handle(req: NextRequest) {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const tvly = tavily({ apiKey: tavilyApiKey });
|
const response = await fetch("https://api.tavily.com/search", {
|
||||||
const response = await tvly.search(query, {
|
method: "POST",
|
||||||
maxResults: maxReturns,
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Authorization: `Bearer ${tavilyApiKey}`,
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
query: query,
|
||||||
|
max_results: maxReturns,
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
return NextResponse.json(response);
|
if (!response.ok) {
|
||||||
|
throw new Error(
|
||||||
|
`Tavily API request failed with status ${response.status}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
return NextResponse.json(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("[Tavily] search error:", error);
|
console.error("[Tavily] search error:", error);
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
|
Loading…
Reference in New Issue
Block a user