From c15dbf52961b0582b2877179b05af07a1211fc91 Mon Sep 17 00:00:00 2001 From: suruiqiang Date: Thu, 13 Feb 2025 18:00:32 +0800 Subject: [PATCH 1/2] in chat list, show model display name if it exists --- app/components/chat.tsx | 2 +- app/store/chat.ts | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 6691403e65b..4b6874443b1 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -1868,7 +1868,7 @@ function _Chat() { {!isUser && (
- {message.model} + {message.modelDisplayName ?? message.model}
)} diff --git a/app/store/chat.ts b/app/store/chat.ts index 87c1a8beba0..8a0261027f0 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -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 From e2429d444b9654ee67b713d7c3ef53b9b7c5dc82 Mon Sep 17 00:00:00 2001 From: suruiqiang Date: Fri, 14 Feb 2025 16:14:41 +0800 Subject: [PATCH 2/2] support bytedance api start with "bot-" (with internet ability) --- app/client/platforms/bytedance.ts | 2 +- app/components/emoji.tsx | 6 +++++- app/constant.ts | 8 +++++++- app/utils.ts | 4 +++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/client/platforms/bytedance.ts b/app/client/platforms/bytedance.ts index f9524cba28d..8e409163610 100644 --- a/app/client/platforms/bytedance.ts +++ b/app/client/platforms/bytedance.ts @@ -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), diff --git a/app/components/emoji.tsx b/app/components/emoji.tsx index 1bf39ac1d77..d968b6aa0e1 100644 --- a/app/components/emoji.tsx +++ b/app/components/emoji.tsx @@ -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.toLowerCase().includes("glm") || diff --git a/app/constant.ts b/app/constant.ts index 72219d93278..11a60a088da 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -216,7 +216,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 = { diff --git a/app/utils.ts b/app/utils.ts index 6183e03b057..6582cb1f873 100644 --- a/app/utils.ts +++ b/app/utils.ts @@ -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;