From 5225a6e1921d170803ab11aa8ba09957cf0b678b Mon Sep 17 00:00:00 2001 From: Eric-2369 Date: Wed, 5 Feb 2025 12:34:00 +0800 Subject: [PATCH 01/14] feat: add more llm icons --- app/components/emoji.tsx | 65 ++++++++++++++++++---- app/components/ui-lib.tsx | 2 + app/icons/llm-icons/chatglm.svg | 14 +++++ app/icons/llm-icons/claude.svg | 8 +++ app/icons/llm-icons/deepseek.svg | 8 +++ app/icons/llm-icons/default.svg | 27 ++++++++++ app/icons/llm-icons/doubao.svg | 14 +++++ app/icons/llm-icons/gemini.svg | 15 ++++++ app/icons/llm-icons/gemma.svg | 15 ++++++ app/icons/llm-icons/grok.svg | 8 +++ app/icons/llm-icons/hunyuan.svg | 17 ++++++ app/icons/llm-icons/meta.svg | 93 ++++++++++++++++++++++++++++++++ app/icons/llm-icons/mistral.svg | 15 ++++++ app/icons/llm-icons/moonshot.svg | 8 +++ app/icons/llm-icons/openai.svg | 8 +++ app/icons/llm-icons/qwen.svg | 14 +++++ app/icons/llm-icons/wenxin.svg | 18 +++++++ 17 files changed, 339 insertions(+), 10 deletions(-) create mode 100644 app/icons/llm-icons/chatglm.svg create mode 100644 app/icons/llm-icons/claude.svg create mode 100644 app/icons/llm-icons/deepseek.svg create mode 100644 app/icons/llm-icons/default.svg create mode 100644 app/icons/llm-icons/doubao.svg create mode 100644 app/icons/llm-icons/gemini.svg create mode 100644 app/icons/llm-icons/gemma.svg create mode 100644 app/icons/llm-icons/grok.svg create mode 100644 app/icons/llm-icons/hunyuan.svg create mode 100644 app/icons/llm-icons/meta.svg create mode 100644 app/icons/llm-icons/mistral.svg create mode 100644 app/icons/llm-icons/moonshot.svg create mode 100644 app/icons/llm-icons/openai.svg create mode 100644 app/icons/llm-icons/qwen.svg create mode 100644 app/icons/llm-icons/wenxin.svg diff --git a/app/components/emoji.tsx b/app/components/emoji.tsx index 54d1c1c99..6686d8731 100644 --- a/app/components/emoji.tsx +++ b/app/components/emoji.tsx @@ -6,8 +6,21 @@ import EmojiPicker, { import { ModelType } from "../store"; -import BotIcon from "../icons/bot.svg"; -import BlackBotIcon from "../icons/black-bot.svg"; +import BotIconDefault from "../icons/llm-icons/default.svg"; +import BotIconOpenAI from "../icons/llm-icons/openai.svg"; +import BotIconGemini from "../icons/llm-icons/gemini.svg"; +import BotIconGemma from "../icons/llm-icons/gemma.svg"; +import BotIconClaude from "../icons/llm-icons/claude.svg"; +import BotIconMeta from "../icons/llm-icons/meta.svg"; +import BotIconMistral from "../icons/llm-icons/mistral.svg"; +import BotIconDeepseek from "../icons/llm-icons/deepseek.svg"; +import BotIconMoonshot from "../icons/llm-icons/moonshot.svg"; +import BotIconQwen from "../icons/llm-icons/qwen.svg"; +import BotIconWenxin from "../icons/llm-icons/wenxin.svg"; +import BotIconGrok from "../icons/llm-icons/grok.svg"; +import BotIconHunyuan from "../icons/llm-icons/hunyuan.svg"; +import BotIconDoubao from "../icons/llm-icons/doubao.svg"; +import BotIconChatglm from "../icons/llm-icons/chatglm.svg"; export function getEmojiUrl(unified: string, style: EmojiStyle) { // Whoever owns this Content Delivery Network (CDN), I am using your CDN to serve emojis @@ -33,17 +46,49 @@ export function AvatarPicker(props: { } export function Avatar(props: { model?: ModelType; avatar?: string }) { + let LlmIcon = BotIconDefault; + if (props.model) { + const modelName = props.model.toLowerCase(); + + if ( + modelName.startsWith("gpt") || + modelName.startsWith("chatgpt") || + modelName.startsWith("o1") || + modelName.startsWith("o3") + ) { + LlmIcon = BotIconOpenAI; + } else if (modelName.startsWith("gemini")) { + LlmIcon = BotIconGemini; + } else if (modelName.startsWith("gemma")) { + LlmIcon = BotIconGemma; + } else if (modelName.startsWith("claude")) { + LlmIcon = BotIconClaude; + } else if (modelName.startsWith("llama")) { + LlmIcon = BotIconMeta; + } else if (modelName.startsWith("mixtral")) { + LlmIcon = BotIconMistral; + } else if (modelName.startsWith("deepseek")) { + LlmIcon = BotIconDeepseek; + } else if (modelName.startsWith("moonshot")) { + LlmIcon = BotIconMoonshot; + } else if (modelName.startsWith("qwen")) { + LlmIcon = BotIconQwen; + } else if (modelName.startsWith("ernie")) { + LlmIcon = BotIconWenxin; + } else if (modelName.startsWith("grok")) { + LlmIcon = BotIconGrok; + } else if (modelName.startsWith("hunyuan")) { + LlmIcon = BotIconHunyuan; + } else if (modelName.startsWith("doubao")) { + LlmIcon = BotIconDoubao; + } else if (modelName.startsWith("glm")) { + LlmIcon = BotIconChatglm; + } + return (
- {props.model?.startsWith("gpt-4") || - props.model?.startsWith("chatgpt-4o") || - props.model?.startsWith("o1") || - props.model?.startsWith("o3") ? ( - - ) : ( - - )} +
); } diff --git a/app/components/ui-lib.tsx b/app/components/ui-lib.tsx index a64265235..7b9f5ace0 100644 --- a/app/components/ui-lib.tsx +++ b/app/components/ui-lib.tsx @@ -23,6 +23,7 @@ import React, { useRef, } from "react"; import { IconButton } from "./button"; +import { Avatar } from "./emoji"; import clsx from "clsx"; export function Popover(props: { @@ -522,6 +523,7 @@ export function Selector(props: { key={i} title={item.title} subTitle={item.subTitle} + icon={} onClick={(e) => { if (item.disable) { e.stopPropagation(); diff --git a/app/icons/llm-icons/chatglm.svg b/app/icons/llm-icons/chatglm.svg new file mode 100644 index 000000000..642750f3e --- /dev/null +++ b/app/icons/llm-icons/chatglm.svg @@ -0,0 +1,14 @@ + + ChatGLM + + + + + + + + + + + \ No newline at end of file diff --git a/app/icons/llm-icons/claude.svg b/app/icons/llm-icons/claude.svg new file mode 100644 index 000000000..ca8e447bb --- /dev/null +++ b/app/icons/llm-icons/claude.svg @@ -0,0 +1,8 @@ + + Claude + + + + + \ No newline at end of file diff --git a/app/icons/llm-icons/deepseek.svg b/app/icons/llm-icons/deepseek.svg new file mode 100644 index 000000000..30440e316 --- /dev/null +++ b/app/icons/llm-icons/deepseek.svg @@ -0,0 +1,8 @@ + + DeepSeek + + + + + \ No newline at end of file diff --git a/app/icons/llm-icons/default.svg b/app/icons/llm-icons/default.svg new file mode 100644 index 000000000..2ebff6b3f --- /dev/null +++ b/app/icons/llm-icons/default.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/icons/llm-icons/doubao.svg b/app/icons/llm-icons/doubao.svg new file mode 100644 index 000000000..79b1b822a --- /dev/null +++ b/app/icons/llm-icons/doubao.svg @@ -0,0 +1,14 @@ + + Doubao + + + + + + + + \ No newline at end of file diff --git a/app/icons/llm-icons/gemini.svg b/app/icons/llm-icons/gemini.svg new file mode 100644 index 000000000..587669135 --- /dev/null +++ b/app/icons/llm-icons/gemini.svg @@ -0,0 +1,15 @@ + + Gemini + + + + + + + + + + + + \ No newline at end of file diff --git a/app/icons/llm-icons/gemma.svg b/app/icons/llm-icons/gemma.svg new file mode 100644 index 000000000..daf1a035c --- /dev/null +++ b/app/icons/llm-icons/gemma.svg @@ -0,0 +1,15 @@ + + Gemma + + + + + + + + + + + + \ No newline at end of file diff --git a/app/icons/llm-icons/grok.svg b/app/icons/llm-icons/grok.svg new file mode 100644 index 000000000..335786777 --- /dev/null +++ b/app/icons/llm-icons/grok.svg @@ -0,0 +1,8 @@ + + Grok + + + + + \ No newline at end of file diff --git a/app/icons/llm-icons/hunyuan.svg b/app/icons/llm-icons/hunyuan.svg new file mode 100644 index 000000000..f67930c98 --- /dev/null +++ b/app/icons/llm-icons/hunyuan.svg @@ -0,0 +1,17 @@ + + Hunyuan + + + + + + + + + + + \ No newline at end of file diff --git a/app/icons/llm-icons/meta.svg b/app/icons/llm-icons/meta.svg new file mode 100644 index 000000000..75dc40df7 --- /dev/null +++ b/app/icons/llm-icons/meta.svg @@ -0,0 +1,93 @@ + + Meta + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/icons/llm-icons/mistral.svg b/app/icons/llm-icons/mistral.svg new file mode 100644 index 000000000..e577faca5 --- /dev/null +++ b/app/icons/llm-icons/mistral.svg @@ -0,0 +1,15 @@ + + Mistral + + + + + + + + + + + + \ No newline at end of file diff --git a/app/icons/llm-icons/moonshot.svg b/app/icons/llm-icons/moonshot.svg new file mode 100644 index 000000000..8ab682d37 --- /dev/null +++ b/app/icons/llm-icons/moonshot.svg @@ -0,0 +1,8 @@ + + MoonshotAI + + + + + \ No newline at end of file diff --git a/app/icons/llm-icons/openai.svg b/app/icons/llm-icons/openai.svg new file mode 100644 index 000000000..ac4567f87 --- /dev/null +++ b/app/icons/llm-icons/openai.svg @@ -0,0 +1,8 @@ + + OpenAI + + + + + \ No newline at end of file diff --git a/app/icons/llm-icons/qwen.svg b/app/icons/llm-icons/qwen.svg new file mode 100644 index 000000000..857ce2186 --- /dev/null +++ b/app/icons/llm-icons/qwen.svg @@ -0,0 +1,14 @@ + + Qwen + + + + + + + + + + + \ No newline at end of file diff --git a/app/icons/llm-icons/wenxin.svg b/app/icons/llm-icons/wenxin.svg new file mode 100644 index 000000000..0030b0e01 --- /dev/null +++ b/app/icons/llm-icons/wenxin.svg @@ -0,0 +1,18 @@ + + Wenxin + + + + + + + + + + + + + + \ No newline at end of file From e5e5fde924a7598a6c447c079cce7337294b9d81 Mon Sep 17 00:00:00 2001 From: dupl <67990457+dupl@users.noreply.github.com> Date: Fri, 7 Feb 2025 06:50:31 +0800 Subject: [PATCH 02/14] update the lastest Gemini models --- app/constant.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/constant.ts b/app/constant.ts index 32e5a2263..226cd4046 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -509,10 +509,14 @@ const googleModels = [ "gemini-exp-1114", "gemini-exp-1121", "gemini-exp-1206", + "gemini-2.0-flash", "gemini-2.0-flash-exp", + "gemini-2.0-flash-lite-preview-02-05", "gemini-2.0-flash-thinking-exp", "gemini-2.0-flash-thinking-exp-1219", "gemini-2.0-flash-thinking-exp-01-21", + "gemini-2.0-pro-exp", + "gemini-2.0-pro-exp-02-05", ]; const anthropicModels = [ From 51384ddc5feff6ca31028c77cf6b17b751a0ab24 Mon Sep 17 00:00:00 2001 From: ZhangYichi Date: Fri, 7 Feb 2025 11:13:22 +0800 Subject: [PATCH 03/14] Fix: Set consistent fill color for OpenAI/MoonShot/Grok SVG to prevent color inversion in dark mode --- app/icons/llm-icons/grok.svg | 2 +- app/icons/llm-icons/moonshot.svg | 2 +- app/icons/llm-icons/openai.svg | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/icons/llm-icons/grok.svg b/app/icons/llm-icons/grok.svg index 335786777..8125cd610 100644 --- a/app/icons/llm-icons/grok.svg +++ b/app/icons/llm-icons/grok.svg @@ -1,4 +1,4 @@ - Grok diff --git a/app/icons/llm-icons/moonshot.svg b/app/icons/llm-icons/moonshot.svg index 8ab682d37..5206e0f12 100644 --- a/app/icons/llm-icons/moonshot.svg +++ b/app/icons/llm-icons/moonshot.svg @@ -1,4 +1,4 @@ - MoonshotAI diff --git a/app/icons/llm-icons/openai.svg b/app/icons/llm-icons/openai.svg index ac4567f87..564cd5e87 100644 --- a/app/icons/llm-icons/openai.svg +++ b/app/icons/llm-icons/openai.svg @@ -1,4 +1,4 @@ - OpenAI From 1010db834ce52f6a832bf50d3645527f3b42697e Mon Sep 17 00:00:00 2001 From: xiexin12138 Date: Fri, 7 Feb 2025 15:41:40 +0800 Subject: [PATCH 04/14] =?UTF-8?q?fix:=20=E8=A1=A5=E5=85=85=E7=A1=85?= =?UTF-8?q?=E5=9F=BA=E6=B5=81=E5=8A=A8=E7=9A=84=20env=20=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.template | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.env.template b/.env.template index 907ec9dfe..4efaa2ff8 100644 --- a/.env.template +++ b/.env.template @@ -73,6 +73,11 @@ ANTHROPIC_API_VERSION= ### anthropic claude Api url (optional) ANTHROPIC_URL= - ### (optional) WHITE_WEBDAV_ENDPOINTS= + +### siliconflow Api key (optional) +SILICONFLOW_API_KEY= + +### siliconflow Api url (optional) +SILICONFLOW_URL= From a780b39c17a271eb44421ac2f027fcf91c3b77cf Mon Sep 17 00:00:00 2001 From: xiexin12138 Date: Fri, 7 Feb 2025 15:43:50 +0800 Subject: [PATCH 05/14] =?UTF-8?q?fix:=20=E8=A1=A5=E5=85=85=E7=A1=85?= =?UTF-8?q?=E5=9F=BA=E6=B5=81=E5=8A=A8=E5=AF=B9=20DeepSeek=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E7=9A=84=E4=BB=98=E8=B4=B9=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/constant.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/constant.ts b/app/constant.ts index 32e5a2263..dd478c5e7 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -620,6 +620,8 @@ const siliconflowModels = [ "deepseek-ai/DeepSeek-V3", "meta-llama/Llama-3.3-70B-Instruct", "THUDM/glm-4-9b-chat", + "Pro/deepseek-ai/DeepSeek-R1", + "Pro/deepseek-ai/DeepSeek-V3", ]; let seq = 1000; // 内置的模型序号生成器从1000开始 From f30c6a4348fb25fead1d1ba4f4ff6717a45496fb Mon Sep 17 00:00:00 2001 From: suruiqiang Date: Fri, 7 Feb 2025 16:14:19 +0800 Subject: [PATCH 06/14] fix doubao and grok not upload image --- app/client/platforms/bytedance.ts | 11 ++++++----- app/client/platforms/xai.ts | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/client/platforms/bytedance.ts b/app/client/platforms/bytedance.ts index a2f0660d8..c2f128128 100644 --- a/app/client/platforms/bytedance.ts +++ b/app/client/platforms/bytedance.ts @@ -22,7 +22,7 @@ import { } from "@fortaine/fetch-event-source"; import { prettyObject } from "@/app/utils/format"; import { getClientConfig } from "@/app/config/client"; -import { getMessageTextContent } from "@/app/utils"; +import { preProcessImageContent } from "@/app/utils/chat"; import { fetch } from "@/app/utils/stream"; export interface OpenAIListModelResponse { @@ -84,10 +84,11 @@ export class DoubaoApi implements LLMApi { } async chat(options: ChatOptions) { - const messages = options.messages.map((v) => ({ - role: v.role, - content: getMessageTextContent(v), - })); + const messages: ChatOptions["messages"] = []; + for (const v of options.messages) { + const content = await preProcessImageContent(v.content); + messages.push({ role: v.role, content }); + } const modelConfig = { ...useAppConfig.getState().modelConfig, diff --git a/app/client/platforms/xai.ts b/app/client/platforms/xai.ts index 06dbaaa29..8c41c2d98 100644 --- a/app/client/platforms/xai.ts +++ b/app/client/platforms/xai.ts @@ -17,7 +17,7 @@ import { SpeechOptions, } from "../api"; import { getClientConfig } from "@/app/config/client"; -import { getMessageTextContent } from "@/app/utils"; +import { preProcessImageContent } from "@/app/utils/chat"; import { RequestPayload } from "./openai"; import { fetch } from "@/app/utils/stream"; @@ -62,7 +62,7 @@ export class XAIApi implements LLMApi { async chat(options: ChatOptions) { const messages: ChatOptions["messages"] = []; for (const v of options.messages) { - const content = getMessageTextContent(v); + const content = await preProcessImageContent(v.content); messages.push({ role: v.role, content }); } From f156430cc5f9451618b13e6432148d1d0dd35c5c Mon Sep 17 00:00:00 2001 From: suruiqiang Date: Fri, 7 Feb 2025 16:18:15 +0800 Subject: [PATCH 07/14] fix emoji issue for doubao and glm's congview & congvideox --- app/components/emoji.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/components/emoji.tsx b/app/components/emoji.tsx index 6686d8731..6cefe3497 100644 --- a/app/components/emoji.tsx +++ b/app/components/emoji.tsx @@ -80,9 +80,13 @@ export function Avatar(props: { model?: ModelType; avatar?: string }) { LlmIcon = BotIconGrok; } else if (modelName.startsWith("hunyuan")) { LlmIcon = BotIconHunyuan; - } else if (modelName.startsWith("doubao")) { + } else if (modelName.startsWith("doubao") || modelName.startsWith("ep-")) { LlmIcon = BotIconDoubao; - } else if (modelName.startsWith("glm")) { + } else if ( + modelName.startsWith("glm") || + modelName.startsWith("cogview-") || + modelName.startsWith("cogvideox-") + ) { LlmIcon = BotIconChatglm; } From 3fe55b4f7ff1791cf6e8c5d9da02b69a240e98a8 Mon Sep 17 00:00:00 2001 From: suruiqiang Date: Fri, 7 Feb 2025 16:20:07 +0800 Subject: [PATCH 08/14] fix bug that gemini has multiple candidates part --- app/client/platforms/google.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/client/platforms/google.ts b/app/client/platforms/google.ts index 5ca8e1071..22c89b13f 100644 --- a/app/client/platforms/google.ts +++ b/app/client/platforms/google.ts @@ -69,9 +69,16 @@ export class GeminiProApi implements LLMApi { .join("\n\n"); }; + let content = ""; + if (Array.isArray(res)) { + res.map((item) => { + content += getTextFromParts(item?.candidates?.at(0)?.content?.parts); + }); + } + return ( getTextFromParts(res?.candidates?.at(0)?.content?.parts) || - getTextFromParts(res?.at(0)?.candidates?.at(0)?.content?.parts) || + content || //getTextFromParts(res?.at(0)?.candidates?.at(0)?.content?.parts) || res?.error?.message || "" ); From a5a976824591a7e2c228dbb257616b98fd7a53ed Mon Sep 17 00:00:00 2001 From: suruiqiang Date: Fri, 7 Feb 2025 16:34:14 +0800 Subject: [PATCH 09/14] change request timeout for thinking mode --- app/client/platforms/deepseek.ts | 7 ++++++- app/client/platforms/google.ts | 10 ++++++++-- app/client/platforms/openai.ts | 9 +++++++-- app/constant.ts | 1 + 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/app/client/platforms/deepseek.ts b/app/client/platforms/deepseek.ts index 2bf3b2338..c436ae61d 100644 --- a/app/client/platforms/deepseek.ts +++ b/app/client/platforms/deepseek.ts @@ -5,6 +5,7 @@ import { DEEPSEEK_BASE_URL, DeepSeek, REQUEST_TIMEOUT_MS, + REQUEST_TIMEOUT_MS_FOR_THINKING, } from "@/app/constant"; import { useAccessStore, @@ -117,10 +118,14 @@ export class DeepSeekApi implements LLMApi { // console.log(chatPayload); + const isR1 = + options.config.model.endsWith("-reasoner") || + options.config.model.endsWith("-r1"); + // make a fetch request const requestTimeoutId = setTimeout( () => controller.abort(), - REQUEST_TIMEOUT_MS, + isR1 ? REQUEST_TIMEOUT_MS_FOR_THINKING : REQUEST_TIMEOUT_MS, ); if (shouldStream) { diff --git a/app/client/platforms/google.ts b/app/client/platforms/google.ts index 22c89b13f..1e593dd42 100644 --- a/app/client/platforms/google.ts +++ b/app/client/platforms/google.ts @@ -1,4 +1,9 @@ -import { ApiPath, Google, REQUEST_TIMEOUT_MS } from "@/app/constant"; +import { + ApiPath, + Google, + REQUEST_TIMEOUT_MS, + REQUEST_TIMEOUT_MS_FOR_THINKING, +} from "@/app/constant"; import { ChatOptions, getHeaders, @@ -197,10 +202,11 @@ export class GeminiProApi implements LLMApi { headers: getHeaders(), }; + const isThinking = options.config.model.includes("-thinking"); // make a fetch request const requestTimeoutId = setTimeout( () => controller.abort(), - REQUEST_TIMEOUT_MS, + isThinking ? REQUEST_TIMEOUT_MS_FOR_THINKING : REQUEST_TIMEOUT_MS, ); if (shouldStream) { diff --git a/app/client/platforms/openai.ts b/app/client/platforms/openai.ts index 467bb82e0..fbe533cad 100644 --- a/app/client/platforms/openai.ts +++ b/app/client/platforms/openai.ts @@ -8,6 +8,7 @@ import { Azure, REQUEST_TIMEOUT_MS, ServiceProvider, + REQUEST_TIMEOUT_MS_FOR_THINKING, } from "@/app/constant"; import { ChatMessageTool, @@ -195,7 +196,9 @@ export class ChatGPTApi implements LLMApi { let requestPayload: RequestPayload | DalleRequestPayload; const isDalle3 = _isDalle3(options.config.model); - const isO1OrO3 = options.config.model.startsWith("o1") || options.config.model.startsWith("o3"); + const isO1OrO3 = + options.config.model.startsWith("o1") || + options.config.model.startsWith("o3"); if (isDalle3) { const prompt = getMessageTextContent( options.messages.slice(-1)?.pop() as any, @@ -359,7 +362,9 @@ export class ChatGPTApi implements LLMApi { // make a fetch request const requestTimeoutId = setTimeout( () => controller.abort(), - isDalle3 || isO1OrO3 ? REQUEST_TIMEOUT_MS * 4 : REQUEST_TIMEOUT_MS, // dalle3 using b64_json is slow. + isDalle3 || isO1OrO3 + ? REQUEST_TIMEOUT_MS_FOR_THINKING + : REQUEST_TIMEOUT_MS, // dalle3 using b64_json is slow. ); const res = await fetch(chatPath, chatPayload); diff --git a/app/constant.ts b/app/constant.ts index 32e5a2263..64aa734f4 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -110,6 +110,7 @@ export const UNFINISHED_INPUT = (id: string) => "unfinished-input-" + id; export const STORAGE_KEY = "chatgpt-next-web"; export const REQUEST_TIMEOUT_MS = 60000; +export const REQUEST_TIMEOUT_MS_FOR_THINKING = REQUEST_TIMEOUT_MS * 5; export const EXPORT_MESSAGE_CLASS_NAME = "export-markdown"; From c4e9cb03a92751b37ec0b9615ef5ec056fa20bde Mon Sep 17 00:00:00 2001 From: itsevin <2720269770@qq.com> Date: Fri, 7 Feb 2025 20:29:21 +0800 Subject: [PATCH 10/14] Add Xai model --- app/constant.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/constant.ts b/app/constant.ts index 32e5a2263..e04152d0f 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -585,7 +585,16 @@ const iflytekModels = [ const deepseekModels = ["deepseek-chat", "deepseek-coder", "deepseek-reasoner"]; -const xAIModes = ["grok-beta"]; +const xAIModes = [ + "grok-beta", + "grok-2", + "grok-2-1212", + "grok-2-latest", + "grok-vision-beta", + "grok-2-vision-1212", + "grok-2-vision", + "grok-2-vision-latest", +]; const chatglmModels = [ "glm-4-plus", From 2a3996e0d66e41a99bfd4373c2bd9dec4d78652a Mon Sep 17 00:00:00 2001 From: Shenghang Tsai Date: Sat, 8 Feb 2025 14:38:12 +0800 Subject: [PATCH 11/14] Update siliconflow.ts --- app/client/platforms/siliconflow.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/client/platforms/siliconflow.ts b/app/client/platforms/siliconflow.ts index fe2f9862b..1bdf587e6 100644 --- a/app/client/platforms/siliconflow.ts +++ b/app/client/platforms/siliconflow.ts @@ -121,10 +121,10 @@ export class SiliconflowApi implements LLMApi { // console.log(chatPayload); // make a fetch request - const requestTimeoutId = setTimeout( - () => controller.abort(), - REQUEST_TIMEOUT_MS, - ); + const requestTimeoutId = setTimeout(() => { + console.error("[Request] SiliconFlow API timeout"); + controller.abort(); + }, 10 * REQUEST_TIMEOUT_MS); if (shouldStream) { const [tools, funcs] = usePluginStore From 1ae5fdbf013349a2c32e6083b41500cbf2c4000d Mon Sep 17 00:00:00 2001 From: suruiqiang Date: Sat, 8 Feb 2025 16:15:10 +0800 Subject: [PATCH 12/14] mini optimizations --- app/client/platforms/siliconflow.ts | 4 ++-- app/components/emoji.tsx | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/client/platforms/siliconflow.ts b/app/client/platforms/siliconflow.ts index fe2f9862b..d6d51fe93 100644 --- a/app/client/platforms/siliconflow.ts +++ b/app/client/platforms/siliconflow.ts @@ -4,7 +4,7 @@ import { ApiPath, SILICONFLOW_BASE_URL, SiliconFlow, - REQUEST_TIMEOUT_MS, + REQUEST_TIMEOUT_MS_FOR_THINKING, } from "@/app/constant"; import { useAccessStore, @@ -123,7 +123,7 @@ export class SiliconflowApi implements LLMApi { // make a fetch request const requestTimeoutId = setTimeout( () => controller.abort(), - REQUEST_TIMEOUT_MS, + REQUEST_TIMEOUT_MS_FOR_THINKING, ); if (shouldStream) { diff --git a/app/components/emoji.tsx b/app/components/emoji.tsx index 6cefe3497..ecb1c6581 100644 --- a/app/components/emoji.tsx +++ b/app/components/emoji.tsx @@ -54,6 +54,8 @@ export function Avatar(props: { model?: ModelType; avatar?: string }) { if ( modelName.startsWith("gpt") || modelName.startsWith("chatgpt") || + modelName.startsWith("dall-e") || + modelName.startsWith("dalle") || modelName.startsWith("o1") || modelName.startsWith("o3") ) { From acf75ce68f7152972fe5924b4880b3ae06c0ca65 Mon Sep 17 00:00:00 2001 From: Shenghang Tsai Date: Sat, 8 Feb 2025 16:34:17 +0800 Subject: [PATCH 13/14] Remove unnecessary trimming --- app/client/platforms/siliconflow.ts | 8 ++++---- app/utils/chat.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/client/platforms/siliconflow.ts b/app/client/platforms/siliconflow.ts index fe2f9862b..90dc13511 100644 --- a/app/client/platforms/siliconflow.ts +++ b/app/client/platforms/siliconflow.ts @@ -174,8 +174,8 @@ export class SiliconflowApi implements LLMApi { // Skip if both content and reasoning_content are empty or null if ( - (!reasoning || reasoning.trim().length === 0) && - (!content || content.trim().length === 0) + (!reasoning || reasoning.length === 0) && + (!content || content.length === 0) ) { return { isThinking: false, @@ -183,12 +183,12 @@ export class SiliconflowApi implements LLMApi { }; } - if (reasoning && reasoning.trim().length > 0) { + if (reasoning && reasoning.length > 0) { return { isThinking: true, content: reasoning, }; - } else if (content && content.trim().length > 0) { + } else if (content && content.length > 0) { return { isThinking: false, content: content, diff --git a/app/utils/chat.ts b/app/utils/chat.ts index c04d33cbf..b77955e6e 100644 --- a/app/utils/chat.ts +++ b/app/utils/chat.ts @@ -576,7 +576,7 @@ export function streamWithThink( try { const chunk = parseSSE(text, runTools); // Skip if content is empty - if (!chunk?.content || chunk.content.trim().length === 0) { + if (!chunk?.content || chunk.content.length === 0) { return; } // Check if thinking mode changed From 2842b264e06b08de9cfdcb84982ee6571fa45881 Mon Sep 17 00:00:00 2001 From: RiverRay Date: Sun, 9 Feb 2025 11:05:32 +0800 Subject: [PATCH 14/14] Update LICENSE --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 047f9431e..4864ab00d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023-2024 Zhang Yifei +Copyright (c) 2023-2025 NextChat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal