Skip to content

Commit a0b8779

Browse files
committed
webui: save model name with conversation history (#13570)
1 parent 5fce5f9 commit a0b8779

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default function ChatMessage({
3737
onChangeSibling(sibling: Message['id']): void;
3838
isPending?: boolean;
3939
}) {
40-
const { viewingChat, config } = useAppContext();
40+
const { viewingChat, config, serverProps } = useAppContext();
4141
const [editingContent, setEditingContent] = useState<string | null>(null);
4242
const timings = useMemo(
4343
() =>
@@ -189,11 +189,18 @@ export default function ChatMessage({
189189
</div>
190190
</div>
191191
)}
192+
193+
{/* Show model name only after AI messages */}
194+
{msg.role === 'assistant' && serverProps?.model_path && (
195+
<div className="text-xs opacity-50 mt-2">
196+
{serverProps.model_path.split(/(\\|\/)/).pop()}
197+
</div>
198+
)}
192199
</>
193200
)}
194201
</div>
195202
</div>
196-
203+
197204
{/* actions for each message */}
198205
{msg.content !== null && (
199206
<div

tools/server/webui/src/utils/app.context.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,10 @@ export const AppContextProvider = ({
305305
if (isGenerating(convId ?? '') || content.trim().length === 0) return false;
306306

307307
if (convId === null || convId.length === 0 || leafNodeId === null) {
308+
const modelName = serverProps?.model_path?.split(/(\\|\/)/).pop();
308309
const conv = await StorageUtils.createConversation(
309-
content.substring(0, 256)
310+
content.substring(0, 256),
311+
modelName
310312
);
311313
convId = conv.id;
312314
leafNodeId = conv.currNode;

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,17 @@ const db = new Dexie('LlamacppWebui') as Dexie & {
2525

2626
// https://dexie.org/docs/Version/Version.stores()
2727
db.version(1).stores({
28-
// Unlike SQL, you dont need to specify all properties but only the one you wish to index.
28+
// Unlike SQL, you don't need to specify all properties but only the one you wish to index.
2929
conversations: '&id, lastModified',
3030
messages: '&id, convId, [convId+id], timestamp',
3131
});
3232

33+
db.version(2).stores({
34+
// Version 2: Added modelName field to conversations
35+
conversations: '&id, lastModified, modelName',
36+
messages: '&id, convId, [convId+id], timestamp',
37+
});
38+
3339
// convId is a string prefixed with 'conv-'
3440
const StorageUtils = {
3541
/**
@@ -93,14 +99,18 @@ const StorageUtils = {
9399
/**
94100
* create a new conversation with a default root node
95101
*/
96-
async createConversation(name: string): Promise<Conversation> {
102+
async createConversation(
103+
name: string,
104+
modelName?: string
105+
): Promise<Conversation> {
97106
const now = Date.now();
98107
const msgId = now;
99108
const conv: Conversation = {
100109
id: `conv-${now}`,
101110
lastModified: now,
102111
currNode: msgId,
103112
name,
113+
modelName,
104114
};
105115
await db.conversations.add(conv);
106116
// create a root node

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export interface Conversation {
103103
lastModified: number; // timestamp from Date.now()
104104
currNode: Message['id']; // the current message node being viewed
105105
name: string;
106+
modelName?: string; // optional model name extracted from serverProps
106107
}
107108

108109
export interface ViewingChat {

0 commit comments

Comments
 (0)