mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-15 06:23:42 +08:00
Compare commits
4 Commits
dependabot
...
eb50f37f81
Author | SHA1 | Date | |
---|---|---|---|
|
eb50f37f81 | ||
|
ecc65fa775 | ||
|
da9963d4ee | ||
|
24ff78e1c5 |
@@ -22,12 +22,12 @@ English / [简体中文](./README_CN.md)
|
|||||||
[![MacOS][MacOS-image]][download-url]
|
[![MacOS][MacOS-image]][download-url]
|
||||||
[![Linux][Linux-image]][download-url]
|
[![Linux][Linux-image]][download-url]
|
||||||
|
|
||||||
[NextChatAI](https://nextchat.club?utm_source=readme) / [iOS APP](https://apps.apple.com/us/app/nextchat-ai/id6743085599) / [Web App Demo](https://app.nextchat.club) / [Desktop App](https://github.com/Yidadaa/ChatGPT-Next-Web/releases) / [Enterprise Edition](#enterprise-edition)
|
[NextChatAI](https://nextchat.club?utm_source=readme) / [iOS APP](https://apps.apple.com/us/app/nextchat-ai/id6743085599) / [Web App Demo](https://app.nextchat.dev) / [Desktop App](https://github.com/Yidadaa/ChatGPT-Next-Web/releases) / [Enterprise Edition](#enterprise-edition)
|
||||||
|
|
||||||
|
|
||||||
[saas-url]: https://nextchat.club?utm_source=readme
|
[saas-url]: https://nextchat.club?utm_source=readme
|
||||||
[saas-image]: https://img.shields.io/badge/NextChat-Saas-green?logo=microsoftedge
|
[saas-image]: https://img.shields.io/badge/NextChat-Saas-green?logo=microsoftedge
|
||||||
[web-url]: https://app.nextchat.club/
|
[web-url]: https://app.nextchat.dev/
|
||||||
[download-url]: https://github.com/Yidadaa/ChatGPT-Next-Web/releases
|
[download-url]: https://github.com/Yidadaa/ChatGPT-Next-Web/releases
|
||||||
[Web-image]: https://img.shields.io/badge/Web-PWA-orange?logo=microsoftedge
|
[Web-image]: https://img.shields.io/badge/Web-PWA-orange?logo=microsoftedge
|
||||||
[Windows-image]: https://img.shields.io/badge/-Windows-blue?logo=windows
|
[Windows-image]: https://img.shields.io/badge/-Windows-blue?logo=windows
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import { getServerSideConfig } from "../config/server";
|
import { getServerSideConfig } from "../config/server";
|
||||||
import { OPENAI_BASE_URL, ServiceProvider } from "../constant";
|
import { OPENAI_BASE_URL, ServiceProvider, OpenaiPath } from "../constant";
|
||||||
import { cloudflareAIGatewayUrl } from "../utils/cloudflare";
|
import { cloudflareAIGatewayUrl } from "../utils/cloudflare";
|
||||||
import { getModelProvider, isModelNotavailableInServer } from "../utils/model";
|
import { getModelProvider, isModelNotavailableInServer } from "../utils/model";
|
||||||
|
|
||||||
@@ -26,8 +26,8 @@ export async function requestOpenai(req: NextRequest) {
|
|||||||
authValue = req.headers.get("Authorization") ?? "";
|
authValue = req.headers.get("Authorization") ?? "";
|
||||||
authHeaderName = "Authorization";
|
authHeaderName = "Authorization";
|
||||||
}
|
}
|
||||||
|
|
||||||
let path = `${req.nextUrl.pathname}`.replaceAll("/api/openai/", "");
|
let path = `${req.nextUrl.pathname}`.replaceAll("/api/openai/", "");
|
||||||
|
let isChatRequest = path.includes(OpenaiPath.ChatPath);
|
||||||
|
|
||||||
let baseUrl =
|
let baseUrl =
|
||||||
(isAzure ? serverConfig.azureUrl : serverConfig.baseUrl) || OPENAI_BASE_URL;
|
(isAzure ? serverConfig.azureUrl : serverConfig.baseUrl) || OPENAI_BASE_URL;
|
||||||
@@ -117,14 +117,14 @@ export async function requestOpenai(req: NextRequest) {
|
|||||||
const jsonBody = JSON.parse(clonedBody) as { model?: string };
|
const jsonBody = JSON.parse(clonedBody) as { model?: string };
|
||||||
|
|
||||||
// not undefined and is false
|
// not undefined and is false
|
||||||
if (
|
if ( isChatRequest &&
|
||||||
isModelNotavailableInServer(
|
isModelNotavailableInServer(
|
||||||
serverConfig.customModels,
|
serverConfig.customModels,
|
||||||
jsonBody?.model as string,
|
jsonBody?.model as string,
|
||||||
[
|
[
|
||||||
ServiceProvider.OpenAI,
|
ServiceProvider.OpenAI,
|
||||||
ServiceProvider.Azure,
|
ServiceProvider.Azure,
|
||||||
jsonBody?.model as string, // support provider-unspecified model
|
"custom" as string, // support provider-unspecified model
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
@@ -523,15 +523,20 @@ const openaiModels = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const googleModels = [
|
const googleModels = [
|
||||||
|
"gemini-1.0-pro", // Deprecated on 2/15/2025
|
||||||
"gemini-1.5-pro-latest",
|
"gemini-1.5-pro-latest",
|
||||||
"gemini-1.5-pro",
|
"gemini-1.5-pro",
|
||||||
"gemini-1.5-pro-002",
|
"gemini-1.5-pro-002",
|
||||||
|
"gemini-1.5-pro-exp-0827",
|
||||||
"gemini-1.5-flash-latest",
|
"gemini-1.5-flash-latest",
|
||||||
"gemini-1.5-flash-8b-latest",
|
"gemini-1.5-flash-8b-latest",
|
||||||
"gemini-1.5-flash",
|
"gemini-1.5-flash",
|
||||||
"gemini-1.5-flash-8b",
|
"gemini-1.5-flash-8b",
|
||||||
"gemini-1.5-flash-002",
|
"gemini-1.5-flash-002",
|
||||||
|
"gemini-1.5-flash-exp-0827",
|
||||||
"learnlm-1.5-pro-experimental",
|
"learnlm-1.5-pro-experimental",
|
||||||
|
"gemini-exp-1114",
|
||||||
|
"gemini-exp-1121",
|
||||||
"gemini-exp-1206",
|
"gemini-exp-1206",
|
||||||
"gemini-2.0-flash",
|
"gemini-2.0-flash",
|
||||||
"gemini-2.0-flash-exp",
|
"gemini-2.0-flash-exp",
|
||||||
|
@@ -66,8 +66,8 @@ export function collectModelTable(
|
|||||||
|
|
||||||
// default models
|
// default models
|
||||||
models.forEach((m) => {
|
models.forEach((m) => {
|
||||||
// using <modelName>@<providerId> as fullName
|
// using <modelName>@<providerType> as fullName
|
||||||
modelTable[`${m.name}@${m?.provider?.id}`] = {
|
modelTable[`${m.name}@${m?.provider?.providerType}`] = {
|
||||||
...m,
|
...m,
|
||||||
displayName: m.name, // 'provider' is copied over if it exists
|
displayName: m.name, // 'provider' is copied over if it exists
|
||||||
};
|
};
|
||||||
@@ -121,12 +121,14 @@ export function collectModelTable(
|
|||||||
if (displayName && provider.providerName == "ByteDance") {
|
if (displayName && provider.providerName == "ByteDance") {
|
||||||
[customModelName, displayName] = [displayName, customModelName];
|
[customModelName, displayName] = [displayName, customModelName];
|
||||||
}
|
}
|
||||||
modelTable[`${customModelName}@${provider?.id}`] = {
|
modelTable[`${customModelName}@${provider?.providerType}`] = {
|
||||||
name: customModelName,
|
name: customModelName,
|
||||||
displayName: displayName || customModelName,
|
displayName: displayName || customModelName,
|
||||||
available,
|
available,
|
||||||
provider, // Use optional chaining
|
provider, // Use optional chaining
|
||||||
sorted: CustomSeq.next(`${customModelName}@${provider?.id}`),
|
sorted: CustomSeq.next(
|
||||||
|
`${customModelName}@${provider?.providerType}`,
|
||||||
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -83,7 +83,7 @@
|
|||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"jest-environment-jsdom": "^29.7.0",
|
"jest-environment-jsdom": "^29.7.0",
|
||||||
"lint-staged": "^13.2.2",
|
"lint-staged": "^13.2.2",
|
||||||
"prettier": "^3.6.2",
|
"prettier": "^3.0.2",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"tsx": "^4.16.0",
|
"tsx": "^4.16.0",
|
||||||
"typescript": "5.2.2",
|
"typescript": "5.2.2",
|
||||||
|
@@ -53,7 +53,7 @@ describe("isModelNotavailableInServer", () => {
|
|||||||
expect(result).toBe(true);
|
expect(result).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
// FIXME: 这个测试用例有问题,需要修复
|
// FIXME: 这个测试用例有问题,需要修复 ???
|
||||||
// test("support passing multiple providers, model available on one of the providers will return false", () => {
|
// test("support passing multiple providers, model available on one of the providers will return false", () => {
|
||||||
// const customModels = "-all,gpt-4@google";
|
// const customModels = "-all,gpt-4@google";
|
||||||
// const modelName = "gpt-4";
|
// const modelName = "gpt-4";
|
||||||
@@ -69,7 +69,19 @@ describe("isModelNotavailableInServer", () => {
|
|||||||
test("test custom model without setting provider", () => {
|
test("test custom model without setting provider", () => {
|
||||||
const customModels = "-all,mistral-large";
|
const customModels = "-all,mistral-large";
|
||||||
const modelName = "mistral-large";
|
const modelName = "mistral-large";
|
||||||
const providerNames = modelName;
|
const providerNames = "custom";
|
||||||
|
const result = isModelNotavailableInServer(
|
||||||
|
customModels,
|
||||||
|
modelName,
|
||||||
|
providerNames,
|
||||||
|
);
|
||||||
|
expect(result).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("test custom model with non-standard provider", () => {
|
||||||
|
const customModels = "-all,deepseek-chat@DeepSeek";
|
||||||
|
const modelName = "deepseek-chat";
|
||||||
|
const providerNames = "custom";
|
||||||
const result = isModelNotavailableInServer(
|
const result = isModelNotavailableInServer(
|
||||||
customModels,
|
customModels,
|
||||||
modelName,
|
modelName,
|
||||||
|
@@ -7076,10 +7076,10 @@ prettier-linter-helpers@^1.0.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
fast-diff "^1.1.2"
|
fast-diff "^1.1.2"
|
||||||
|
|
||||||
prettier@^3.6.2:
|
prettier@^3.0.2:
|
||||||
version "3.6.2"
|
version "3.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.6.2.tgz#ccda02a1003ebbb2bfda6f83a074978f608b9393"
|
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.0.2.tgz#78fcecd6d870551aa5547437cdae39d4701dca5b"
|
||||||
integrity sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==
|
integrity sha512-o2YR9qtniXvwEZlOKbveKfDQVyqxbEIWn48Z8m3ZJjBjcCmUy3xZGIv+7AkaeuaTr6yPXJjwv07ZWlsWbEy1rQ==
|
||||||
|
|
||||||
pretty-format@^27.0.2:
|
pretty-format@^27.0.2:
|
||||||
version "27.5.1"
|
version "27.5.1"
|
||||||
|
Reference in New Issue
Block a user