Skip to content

Commit 47f1d65

Browse files
committed
create helper function modelNameFromPath
1 parent f494884 commit 47f1d65

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

tools/server/webui/src/components/ChatMessage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useMemo, useState } from 'react';
22
import { useAppContext } from '../utils/app.context';
33
import { Message, PendingMessage } from '../utils/types';
4-
import { classNames } from '../utils/misc';
4+
import { classNames, modelNameFromPath } from '../utils/misc';
55
import MarkdownDisplay, { CopyButton } from './MarkdownDisplay';
66
import {
77
ArrowPathIcon,
@@ -201,7 +201,7 @@ export default function ChatMessage({
201201
className="cursor-pointer font-semibold text-sm opacity-60"
202202
>
203203
Model:{' '}
204-
{msg.serverProps.model_path?.split(/(\\|\/)/).pop()}
204+
{msg.serverProps.model_path && modelNameFromPath(msg.serverProps.model_path)}
205205
</div>
206206
<div className="dropdown-content bg-base-100 z-10 w-80 p-2 shadow mt-4">
207207
<b>Server Information</b>

tools/server/webui/src/utils/misc.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,10 @@ export const getServerProps = async (
195195
throw error;
196196
}
197197
};
198+
199+
export const modelNameFromPath = (path: string): string => {
200+
// get the last non-empty part
201+
const trimmed = path.replace(/[\\\/]+$/, '');
202+
const parts = trimmed.split(/[\\\/]/);
203+
return parts[parts.length - 1] || path;
204+
};

0 commit comments

Comments
 (0)