@vettvangur/ai-sdk 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +19 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -940,16 +940,31 @@ function bindChat(root, options = {}) {
|
|
|
940
940
|
chatThread.append(message);
|
|
941
941
|
}
|
|
942
942
|
function tool(id, _name) {
|
|
943
|
-
const element = root.ownerDocument.createElement("
|
|
943
|
+
const element = root.ownerDocument.createElement("div");
|
|
944
944
|
element.dataset.aiChatTool = id;
|
|
945
945
|
element.className = classes.tool;
|
|
946
|
-
|
|
946
|
+
const dot = root.ownerDocument.createElement("span");
|
|
947
|
+
dot.className = "ai-chat__tool-dot";
|
|
948
|
+
dot.setAttribute("aria-hidden", "true");
|
|
949
|
+
const label = root.ownerDocument.createElement("span");
|
|
950
|
+
label.append(root.ownerDocument.createTextNode(labels.toolRunning));
|
|
951
|
+
const status = root.ownerDocument.createElement("span");
|
|
952
|
+
status.className = "ai-chat__tool-status sr-only";
|
|
953
|
+
element.append(dot, label, status);
|
|
947
954
|
activeAssistant?.append(element);
|
|
948
955
|
return element;
|
|
949
956
|
}
|
|
950
957
|
function finishTool(id, failed, interrupted = false) {
|
|
951
958
|
const element = activeAssistant?.querySelector(`[data-ai-chat-tool="${CSS.escape(id)}"]`);
|
|
952
|
-
if (element)
|
|
959
|
+
if (element) {
|
|
960
|
+
element.classList.add("ai-chat__tool--done");
|
|
961
|
+
element.classList.toggle("ai-chat__tool--failed", failed || interrupted);
|
|
962
|
+
const status = element.querySelector(".ai-chat__tool-status");
|
|
963
|
+
if (status) {
|
|
964
|
+
status.textContent = interrupted ? labels.toolInterrupted : failed ? labels.toolFailed : labels.toolComplete;
|
|
965
|
+
status.classList.remove("sr-only");
|
|
966
|
+
}
|
|
967
|
+
}
|
|
953
968
|
}
|
|
954
969
|
function renderResult(event) {
|
|
955
970
|
if (!activeAssistant) return;
|
|
@@ -993,6 +1008,7 @@ function bindChat(root, options = {}) {
|
|
|
993
1008
|
const question = input.value.trim();
|
|
994
1009
|
if (!question || session.status !== "idle") return;
|
|
995
1010
|
input.value = "";
|
|
1011
|
+
chatThread.replaceChildren();
|
|
996
1012
|
appendMarkdown(appendMessage("user"), question);
|
|
997
1013
|
activeAssistant = appendMessage("assistant");
|
|
998
1014
|
root.setAttribute("aria-busy", "true");
|