Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in chat list, show model.displayName if it exists + support bytedance's r1 with internet #6220

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,7 @@ function _Chat() {
</div>
{!isUser && (
<div className={styles["chat-model-name"]}>
{message.model}
{message.modelDisplayName ?? message.model}
</div>
)}

Expand Down
23 changes: 23 additions & 0 deletions app/store/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export type ChatMessage = RequestMessage & {
isError?: boolean;
id: string;
model?: ModelType;
modelDisplayName?: string;
tools?: ChatMessageTool[];
audio_url?: string;
isMcpResponse?: boolean;
Expand Down Expand Up @@ -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)),
Expand Down Expand Up @@ -437,6 +456,10 @@ export const useChatStore = createPersistStore(
role: "assistant",
streaming: true,
model: modelConfig.model,
modelDisplayName: getModelDisplayName(
modelConfig.model,
modelConfig.providerName,
),
});

// get recent messages
Expand Down