1
0
mirror of https://github.com/coalaura/whiskr.git synced 2025-09-08 17:06:42 +00:00

better search tools

This commit is contained in:
Laura
2025-08-14 17:08:45 +02:00
parent 5d44980510
commit 0b51ee9dad
17 changed files with 335 additions and 102 deletions

View File

@@ -284,8 +284,8 @@ body.loading #version {
margin-top: 10px;
}
.message.has-reasoning:not(.has-text) div.text,
.message.has-tool:not(.has-text) div.text,
.message.has-reasoning:not(.has-text):not(.errored) div.text,
.message.has-tool:not(.has-text):not(.errored) div.text,
.message:not(.has-tool) .tool,
.message:not(.has-reasoning) .reasoning {
display: none;

View File

@@ -65,9 +65,9 @@
<label for="reasoning-tokens" title="Maximum amount of reasoning tokens"></label>
<input id="reasoning-tokens" type="number" min="2" max="1" step="0.05" value="0.85" />
</div>
<div class="option group">
<button id="json" class="none" title="Turn on structured json output"></button>
<button id="search" title="Turn on web-search (openrouter built-in)"></button>
<div class="option group none">
<button id="json" title="Turn on structured json output"></button>
<button id="search" title="Turn on search tools (search_web and fetch_contents)"></button>
</div>
<div class="option">
<button id="scrolling" title="Turn on auto-scrolling"></button>

View File

@@ -21,6 +21,7 @@
models = {};
let autoScrolling = false,
searchAvailable = false,
jsonMode = false,
searchTool = false;
@@ -441,6 +442,10 @@
data.statistics = this.#statistics;
}
if (!data.reasoning && !data.text && !data.tool) {
return false;
}
return data;
}
@@ -512,6 +517,7 @@
this.#tool = tool;
this.#render("tool");
this.#save();
}
addReasoning(chunk) {
@@ -687,6 +693,9 @@
$version.innerHTML = `<a href="https://github.com/coalaura/whiskr" target="_blank">whiskr</a> <a href="https://github.com/coalaura/whiskr/releases/tag/${data.version}" target="_blank">${data.version}</a>`;
}
// update search availability
searchAvailable = data.search;
// render models
$model.innerHTML = "";
@@ -805,12 +814,12 @@
}
const hasJson = tags.includes("json"),
hasTools = tags.includes("tools");
hasSearch = searchAvailable && tags.includes("tools");
$json.classList.toggle("none", !hasJson);
$search.classList.toggle("none", !hasTools);
$search.classList.toggle("none", !hasSearch);
$search.parentNode.classList.toggle("none", !hasJson && !hasTools);
$search.parentNode.classList.toggle("none", !hasJson && !hasSearch);
});
$prompt.addEventListener("change", () => {
@@ -952,7 +961,7 @@
search: searchTool,
messages: messages
.map((message) => message.getData())
.filter((data) => data?.text),
.filter(Boolean),
};
let message, generationID;
@@ -1012,6 +1021,10 @@
}
switch (chunk.type) {
case "end":
finish();
break;
case "id":
generationID = chunk.text;
@@ -1020,7 +1033,7 @@
message.setState("tooling");
message.setTool(chunk.text);
if (chunk.text.result) {
if (chunk.text.done) {
finish();
}