in chat list, show model display name if it exists

This commit is contained in:
suruiqiang 2025-02-13 18:00:32 +08:00
parent 12863f5213
commit c15dbf5296
2 changed files with 24 additions and 1 deletions

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

@ -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