@copilotkit/react-ui 1.10.0-next.4 → 1.10.0-next.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/CHANGELOG.md +10 -0
- package/dist/{chunk-WYEGK6BP.mjs → chunk-BXX6RM44.mjs} +2 -2
- package/dist/chunk-BXX6RM44.mjs.map +1 -0
- package/dist/chunk-BY42E5VF.mjs +203 -0
- package/dist/chunk-BY42E5VF.mjs.map +1 -0
- package/dist/{chunk-P6O2MZGT.mjs → chunk-K344MVUT.mjs} +58 -5
- package/dist/chunk-K344MVUT.mjs.map +1 -0
- package/dist/{chunk-2TABXABK.mjs → chunk-MYWIJSW6.mjs} +2 -2
- package/dist/chunk-MYWIJSW6.mjs.map +1 -0
- package/dist/components/chat/Chat.d.ts +10 -5
- package/dist/components/chat/Chat.js +54 -7
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +1 -1
- package/dist/components/chat/Modal.d.ts +1 -1
- package/dist/components/chat/Modal.js +157 -52
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +2 -2
- package/dist/components/chat/Popup.js +157 -52
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +3 -3
- package/dist/components/chat/Sidebar.js +157 -52
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +3 -3
- package/dist/components/chat/index.d.ts +1 -1
- package/dist/components/chat/index.js +157 -52
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +4 -4
- package/dist/components/chat/props.d.ts +39 -1
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +157 -52
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +161 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/package.json +4 -4
- package/src/components/chat/Chat.tsx +98 -4
- package/src/components/chat/Modal.tsx +107 -41
- package/src/components/chat/Popup.tsx +20 -0
- package/src/components/chat/Sidebar.tsx +22 -0
- package/src/components/chat/props.ts +46 -0
- package/dist/chunk-2TABXABK.mjs.map +0 -1
- package/dist/chunk-P6O2MZGT.mjs.map +0 -1
- package/dist/chunk-QKDRZ7WA.mjs +0 -144
- package/dist/chunk-QKDRZ7WA.mjs.map +0 -1
- package/dist/chunk-WYEGK6BP.mjs.map +0 -1
|
@@ -1538,6 +1538,7 @@ function RenderMessage(_a) {
|
|
|
1538
1538
|
var import_react10 = __toESM(require("react"));
|
|
1539
1539
|
var import_react_core5 = require("@copilotkit/react-core");
|
|
1540
1540
|
var import_shared = require("@copilotkit/shared");
|
|
1541
|
+
var import_shared2 = require("@copilotkit/shared");
|
|
1541
1542
|
var import_react_core6 = require("@copilotkit/react-core");
|
|
1542
1543
|
|
|
1543
1544
|
// src/components/chat/ImageUploadQueue.tsx
|
|
@@ -1683,11 +1684,31 @@ function CopilotChat({
|
|
|
1683
1684
|
ImageRenderer: ImageRenderer2 = ImageRenderer,
|
|
1684
1685
|
imageUploadsEnabled,
|
|
1685
1686
|
inputFileAccept = "image/*",
|
|
1686
|
-
hideStopButton
|
|
1687
|
+
hideStopButton,
|
|
1688
|
+
observabilityHooks
|
|
1687
1689
|
}) {
|
|
1688
|
-
const { additionalInstructions, setChatInstructions } = (0, import_react_core5.useCopilotContext)();
|
|
1690
|
+
const { additionalInstructions, setChatInstructions, copilotApiConfig, setBannerError } = (0, import_react_core5.useCopilotContext)();
|
|
1689
1691
|
const [selectedImages, setSelectedImages] = (0, import_react10.useState)([]);
|
|
1690
1692
|
const fileInputRef = (0, import_react10.useRef)(null);
|
|
1693
|
+
const triggerObservabilityHook = (0, import_react10.useCallback)(
|
|
1694
|
+
(hookName, ...args) => {
|
|
1695
|
+
if (copilotApiConfig.publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
1696
|
+
observabilityHooks[hookName](...args);
|
|
1697
|
+
}
|
|
1698
|
+
if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !copilotApiConfig.publicApiKey) {
|
|
1699
|
+
setBannerError(
|
|
1700
|
+
new import_shared.CopilotKitError({
|
|
1701
|
+
message: "observabilityHooks requires a publicApiKey to function.",
|
|
1702
|
+
code: import_shared.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
|
|
1703
|
+
severity: import_shared.Severity.CRITICAL,
|
|
1704
|
+
visibility: import_shared.ErrorVisibility.BANNER
|
|
1705
|
+
})
|
|
1706
|
+
);
|
|
1707
|
+
import_shared.styledConsole.publicApiKeyRequired("observabilityHooks");
|
|
1708
|
+
}
|
|
1709
|
+
},
|
|
1710
|
+
[copilotApiConfig.publicApiKey, observabilityHooks]
|
|
1711
|
+
);
|
|
1691
1712
|
(0, import_react10.useEffect)(() => {
|
|
1692
1713
|
if (!imageUploadsEnabled)
|
|
1693
1714
|
return;
|
|
@@ -1760,12 +1781,24 @@ function CopilotChat({
|
|
|
1760
1781
|
onStopGeneration,
|
|
1761
1782
|
onReloadMessages
|
|
1762
1783
|
);
|
|
1784
|
+
const prevIsLoading = (0, import_react10.useRef)(isLoading);
|
|
1785
|
+
(0, import_react10.useEffect)(() => {
|
|
1786
|
+
if (prevIsLoading.current !== isLoading) {
|
|
1787
|
+
if (isLoading) {
|
|
1788
|
+
triggerObservabilityHook("onChatStarted");
|
|
1789
|
+
} else {
|
|
1790
|
+
triggerObservabilityHook("onChatStopped");
|
|
1791
|
+
}
|
|
1792
|
+
prevIsLoading.current = isLoading;
|
|
1793
|
+
}
|
|
1794
|
+
}, [isLoading, triggerObservabilityHook]);
|
|
1763
1795
|
const handleSendMessage = (text) => {
|
|
1764
1796
|
const images = selectedImages;
|
|
1765
1797
|
setSelectedImages([]);
|
|
1766
1798
|
if (fileInputRef.current) {
|
|
1767
1799
|
fileInputRef.current.value = "";
|
|
1768
1800
|
}
|
|
1801
|
+
triggerObservabilityHook("onMessageSent", text);
|
|
1769
1802
|
return sendMessage(text, images);
|
|
1770
1803
|
};
|
|
1771
1804
|
const chatContext = import_react10.default.useContext(ChatContext);
|
|
@@ -1774,12 +1807,14 @@ function CopilotChat({
|
|
|
1774
1807
|
if (onRegenerate) {
|
|
1775
1808
|
onRegenerate(messageId);
|
|
1776
1809
|
}
|
|
1810
|
+
triggerObservabilityHook("onMessageRegenerated", messageId);
|
|
1777
1811
|
reloadMessages(messageId);
|
|
1778
1812
|
};
|
|
1779
1813
|
const handleCopy = (message) => {
|
|
1780
1814
|
if (onCopy) {
|
|
1781
1815
|
onCopy(message);
|
|
1782
1816
|
}
|
|
1817
|
+
triggerObservabilityHook("onMessageCopied", message);
|
|
1783
1818
|
};
|
|
1784
1819
|
const handleImageUpload = (event) => __async(this, null, function* () {
|
|
1785
1820
|
if (!event.target.files || event.target.files.length === 0) {
|
|
@@ -1815,6 +1850,18 @@ function CopilotChat({
|
|
|
1815
1850
|
const removeSelectedImage = (index) => {
|
|
1816
1851
|
setSelectedImages((prev) => prev.filter((_, i) => i !== index));
|
|
1817
1852
|
};
|
|
1853
|
+
const handleThumbsUp = (message) => {
|
|
1854
|
+
if (onThumbsUp) {
|
|
1855
|
+
onThumbsUp(message);
|
|
1856
|
+
}
|
|
1857
|
+
triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsUp");
|
|
1858
|
+
};
|
|
1859
|
+
const handleThumbsDown = (message) => {
|
|
1860
|
+
if (onThumbsDown) {
|
|
1861
|
+
onThumbsDown(message);
|
|
1862
|
+
}
|
|
1863
|
+
triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
|
|
1864
|
+
};
|
|
1818
1865
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
1819
1866
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1820
1867
|
Messages2,
|
|
@@ -1826,8 +1873,8 @@ function CopilotChat({
|
|
|
1826
1873
|
inProgress: isLoading,
|
|
1827
1874
|
onRegenerate: handleRegenerate,
|
|
1828
1875
|
onCopy: handleCopy,
|
|
1829
|
-
onThumbsUp,
|
|
1830
|
-
onThumbsDown,
|
|
1876
|
+
onThumbsUp: handleThumbsUp,
|
|
1877
|
+
onThumbsDown: handleThumbsDown,
|
|
1831
1878
|
markdownTagRenderers,
|
|
1832
1879
|
ImageRenderer: ImageRenderer2,
|
|
1833
1880
|
children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
@@ -1983,7 +2030,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
1983
2030
|
let firstMessage = null;
|
|
1984
2031
|
if (messageContent.trim().length > 0) {
|
|
1985
2032
|
const textMessage = {
|
|
1986
|
-
id: (0,
|
|
2033
|
+
id: (0, import_shared2.randomId)(),
|
|
1987
2034
|
role: "user",
|
|
1988
2035
|
content: messageContent
|
|
1989
2036
|
};
|
|
@@ -2005,7 +2052,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2005
2052
|
if (images.length > 0) {
|
|
2006
2053
|
for (let i = 0; i < images.length; i++) {
|
|
2007
2054
|
const imageMessage = {
|
|
2008
|
-
id: (0,
|
|
2055
|
+
id: (0, import_shared2.randomId)(),
|
|
2009
2056
|
role: "user",
|
|
2010
2057
|
image: {
|
|
2011
2058
|
format: images[i].contentType.replace("image/", ""),
|
|
@@ -2019,7 +2066,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2019
2066
|
}
|
|
2020
2067
|
}
|
|
2021
2068
|
if (!firstMessage) {
|
|
2022
|
-
return { role: "user", content: "", id: (0,
|
|
2069
|
+
return { role: "user", content: "", id: (0, import_shared2.randomId)() };
|
|
2023
2070
|
}
|
|
2024
2071
|
return firstMessage;
|
|
2025
2072
|
});
|