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

improvements

This commit is contained in:
2025-08-30 00:25:48 +02:00
parent c7c3bff2d8
commit be17a801f8
3 changed files with 15 additions and 8 deletions

16
chat.go
View File

@@ -14,12 +14,13 @@ import (
) )
type ToolCall struct { type ToolCall struct {
ID string `json:"id"` ID string `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Args string `json:"args"` Args string `json:"args"`
Result string `json:"result,omitempty"` Result string `json:"result,omitempty"`
Done bool `json:"done,omitempty"` Done bool `json:"done,omitempty"`
Cost float64 `json:"cost,omitempty"` Invalid bool `json:"invalid,omitempty"`
Cost float64 `json:"cost,omitempty"`
} }
type TextFile struct { type TextFile struct {
@@ -323,7 +324,8 @@ func HandleChat(w http.ResponseWriter, r *http.Request) {
return return
} }
default: default:
return tool.Invalid = true
tool.Result = "error: invalid tool call"
} }
tool.Done = true tool.Done = true

View File

@@ -368,6 +368,8 @@ body:not(.loading) #loading {
width: calc(800px - 24px); width: calc(800px - 24px);
} }
.message .tool.invalid,
.message .tool .result.error,
.message .text .error { .message .text .error {
color: #ed8796; color: #ed8796;
} }

View File

@@ -493,7 +493,7 @@
if (!only || only === "tool") { if (!only || only === "tool") {
if (this.#tool) { if (this.#tool) {
const { name, args, result, cost } = this.#tool; const { name, args, result, cost, invalid } = this.#tool;
const _name = this.#_tool.querySelector(".name"), const _name = this.#_tool.querySelector(".name"),
_arguments = this.#_tool.querySelector(".arguments"), _arguments = this.#_tool.querySelector(".arguments"),
@@ -508,8 +508,11 @@
_cost.textContent = cost ? `${formatMoney(cost)}` : ""; _cost.textContent = cost ? `${formatMoney(cost)}` : "";
_result.classList.toggle("error", result?.startsWith("error: "));
_result.innerHTML = render(result || "*processing*"); _result.innerHTML = render(result || "*processing*");
this.#_tool.classList.toggle("invalid", invalid);
this.#_tool.setAttribute("data-tool", name); this.#_tool.setAttribute("data-tool", name);
} else { } else {
this.#_tool.removeAttribute("data-tool"); this.#_tool.removeAttribute("data-tool");