This commit is contained in:
sanmao 2025-04-23 11:10:58 +08:00 committed by GitHub
commit 5862caff27
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 40 additions and 5 deletions

View File

@ -117,7 +117,7 @@ export class DoubaoApi implements LLMApi {
options.onController?.(controller); options.onController?.(controller);
try { try {
const chatPath = this.path(ByteDance.ChatPath); const chatPath = this.path(ByteDance.ChatPath(modelConfig.model));
const chatPayload = { const chatPayload = {
method: "POST", method: "POST",
body: JSON.stringify(requestPayload), body: JSON.stringify(requestPayload),

View File

@ -1868,7 +1868,7 @@ function _Chat() {
</div> </div>
{!isUser && ( {!isUser && (
<div className={styles["chat-model-name"]}> <div className={styles["chat-model-name"]}>
{message.model} {message.modelDisplayName ?? message.model}
</div> </div>
)} )}

View File

@ -82,7 +82,11 @@ export function Avatar(props: { model?: ModelType; avatar?: string }) {
LlmIcon = BotIconGrok; LlmIcon = BotIconGrok;
} else if (modelName.startsWith("hunyuan")) { } else if (modelName.startsWith("hunyuan")) {
LlmIcon = BotIconHunyuan; LlmIcon = BotIconHunyuan;
} else if (modelName.startsWith("doubao") || modelName.startsWith("ep-")) { } else if (
modelName.startsWith("doubao") ||
modelName.startsWith("ep-") ||
modelName.startsWith("bot-")
) {
LlmIcon = BotIconDoubao; LlmIcon = BotIconDoubao;
} else if ( } else if (
modelName.includes("glm") || modelName.includes("glm") ||

View File

@ -216,7 +216,13 @@ export const Baidu = {
export const ByteDance = { export const ByteDance = {
ExampleEndpoint: "https://ark.cn-beijing.volces.com/api/", 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 = { export const Alibaba = {

View File

@ -60,6 +60,7 @@ export type ChatMessage = RequestMessage & {
isError?: boolean; isError?: boolean;
id: string; id: string;
model?: ModelType; model?: ModelType;
modelDisplayName?: string;
tools?: ChatMessageTool[]; tools?: ChatMessageTool[];
audio_url?: string; audio_url?: string;
isMcpResponse?: boolean; isMcpResponse?: boolean;
@ -151,6 +152,24 @@ function getSummarizeModel(
return [currentModel, providerName]; 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[]) { function countMessages(msgs: ChatMessage[]) {
return msgs.reduce( return msgs.reduce(
(pre, cur) => pre + estimateTokenLength(getMessageTextContent(cur)), (pre, cur) => pre + estimateTokenLength(getMessageTextContent(cur)),
@ -437,6 +456,10 @@ export const useChatStore = createPersistStore(
role: "assistant", role: "assistant",
streaming: true, streaming: true,
model: modelConfig.model, model: modelConfig.model,
modelDisplayName: getModelDisplayName(
modelConfig.model,
modelConfig.providerName,
),
}); });
// get recent messages // get recent messages

View File

@ -304,7 +304,9 @@ export function getTimeoutMSByModel(model: string) {
model.startsWith("o1") || model.startsWith("o1") ||
model.startsWith("o3") || model.startsWith("o3") ||
model.includes("deepseek-r") || 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_FOR_THINKING;
return REQUEST_TIMEOUT_MS; return REQUEST_TIMEOUT_MS;