Compare commits

..

26 Commits

Author SHA1 Message Date
Q.A.zh
3d4c545f37 Merge 69fcb92a3b into c30ddfbb07 2025-06-12 19:58:45 +08:00
RiverRay
c30ddfbb07 Merge pull request #6425 from yunlingz/o_model_md_response
Some checks failed
Run Tests / test (push) Has been cancelled
Fix: Encourage markdown inclusion in model responses for o1/o3
2025-06-12 11:19:24 +08:00
RiverRay
a2f0149786 Merge pull request #6460 from dreamsafari/main
加入Grok3模型列表
2025-06-12 11:13:31 +08:00
GH Action - Upstream Sync
03d36f96ed Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web 2025-06-12 01:53:30 +00:00
RiverRay
705dffc664 Merge pull request #6514 from KevinShiCN/patch-1
Some checks failed
Run Tests / test (push) Has been cancelled
Add gemini-2.5-pro-preview-06-05 into constant.ts
2025-06-11 16:14:09 +08:00
KevinShiCN
02f7e6de98 Add gemini-2.5-pro-preview-06-05 into constant.ts 2025-06-08 23:59:49 +08:00
dreamsafari
843dc52efa 加入Grok3模型列表 2025-04-22 13:06:54 +08:00
RiverRay
3809375694 Merge pull request #6457 from ACTOR-ALCHEMIST/main
Some checks failed
Run Tests / test (push) Has been cancelled
Support OpenAI o3 and o4-mini
2025-04-19 16:00:41 +08:00
RiverRay
1b0de25986 Update README.md 2025-04-19 15:59:31 +08:00
RiverRay
865c45dd29 Update README.md 2025-04-19 15:56:53 +08:00
RiverRay
1f5d8e6d9c Merge pull request #6458 from ChatGPTNextWeb/Leizhenpeng-patch-7
Update README.md
2025-04-19 15:50:48 +08:00
RiverRay
c9ef6d58ed Update README.md 2025-04-19 15:50:17 +08:00
Jasper Hu
2d7229d2b8 feat: 支持 OpenAI 新模型 o3 与 o4-mini,并适配新参数 2025-04-18 20:36:07 +01:00
RiverRay
11b37c15bd Merge pull request #6450 from stephen-zeng/main
Some checks failed
Run Tests / test (push) Has been cancelled
Add gpt-4.1 family & gpt-4.5-preview support
2025-04-17 08:29:19 +08:00
QwQwQ
1d0038f17d add gpt-4.5-preview support 2025-04-16 22:10:47 +08:00
QwQwQ
619fa519c0 add gpt-4.1 family support 2025-04-16 22:02:35 +08:00
Yunling Zhu
c261ebc82c use unshift to improve perf 2025-04-06 16:56:54 +08:00
Yunling Zhu
f7c747c65f encourage markdown inclusion for o1/o3 2025-04-03 22:11:59 +08:00
RiverRay
48469bd8ca Merge pull request #6392 from ChatGPTNextWeb/Leizhenpeng-patch-6
Some checks failed
Run Tests / test (push) Has been cancelled
Update README.md
2025-03-20 17:52:02 +08:00
Q.A.zh
69fcb92a3b 移除空格,增加custom_models 容错性 2024-12-30 02:54:15 +00:00
Q.A.zh
3b5b496599 modify test comment 2024-12-28 15:53:35 +00:00
Q.A.zh
2db4caace4 fix model name 2024-12-28 15:43:27 +00:00
Q.A.zh
fd8ad63655 fix error model name 2024-12-28 15:38:01 +00:00
Q.A.zh
c41c2b538a Remove the empty array slot 2024-12-28 09:14:27 +00:00
Q.A.zh
4d6c82deb9 add collectModelTable unit test 2024-12-28 09:09:41 +00:00
Q.A.zh
b09f458aeb Introducing the ability to remove specified Providers. 2024-12-28 04:17:22 +00:00
5 changed files with 209 additions and 12 deletions

View File

@@ -22,7 +22,7 @@ English / [简体中文](./README_CN.md)
[![MacOS][MacOS-image]][download-url]
[![Linux][Linux-image]][download-url]
[NextChatAI](https://nextchat.club?utm_source=readme) / [Web App Demo](https://app.nextchat.dev) / [Desktop App](https://github.com/Yidadaa/ChatGPT-Next-Web/releases) / [Discord](https://discord.gg/YCkeafCafC) / [Enterprise Edition](#enterprise-edition) / [Twitter](https://twitter.com/NextChatDev)
[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
@@ -40,13 +40,14 @@ English / [简体中文](./README_CN.md)
</div>
## 🥳 Cheer for DeepSeek, China's AI star!
> Purpose-Built UI for DeepSeek Reasoner Model
## 🥳 Cheer for NextChat iOS Version Online!
> [👉 Click Here to Install Now](https://apps.apple.com/us/app/nextchat-ai/id6743085599)
> [❤️ Source Code Coming Soon](https://github.com/ChatGPTNextWeb/NextChat-iOS)
![Github iOS Image](https://github.com/user-attachments/assets/e0aa334f-4c13-4dc9-8310-e3b09fa4b9f3)
<img src="https://github.com/user-attachments/assets/f3952210-3af1-4dc0-9b81-40eaa4847d9a"/>
## 🫣 NextChat Support MCP !
> Before build, please set env ENABLE_MCP=true
@@ -308,11 +309,14 @@ If you want to disable parse settings from url, set this to 1.
To control custom models, use `+` to add a custom model, use `-` to hide a model, use `name=displayName` to customize model name, separated by comma.
User `-all` to disable all default models, `+all` to enable all default models.
Use `-all` to disable all default models, `+all` to enable all default models.
Use `-*provider` to disable specified models.
Current valid providers: `openai,azure,google,anthropic,baidu,bytedance,alibaba,tencent,moonshot,iflytek,xai,chatglm` and more to come.
For Azure: use `modelName@Azure=deploymentName` to customize model name and deployment name.
> Example: `+gpt-3.5-turbo@Azure=gpt35` will show option `gpt35(Azure)` in model list.
> If you only can use Azure model, `-all,+gpt-3.5-turbo@Azure=gpt35` will `gpt35(Azure)` the only option in model list.
> If you don't want to use Azure model, using `-*azure` will prevent Azure models from appearing in the model list.
For ByteDance: use `modelName@bytedance=deploymentName` to customize model name and deployment name.
> Example: `+Doubao-lite-4k@bytedance=ep-xxxxx-xxx` will show option `Doubao-lite-4k(ByteDance)` in model list.

View File

@@ -56,7 +56,7 @@ export interface OpenAIListModelResponse {
export interface RequestPayload {
messages: {
role: "system" | "user" | "assistant";
role: "developer" | "system" | "user" | "assistant";
content: string | MultimodalContent[];
}[];
stream?: boolean;
@@ -198,7 +198,8 @@ export class ChatGPTApi implements LLMApi {
const isDalle3 = _isDalle3(options.config.model);
const isO1OrO3 =
options.config.model.startsWith("o1") ||
options.config.model.startsWith("o3");
options.config.model.startsWith("o3") ||
options.config.model.startsWith("o4-mini");
if (isDalle3) {
const prompt = getMessageTextContent(
options.messages.slice(-1)?.pop() as any,
@@ -237,13 +238,21 @@ export class ChatGPTApi implements LLMApi {
// Please do not ask me why not send max_tokens, no reason, this param is just shit, I dont want to explain anymore.
};
// O1 使用 max_completion_tokens 控制token数 (https://platform.openai.com/docs/guides/reasoning#controlling-costs)
if (isO1OrO3) {
// by default the o1/o3 models will not attempt to produce output that includes markdown formatting
// manually add "Formatting re-enabled" developer message to encourage markdown inclusion in model responses
// (https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/reasoning?tabs=python-secure#markdown-output)
requestPayload["messages"].unshift({
role: "developer",
content: "Formatting re-enabled",
});
// o1/o3 uses max_completion_tokens to control the number of tokens (https://platform.openai.com/docs/guides/reasoning#controlling-costs)
requestPayload["max_completion_tokens"] = modelConfig.max_tokens;
}
// add max_tokens to vision model
if (visionModel) {
if (visionModel && !isO1OrO3) {
requestPayload["max_tokens"] = Math.max(modelConfig.max_tokens, 4000);
}
}

View File

@@ -417,6 +417,14 @@ export const KnowledgeCutOffDate: Record<string, string> = {
"gpt-4-turbo": "2023-12",
"gpt-4-turbo-2024-04-09": "2023-12",
"gpt-4-turbo-preview": "2023-12",
"gpt-4.1": "2024-06",
"gpt-4.1-2025-04-14": "2024-06",
"gpt-4.1-mini": "2024-06",
"gpt-4.1-mini-2025-04-14": "2024-06",
"gpt-4.1-nano": "2024-06",
"gpt-4.1-nano-2025-04-14": "2024-06",
"gpt-4.5-preview": "2023-10",
"gpt-4.5-preview-2025-02-27": "2023-10",
"gpt-4o": "2023-10",
"gpt-4o-2024-05-13": "2023-10",
"gpt-4o-2024-08-06": "2023-10",
@@ -458,6 +466,7 @@ export const DEFAULT_TTS_VOICES = [
export const VISION_MODEL_REGEXES = [
/vision/,
/gpt-4o/,
/gpt-4\.1/,
/claude-3/,
/gemini-1\.5/,
/gemini-exp/,
@@ -469,6 +478,8 @@ export const VISION_MODEL_REGEXES = [
/^dall-e-3$/, // Matches exactly "dall-e-3"
/glm-4v/,
/vl/i,
/o3/,
/o4-mini/,
];
export const EXCLUDE_VISION_MODEL_REGEXES = [/claude-3-5-haiku-20241022/];
@@ -485,6 +496,14 @@ const openaiModels = [
"gpt-4-32k-0613",
"gpt-4-turbo",
"gpt-4-turbo-preview",
"gpt-4.1",
"gpt-4.1-2025-04-14",
"gpt-4.1-mini",
"gpt-4.1-mini-2025-04-14",
"gpt-4.1-nano",
"gpt-4.1-nano-2025-04-14",
"gpt-4.5-preview",
"gpt-4.5-preview-2025-02-27",
"gpt-4o",
"gpt-4o-2024-05-13",
"gpt-4o-2024-08-06",
@@ -499,6 +518,8 @@ const openaiModels = [
"o1-mini",
"o1-preview",
"o3-mini",
"o3",
"o4-mini",
];
const googleModels = [
@@ -525,6 +546,7 @@ const googleModels = [
"gemini-2.0-flash-thinking-exp-01-21",
"gemini-2.0-pro-exp",
"gemini-2.0-pro-exp-02-05",
"gemini-2.5-pro-preview-06-05",
];
const anthropicModels = [
@@ -611,6 +633,18 @@ const xAIModes = [
"grok-2-vision-1212",
"grok-2-vision",
"grok-2-vision-latest",
"grok-3-mini-fast-beta",
"grok-3-mini-fast",
"grok-3-mini-fast-latest",
"grok-3-mini-beta",
"grok-3-mini",
"grok-3-mini-latest",
"grok-3-fast-beta",
"grok-3-fast",
"grok-3-fast-latest",
"grok-3-beta",
"grok-3",
"grok-3-latest",
];
const chatglmModels = [

View File

@@ -76,6 +76,7 @@ export function collectModelTable(
// server custom models
customModels
.split(",")
.map((v) => v.trim())
.filter((v) => !!v && v.length > 0)
.forEach((m) => {
const available = !m.startsWith("-");
@@ -88,6 +89,13 @@ export function collectModelTable(
Object.values(modelTable).forEach(
(model) => (model.available = available),
);
} else if (name.startsWith("*")) {
const modelId = name.substring(1).toLowerCase();
Object.values(modelTable).forEach((model) => {
if (model?.provider?.id === modelId) {
model.available = available;
}
});
} else {
// 1. find model by name, and set available value
const [customModelName, customProviderName] = getModelProvider(name);

142
test/model.test.ts Normal file
View File

@@ -0,0 +1,142 @@
import { collectModelTable } from "@/app/utils/model"
import { LLMModel,LLMModelProvider } from "@/app/client/api";
describe('collectModelTable', () => {
const mockModels: readonly LLMModel[] = [
{
name: 'gpt-3.5-turbo',
available: true,
provider: {
id: 'openai',
providerName: 'OpenAI',
providerType: 'openai',
} as LLMModelProvider,
sorted: 1,
},
{
name: 'gpt-4',
available: true,
provider: {
id: 'openai',
providerName: 'OpenAI',
providerType: 'openai',
} as LLMModelProvider,
sorted: 1,
},
{
name: 'gpt-3.5-turbo',
available: true,
provider: {
id: 'azure',
providerName: 'Azure',
providerType: 'azure',
} as LLMModelProvider,
sorted: 2,
},
{
name: 'gpt-4',
available: true,
provider: {
id: 'azure',
providerName: 'Azure',
providerType: 'azure',
} as LLMModelProvider,
sorted: 2,
},
{
name: 'gemini-pro',
available: true,
provider: {
id: 'google',
providerName: 'Google',
providerType: 'google',
} as LLMModelProvider,
sorted: 3,
},
{
name: 'claude-3-haiku-20240307',
available: true,
provider: {
id: 'anthropic',
providerName: 'Anthropic',
providerType: 'anthropic',
} as LLMModelProvider,
sorted: 4,
},
{
name: 'grok-beta',
available: true,
provider: {
id: 'xai',
providerName: 'XAI',
providerType: 'xai',
} as LLMModelProvider,
sorted: 11,
},
];
test('all models shoule be available', () => {
const customModels = '';
const result = collectModelTable(mockModels, customModels);
expect(result['gpt-3.5-turbo@openai'].available).toBe(true);
expect(result['gpt-4@openai'].available).toBe(true);
expect(result['gpt-3.5-turbo@azure'].available).toBe(true);
expect(result['gpt-4@azure'].available).toBe(true);
expect(result['gemini-pro@google'].available).toBe(true);
expect(result['claude-3-haiku-20240307@anthropic'].available).toBe(true);
expect(result['grok-beta@xai'].available).toBe(true);
});
test('should exclude all models when custom is "-all"', () => {
const customModels = '-all';
const result = collectModelTable(mockModels, customModels);
expect(result['gpt-3.5-turbo@openai'].available).toBe(false);
expect(result['gpt-4@openai'].available).toBe(false);
expect(result['gpt-3.5-turbo@azure'].available).toBe(false);
expect(result['gpt-4@azure'].available).toBe(false);
expect(result['gemini-pro@google'].available).toBe(false);
expect(result['claude-3-haiku-20240307@anthropic'].available).toBe(false);
expect(result['grok-beta@xai'].available).toBe(false);
});
test('should exclude all Azure models when custom is "-*azure"', () => {
const customModels = '-*azure';
const result = collectModelTable(mockModels, customModels);
expect(result['gpt-3.5-turbo@openai'].available).toBe(true);
expect(result['gpt-4@openai'].available).toBe(true);
expect(result['gpt-3.5-turbo@azure'].available).toBe(false);
expect(result['gpt-4@azure'].available).toBe(false);
expect(result['gemini-pro@google'].available).toBe(true);
expect(result['claude-3-haiku-20240307@anthropic'].available).toBe(true);
expect(result['grok-beta@xai'].available).toBe(true);
});
test('should exclude Google and XAI models when custom is "-*google,-*xai"', () => {
const customModels = '-*google,-*xai';
const result = collectModelTable(mockModels, customModels);
expect(result['gpt-3.5-turbo@openai'].available).toBe(true);
expect(result['gpt-4@openai'].available).toBe(true);
expect(result['gpt-3.5-turbo@azure'].available).toBe(true);
expect(result['gpt-4@azure'].available).toBe(true);
expect(result['gemini-pro@google'].available).toBe(false);
expect(result['claude-3-haiku-20240307@anthropic'].available).toBe(true);
expect(result['grok-beta@xai'].available).toBe(false);
});
test('All models except OpenAI should be excluded, and additional models should be added when customized as "-all, +*openai,gpt-4o@azure"', () => {
const customModels = '-all,+*openai,gpt-4o@azure';
const result = collectModelTable(mockModels, customModels);
expect(result['gpt-3.5-turbo@openai'].available).toBe(true);
expect(result['gpt-4@openai'].available).toBe(true);
expect(result['gpt-3.5-turbo@azure'].available).toBe(false);
expect(result['gpt-4@azure'].available).toBe(false);
expect(result['gemini-pro@google'].available).toBe(false);
expect(result['claude-3-haiku-20240307@anthropic'].available).toBe(false);
expect(result['grok-beta@xai'].available).toBe(false);
expect(result['gpt-4o@azure'].available).toBe(true);
});
});