quantizations
This commit is contained in:
@@ -264,6 +264,8 @@
|
||||
<div class="chat-toolbar">
|
||||
<label>Model
|
||||
<select id="chat-model" onchange="selectChatModel(this.value)"></select>
|
||||
<select id="chat-quantization" onchange="selectChatQuantization(this.value)"></select>
|
||||
<button type="button" id="vote-coverage" onclick="voteForCoverage()" style="display:none">Vote for coverage</button>
|
||||
</label>
|
||||
<button type="button" id="request-model-load" style="display:none" onclick="requestSelectedModelLoad()">Load on available node</button>
|
||||
<div id="chat-status" class="chat-status">select a model to start</div>
|
||||
@@ -1268,6 +1270,7 @@ let chatBusy = false;
|
||||
let chatSessions = [];
|
||||
let activeChatSessionId = "";
|
||||
let selectedChatModel = localStorage.getItem("meshnet_chat_model") || "";
|
||||
let selectedChatQuantization = localStorage.getItem("meshnet_chat_quantization") || "";
|
||||
const CHAT_SESSIONS_KEY = "meshnet_chat_sessions_v1";
|
||||
const CHAT_ACTIVE_SESSION_KEY = "meshnet_chat_active_session_v1";
|
||||
const CHAT_SESSIONS_LIMIT = 50;
|
||||
@@ -1628,6 +1631,36 @@ function renderChatModels(force) {
|
||||
return `<option value="${esc(model.id)}"${model.id === selectedChatModel ? " selected" : ""}>${esc(label)}</option>`;
|
||||
}).join("");
|
||||
select.value = selectedChatModel;
|
||||
renderChatQuantizations();
|
||||
}
|
||||
|
||||
function selectedChatModelEntry() {
|
||||
return availableModels.find(model => model.id === selectedChatModel) || null;
|
||||
}
|
||||
|
||||
function renderChatQuantizations() {
|
||||
const select = $("chat-quantization");
|
||||
const vote = $("vote-coverage");
|
||||
const model = selectedChatModelEntry();
|
||||
if (!select || !vote) return;
|
||||
const variants = (model && model.quantizations) || [];
|
||||
const selectable = variants.filter(variant => variant.selectable);
|
||||
if (!selectable.length) {
|
||||
select.innerHTML = '<option value="">no complete coverage</option>';
|
||||
select.disabled = true;
|
||||
vote.style.display = model ? "" : "none";
|
||||
return;
|
||||
}
|
||||
const preferred = selectable.find(variant => variant.id === selectedChatQuantization)
|
||||
|| selectable[0];
|
||||
selectedChatQuantization = preferred.id;
|
||||
localStorage.setItem("meshnet_chat_quantization", selectedChatQuantization);
|
||||
select.innerHTML = selectable.map(variant =>
|
||||
`<option value="${esc(variant.id)}">${esc(variant.id)}</option>`
|
||||
).join("");
|
||||
select.value = selectedChatQuantization;
|
||||
select.disabled = false;
|
||||
vote.style.display = variants.some(variant => !variant.selectable) ? "" : "none";
|
||||
}
|
||||
|
||||
function bindChatModelSelect() {
|
||||
@@ -1649,6 +1682,24 @@ function selectChatModel(value) {
|
||||
saveChatSessionsStore();
|
||||
renderChatSessionList();
|
||||
}
|
||||
renderChatQuantizations();
|
||||
}
|
||||
|
||||
function selectChatQuantization(value) {
|
||||
selectedChatQuantization = value || "";
|
||||
localStorage.setItem("meshnet_chat_quantization", selectedChatQuantization);
|
||||
}
|
||||
|
||||
async function voteForCoverage() {
|
||||
const model = selectedChatModelEntry();
|
||||
if (!model) return;
|
||||
const unavailable = (model.quantizations || []).find(variant => !variant.selectable);
|
||||
if (!unavailable) return;
|
||||
const result = await apiCall("/v1/models/vote", "POST", {
|
||||
model: model.id,
|
||||
quantization: unavailable.id,
|
||||
});
|
||||
renderChatStatus(result.ok ? `vote recorded for ${unavailable.id} coverage` : "coverage vote failed");
|
||||
}
|
||||
|
||||
async function requestSelectedModelLoad() {
|
||||
@@ -2049,6 +2100,7 @@ async function sendChat() {
|
||||
{ role: "user", content: prompt },
|
||||
],
|
||||
stream: true,
|
||||
quantization: selectedChatQuantization || "bfloat16",
|
||||
max_tokens: 15120,
|
||||
};
|
||||
chatBusy = true;
|
||||
@@ -2213,6 +2265,7 @@ function applyAvailableModels(models, map) {
|
||||
aliases: model.aliases || [],
|
||||
coverage: model.shard_coverage_percentage,
|
||||
servedCopies: model.served_model_copies,
|
||||
quantizations: model.quantizations || [],
|
||||
};
|
||||
entry.servedCopies = modelServedCopiesFromMap(lastNetworkMap, entry);
|
||||
return entry;
|
||||
|
||||
Reference in New Issue
Block a user