mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-09-29 22:56:37 +08:00
Compare commits
9 Commits
6c02a77a89
...
d9c3b17cf9
Author | SHA1 | Date | |
---|---|---|---|
|
d9c3b17cf9 | ||
|
995bef73de | ||
|
38ac502d80 | ||
|
0511808900 | ||
|
42eff644b4 | ||
|
8ae6883784 | ||
|
c0f2ab6de3 | ||
|
e2429d444b | ||
|
c15dbf5296 |
@ -117,7 +117,7 @@ export class DoubaoApi implements LLMApi {
|
||||
options.onController?.(controller);
|
||||
|
||||
try {
|
||||
const chatPath = this.path(ByteDance.ChatPath);
|
||||
const chatPath = this.path(ByteDance.ChatPath(modelConfig.model));
|
||||
const chatPayload = {
|
||||
method: "POST",
|
||||
body: JSON.stringify(requestPayload),
|
||||
|
@ -200,6 +200,7 @@ export class ChatGPTApi implements LLMApi {
|
||||
options.config.model.startsWith("o1") ||
|
||||
options.config.model.startsWith("o3") ||
|
||||
options.config.model.startsWith("o4-mini");
|
||||
const isGpt5 = options.config.model.startsWith("gpt-5");
|
||||
if (isDalle3) {
|
||||
const prompt = getMessageTextContent(
|
||||
options.messages.slice(-1)?.pop() as any,
|
||||
@ -230,7 +231,7 @@ export class ChatGPTApi implements LLMApi {
|
||||
messages,
|
||||
stream: options.config.stream,
|
||||
model: modelConfig.model,
|
||||
temperature: !isO1OrO3 ? modelConfig.temperature : 1,
|
||||
temperature: (!isO1OrO3 && !isGpt5) ? modelConfig.temperature : 1,
|
||||
presence_penalty: !isO1OrO3 ? modelConfig.presence_penalty : 0,
|
||||
frequency_penalty: !isO1OrO3 ? modelConfig.frequency_penalty : 0,
|
||||
top_p: !isO1OrO3 ? modelConfig.top_p : 1,
|
||||
@ -238,7 +239,13 @@ 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.
|
||||
};
|
||||
|
||||
if (isO1OrO3) {
|
||||
if (isGpt5) {
|
||||
// Remove max_tokens if present
|
||||
delete requestPayload.max_tokens;
|
||||
// Add max_completion_tokens (or max_completion_tokens if that's what you meant)
|
||||
requestPayload["max_completion_tokens"] = modelConfig.max_tokens;
|
||||
|
||||
} else 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)
|
||||
@ -251,8 +258,9 @@ export class ChatGPTApi implements LLMApi {
|
||||
requestPayload["max_completion_tokens"] = modelConfig.max_tokens;
|
||||
}
|
||||
|
||||
|
||||
// add max_tokens to vision model
|
||||
if (visionModel && !isO1OrO3) {
|
||||
if (visionModel && !isO1OrO3 && ! isGpt5) {
|
||||
requestPayload["max_tokens"] = Math.max(modelConfig.max_tokens, 4000);
|
||||
}
|
||||
}
|
||||
|
@ -1868,7 +1868,7 @@ function _Chat() {
|
||||
</div>
|
||||
{!isUser && (
|
||||
<div className={styles["chat-model-name"]}>
|
||||
{message.model}
|
||||
{message.modelDisplayName ?? message.model}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
@ -82,7 +82,11 @@ export function Avatar(props: { model?: ModelType; avatar?: string }) {
|
||||
LlmIcon = BotIconGrok;
|
||||
} else if (modelName.startsWith("hunyuan")) {
|
||||
LlmIcon = BotIconHunyuan;
|
||||
} else if (modelName.startsWith("doubao") || modelName.startsWith("ep-")) {
|
||||
} else if (
|
||||
modelName.startsWith("doubao") ||
|
||||
modelName.startsWith("ep-") ||
|
||||
modelName.startsWith("bot-")
|
||||
) {
|
||||
LlmIcon = BotIconDoubao;
|
||||
} else if (
|
||||
modelName.includes("glm") ||
|
||||
|
@ -221,7 +221,13 @@ export const Baidu = {
|
||||
|
||||
export const ByteDance = {
|
||||
ExampleEndpoint: "https://ark.cn-beijing.volces.com/api/",
|
||||
ChatPath: "api/v3/chat/completions",
|
||||
ChatPath: (modelName: string) => {
|
||||
if (modelName.startsWith("bot-")) {
|
||||
return "api/v3/bots/chat/completions";
|
||||
} else {
|
||||
return "api/v3/chat/completions";
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export const Alibaba = {
|
||||
@ -493,6 +499,7 @@ export const VISION_MODEL_REGEXES = [
|
||||
/o3/,
|
||||
/o4-mini/,
|
||||
/grok-4/i,
|
||||
/gpt-5/
|
||||
];
|
||||
|
||||
export const EXCLUDE_VISION_MODEL_REGEXES = [/claude-3-5-haiku-20241022/];
|
||||
@ -517,6 +524,11 @@ const openaiModels = [
|
||||
"gpt-4.1-nano-2025-04-14",
|
||||
"gpt-4.5-preview",
|
||||
"gpt-4.5-preview-2025-02-27",
|
||||
"gpt-5-chat",
|
||||
"gpt-5-mini",
|
||||
"gpt-5-nano",
|
||||
"gpt-5",
|
||||
"gpt-5-chat-2025-01-01-preview",
|
||||
"gpt-4o",
|
||||
"gpt-4o-2024-05-13",
|
||||
"gpt-4o-2024-08-06",
|
||||
|
@ -60,6 +60,7 @@ export type ChatMessage = RequestMessage & {
|
||||
isError?: boolean;
|
||||
id: string;
|
||||
model?: ModelType;
|
||||
modelDisplayName?: string;
|
||||
tools?: ChatMessageTool[];
|
||||
audio_url?: string;
|
||||
isMcpResponse?: boolean;
|
||||
@ -151,6 +152,24 @@ function getSummarizeModel(
|
||||
return [currentModel, providerName];
|
||||
}
|
||||
|
||||
function getModelDisplayName(
|
||||
model: ModelType,
|
||||
providerName: ServiceProvider,
|
||||
): string | undefined {
|
||||
const configStore = useAppConfig.getState();
|
||||
const accessStore = useAccessStore.getState();
|
||||
const allModel = collectModelsWithDefaultModel(
|
||||
configStore.models,
|
||||
[configStore.customModels, accessStore.customModels].join(","),
|
||||
accessStore.defaultModel,
|
||||
);
|
||||
|
||||
const matchedModel = allModel.find(
|
||||
(m) => m.name === model && m.provider?.providerName === providerName,
|
||||
);
|
||||
return matchedModel ? matchedModel.displayName : undefined;
|
||||
}
|
||||
|
||||
function countMessages(msgs: ChatMessage[]) {
|
||||
return msgs.reduce(
|
||||
(pre, cur) => pre + estimateTokenLength(getMessageTextContent(cur)),
|
||||
@ -437,6 +456,10 @@ export const useChatStore = createPersistStore(
|
||||
role: "assistant",
|
||||
streaming: true,
|
||||
model: modelConfig.model,
|
||||
modelDisplayName: getModelDisplayName(
|
||||
modelConfig.model,
|
||||
modelConfig.providerName,
|
||||
),
|
||||
});
|
||||
|
||||
// get recent messages
|
||||
|
@ -304,7 +304,9 @@ export function getTimeoutMSByModel(model: string) {
|
||||
model.startsWith("o1") ||
|
||||
model.startsWith("o3") ||
|
||||
model.includes("deepseek-r") ||
|
||||
model.includes("-thinking")
|
||||
model.includes("-thinking") ||
|
||||
model.startsWith("ep-") ||
|
||||
model.startsWith("bot-")
|
||||
)
|
||||
return REQUEST_TIMEOUT_MS_FOR_THINKING;
|
||||
return REQUEST_TIMEOUT_MS;
|
||||
|
Loading…
Reference in New Issue
Block a user