feat: show current running models

This commit is contained in:
Timothy J. Baek
2024-06-04 11:13:43 -07:00
parent 56fda46215
commit 2be9c25ba7
6 changed files with 129 additions and 20 deletions

View File

@@ -18,7 +18,8 @@
tags as _tags,
WEBUI_NAME,
banners,
user
user,
socket
} from '$lib/stores';
import {
convertMessagesToHistory,
@@ -280,6 +281,16 @@
}
};
const getChatEventEmitter = async (modelId: string, chatId: string = '') => {
return setInterval(() => {
$socket?.emit('usage', {
action: 'chat',
model: modelId,
chat_id: chatId
});
}, 1000);
};
//////////////////////////
// Ollama functions
//////////////////////////
@@ -451,6 +462,8 @@
}
responseMessage.userContext = userContext;
const chatEventEmitter = await getChatEventEmitter(model.id, _chatId);
if (webSearchEnabled) {
await getWebSearchResults(model.id, parentId, responseMessageId);
}
@@ -460,6 +473,10 @@
} else if (model) {
await sendPromptOllama(model, prompt, responseMessageId, _chatId);
}
console.log('chatEventEmitter', chatEventEmitter);
if (chatEventEmitter) clearInterval(chatEventEmitter);
} else {
toast.error($i18n.t(`Model {{modelId}} not found`, { modelId }));
}
@@ -542,6 +559,7 @@
const sendPromptOllama = async (model, userPrompt, responseMessageId, _chatId) => {
model = model.id;
const responseMessage = history.messages[responseMessageId];
// Wait until history/message have been updated