mirror of
https://github.com/coalaura/whiskr.git
synced 2025-12-02 20:22:52 +00:00
add dump button
This commit is contained in:
@@ -1011,6 +1011,7 @@ body.loading #version,
|
|||||||
#scrolling,
|
#scrolling,
|
||||||
#import,
|
#import,
|
||||||
#export,
|
#export,
|
||||||
|
#dump,
|
||||||
#clear,
|
#clear,
|
||||||
#upload,
|
#upload,
|
||||||
#add,
|
#add,
|
||||||
@@ -1170,6 +1171,7 @@ label[for="reasoning-tokens"] {
|
|||||||
#scrolling,
|
#scrolling,
|
||||||
#import,
|
#import,
|
||||||
#export,
|
#export,
|
||||||
|
#dump,
|
||||||
#clear {
|
#clear {
|
||||||
position: unset !important;
|
position: unset !important;
|
||||||
}
|
}
|
||||||
@@ -1210,6 +1212,15 @@ label[for="reasoning-tokens"] {
|
|||||||
background-image: url(icons/export.svg);
|
background-image: url(icons/export.svg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#dump {
|
||||||
|
background-image: url(icons/dump.svg);
|
||||||
|
}
|
||||||
|
|
||||||
|
#dump.loading {
|
||||||
|
animation: rotating 1.2s linear infinite;
|
||||||
|
background-image: url(icons/spinner.svg);
|
||||||
|
}
|
||||||
|
|
||||||
#clear {
|
#clear {
|
||||||
background-image: url(icons/trash.svg);
|
background-image: url(icons/trash.svg);
|
||||||
}
|
}
|
||||||
|
|||||||
7
static/css/icons/dump.svg
Normal file
7
static/css/icons/dump.svg
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->
|
||||||
|
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
|
||||||
|
<g id="SVGRepo_bgCarrier" stroke-width="0"/>
|
||||||
|
|
||||||
|
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
After Width: | Height: | Size: 1.3 KiB |
@@ -99,6 +99,7 @@
|
|||||||
<div class="option">
|
<div class="option">
|
||||||
<button id="export" title="Export the entire chat as a JSON file"></button>
|
<button id="export" title="Export the entire chat as a JSON file"></button>
|
||||||
<button id="import" title="Import a chat form a JSON file"></button>
|
<button id="import" title="Import a chat form a JSON file"></button>
|
||||||
|
<button id="dump" title="Dump the actual OpenRouter request for the current chat"></button>
|
||||||
<button id="clear" title="Clear the entire chat"></button>
|
<button id="clear" title="Clear the entire chat"></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
$scrolling = document.getElementById("scrolling"),
|
$scrolling = document.getElementById("scrolling"),
|
||||||
$export = document.getElementById("export"),
|
$export = document.getElementById("export"),
|
||||||
$import = document.getElementById("import"),
|
$import = document.getElementById("import"),
|
||||||
|
$dump = document.getElementById("dump"),
|
||||||
$clear = document.getElementById("clear"),
|
$clear = document.getElementById("clear"),
|
||||||
$authentication = document.getElementById("authentication"),
|
$authentication = document.getElementById("authentication"),
|
||||||
$authError = document.getElementById("auth-error"),
|
$authError = document.getElementById("auth-error"),
|
||||||
@@ -72,6 +73,7 @@
|
|||||||
isResizing = false,
|
isResizing = false,
|
||||||
scrollResize = false,
|
scrollResize = false,
|
||||||
isUploading = false,
|
isUploading = false,
|
||||||
|
isDumping = false,
|
||||||
totalCost = 0;
|
totalCost = 0;
|
||||||
|
|
||||||
function updateTotalCost() {
|
function updateTotalCost() {
|
||||||
@@ -1085,15 +1087,7 @@
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function generate(cancel = false, noPush = false) {
|
function buildRequest(noPush = false) {
|
||||||
if (abortNow() && cancel) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (autoScrolling) {
|
|
||||||
setFollowTail(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
let temperature = parseFloat($temperature.value);
|
let temperature = parseFloat($temperature.value);
|
||||||
|
|
||||||
if (Number.isNaN(temperature) || temperature < 0 || temperature > 2) {
|
if (Number.isNaN(temperature) || temperature < 0 || temperature > 2) {
|
||||||
@@ -1127,11 +1121,7 @@
|
|||||||
pushMessage();
|
pushMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
const controller = new AbortController();
|
return {
|
||||||
|
|
||||||
$chat.classList.add("completing");
|
|
||||||
|
|
||||||
const body = {
|
|
||||||
prompt: $prompt.value,
|
prompt: $prompt.value,
|
||||||
model: $model.value,
|
model: $model.value,
|
||||||
temperature: temperature,
|
temperature: temperature,
|
||||||
@@ -1150,6 +1140,22 @@
|
|||||||
},
|
},
|
||||||
messages: messages.map(message => message.getData()).filter(Boolean),
|
messages: messages.map(message => message.getData()).filter(Boolean),
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function generate(cancel = false, noPush = false) {
|
||||||
|
if (abortNow() && cancel) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (autoScrolling) {
|
||||||
|
setFollowTail(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
const body = buildRequest(noPush);
|
||||||
|
|
||||||
|
const controller = new AbortController();
|
||||||
|
|
||||||
|
$chat.classList.add("completing");
|
||||||
|
|
||||||
let message, generationID, stopTimeout;
|
let message, generationID, stopTimeout;
|
||||||
|
|
||||||
@@ -1995,6 +2001,42 @@
|
|||||||
restore();
|
restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$dump.addEventListener("click", async () => {
|
||||||
|
if (isDumping) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
isDumping = true;
|
||||||
|
|
||||||
|
$dump.classList.add("loading");
|
||||||
|
|
||||||
|
const body = buildRequest(true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch("/-/dump", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(body),
|
||||||
|
});
|
||||||
|
|
||||||
|
const json = await response.json();
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(json?.error || response.statusText);
|
||||||
|
}
|
||||||
|
|
||||||
|
download("request.json", "application/json", JSON.stringify(json.request, null, 4));
|
||||||
|
} catch (err) {
|
||||||
|
notify(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
$dump.classList.remove("loading");
|
||||||
|
|
||||||
|
isDumping = false;
|
||||||
|
});
|
||||||
|
|
||||||
$scrolling.addEventListener("click", () => {
|
$scrolling.addEventListener("click", () => {
|
||||||
autoScrolling = !autoScrolling;
|
autoScrolling = !autoScrolling;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user