mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-01 23:56:39 +08:00
commit
0a6c36441c
@ -91,7 +91,7 @@ async function request(req: NextRequest, apiKey: string) {
|
|||||||
},
|
},
|
||||||
10 * 60 * 1000,
|
10 * 60 * 1000,
|
||||||
);
|
);
|
||||||
const fetchUrl = `${baseUrl}${path}?key=${apiKey}${
|
const fetchUrl = `${baseUrl}${path}${
|
||||||
req?.nextUrl?.searchParams?.get("alt") === "sse" ? "&alt=sse" : ""
|
req?.nextUrl?.searchParams?.get("alt") === "sse" ? "&alt=sse" : ""
|
||||||
}`;
|
}`;
|
||||||
|
|
||||||
@ -100,6 +100,9 @@ async function request(req: NextRequest, apiKey: string) {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"Cache-Control": "no-store",
|
"Cache-Control": "no-store",
|
||||||
|
"x-google-api-key":
|
||||||
|
req.headers.get("x-google-api-key") ||
|
||||||
|
(req.headers.get("Authorization") ?? "").replace("Bearer ", ""),
|
||||||
},
|
},
|
||||||
method: req.method,
|
method: req.method,
|
||||||
body: req.body,
|
body: req.body,
|
||||||
|
@ -276,7 +276,13 @@ export function getHeaders(ignoreHeaders: boolean = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getAuthHeader(): string {
|
function getAuthHeader(): string {
|
||||||
return isAzure ? "api-key" : isAnthropic ? "x-api-key" : "Authorization";
|
return isAzure
|
||||||
|
? "api-key"
|
||||||
|
: isAnthropic
|
||||||
|
? "x-api-key"
|
||||||
|
: isGoogle
|
||||||
|
? "x-goog-api-key"
|
||||||
|
: "Authorization";
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -287,14 +293,15 @@ export function getHeaders(ignoreHeaders: boolean = false) {
|
|||||||
apiKey,
|
apiKey,
|
||||||
isEnabledAccessControl,
|
isEnabledAccessControl,
|
||||||
} = getConfig();
|
} = getConfig();
|
||||||
// when using google api in app, not set auth header
|
|
||||||
if (isGoogle && clientConfig?.isApp) return headers;
|
|
||||||
// when using baidu api in app, not set auth header
|
// when using baidu api in app, not set auth header
|
||||||
if (isBaidu && clientConfig?.isApp) return headers;
|
if (isBaidu && clientConfig?.isApp) return headers;
|
||||||
|
|
||||||
const authHeader = getAuthHeader();
|
const authHeader = getAuthHeader();
|
||||||
|
|
||||||
const bearerToken = getBearerToken(apiKey, isAzure || isAnthropic);
|
const bearerToken = getBearerToken(
|
||||||
|
apiKey,
|
||||||
|
isAzure || isAnthropic || isGoogle,
|
||||||
|
);
|
||||||
|
|
||||||
if (bearerToken) {
|
if (bearerToken) {
|
||||||
headers[authHeader] = bearerToken;
|
headers[authHeader] = bearerToken;
|
||||||
|
@ -48,10 +48,6 @@ export class GeminiProApi implements LLMApi {
|
|||||||
let chatPath = [baseUrl, path].join("/");
|
let chatPath = [baseUrl, path].join("/");
|
||||||
|
|
||||||
chatPath += chatPath.includes("?") ? "&alt=sse" : "?alt=sse";
|
chatPath += chatPath.includes("?") ? "&alt=sse" : "?alt=sse";
|
||||||
// if chatPath.startsWith('http') then add key in query string
|
|
||||||
if (chatPath.startsWith("http") && accessStore.googleApiKey) {
|
|
||||||
chatPath += `&key=${accessStore.googleApiKey}`;
|
|
||||||
}
|
|
||||||
return chatPath;
|
return chatPath;
|
||||||
}
|
}
|
||||||
extractMessage(res: any) {
|
extractMessage(res: any) {
|
||||||
|
29
start.sh
29
start.sh
@ -1,18 +1,18 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
## 加速
|
# 加速
|
||||||
#yarn config set registry 'https://registry.npmmirror.com/'
|
yarn config set registry 'https://registry.npmmirror.com/'
|
||||||
#yarn config set sharp_binary_host "https://npm.taobao.org/mirrors/sharp"
|
yarn config set sharp_binary_host "https://npm.taobao.org/mirrors/sharp"
|
||||||
#yarn config set sharp_libvips_binary_host "https://npm.taobao.org/mirrors/sharp-libvips"
|
yarn config set sharp_libvips_binary_host "https://npm.taobao.org/mirrors/sharp-libvips"
|
||||||
## 官方
|
## 官方
|
||||||
##yarn config delete registry
|
##yarn config delete registry
|
||||||
##yarn config delete sharp_binary_host
|
##yarn config delete sharp_binary_host
|
||||||
##yarn config delete sharp_libvips_binary_host
|
##yarn config delete sharp_libvips_binary_host
|
||||||
#
|
#
|
||||||
#yarn cache clean
|
#yarn cache clean
|
||||||
#yarn install
|
yarn install
|
||||||
#
|
#
|
||||||
#yarn run build
|
yarn run build
|
||||||
#
|
#
|
||||||
#mkdir -p "./node_modules/tiktoken"
|
#mkdir -p "./node_modules/tiktoken"
|
||||||
#export OUT_DIR="out"
|
#export OUT_DIR="out"
|
||||||
@ -27,12 +27,11 @@ set -e
|
|||||||
|
|
||||||
#docker network ls | grep -qw chatgpt-ns || docker network create chatgpt-ns
|
#docker network ls | grep -qw chatgpt-ns || docker network create chatgpt-ns
|
||||||
|
|
||||||
# 检查构建器是否已存在
|
## 检查构建器是否已存在
|
||||||
if ! docker buildx inspect mybuilder &> /dev/null; then
|
#if ! docker buildx inspect mybuilder &> /dev/null; then
|
||||||
docker buildx create --use --name=mybuilder
|
# docker buildx create --use --name=mybuilder
|
||||||
fi
|
#fi
|
||||||
#docker buildx build --platform linux/amd64 -t registry.cn-hangzhou.aliyuncs.com/si-private/chatgpt-next-web:temp -f Dockerfile.linux-build --load .
|
#docker buildx build --platform linux/amd64 -t registry.cn-hangzhou.aliyuncs.com/si-private/chatgpt-next-web:temp -f Dockerfile --load .
|
||||||
docker buildx build --platform linux/amd64 -t registry.cn-hangzhou.aliyuncs.com/si-private/chatgpt-next-web:temp -f Dockerfile --load .
|
#
|
||||||
|
#docker tag registry.cn-hangzhou.aliyuncs.com/si-private/chatgpt-next-web:temp registry.cn-hangzhou.aliyuncs.com/si-private/chatgpt-next-web:latest
|
||||||
docker tag registry.cn-hangzhou.aliyuncs.com/si-private/chatgpt-next-web:temp registry.cn-hangzhou.aliyuncs.com/si-private/chatgpt-next-web:latest
|
#docker tag registry.cn-hangzhou.aliyuncs.com/si-private/chatgpt-next-web:temp registry.cn-hangzhou.aliyuncs.com/si-private/chatgpt-next-web:test
|
||||||
docker tag registry.cn-hangzhou.aliyuncs.com/si-private/chatgpt-next-web:temp registry.cn-hangzhou.aliyuncs.com/si-private/chatgpt-next-web:test
|
|
||||||
|
Loading…
Reference in New Issue
Block a user