@smart-cloud/ai-kit-ui 1.3.11 → 1.3.13
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/ai-kit-ui.css +0 -1
- package/dist/index.cjs +6 -6
- package/dist/index.js +6 -6
- package/package.json +1 -1
- package/src/ai-chatbot/AiChatbot.tsx +56 -57
- package/src/doc-search/DocSearch.tsx +243 -161
- package/src/styles/ai-kit-ui.css +0 -1
package/package.json
CHANGED
|
@@ -65,9 +65,8 @@ const USE_AUDIO = false; // Set to true to enable audio recording feature (requi
|
|
|
65
65
|
// New: history storage support
|
|
66
66
|
const DEFAULT_PRESERVATION_TIME_DAYS = 1;
|
|
67
67
|
const DEFAULT_HISTORY_STORAGE: HistoryStorageMode = "localstorage";
|
|
68
|
-
const HISTORY_STORAGE_KEY = `ai-kit-chatbot-history-v1:${
|
|
69
|
-
|
|
70
|
-
}`;
|
|
68
|
+
const HISTORY_STORAGE_KEY = `ai-kit-chatbot-history-v1:${typeof window !== "undefined" ? window.location.hostname : "unknown"
|
|
69
|
+
}`;
|
|
71
70
|
|
|
72
71
|
export const DEFAULT_CHATBOT_LABELS: Required<AiChatbotLabels> = {
|
|
73
72
|
modalTitle: "AI Assistant",
|
|
@@ -223,7 +222,7 @@ const formatStatusEvent = (
|
|
|
223
222
|
case "backend:response":
|
|
224
223
|
return I18n.get(
|
|
225
224
|
labels.assistantThinkingLabel ??
|
|
226
|
-
|
|
225
|
+
DEFAULT_CHATBOT_LABELS.assistantThinkingLabel,
|
|
227
226
|
);
|
|
228
227
|
case "done":
|
|
229
228
|
return msg || I18n.get("Done.");
|
|
@@ -964,9 +963,9 @@ const AiChatbotBase: FC<AiChatbotProps & AiKitShellInjectedProps> = (props) => {
|
|
|
964
963
|
blob instanceof File
|
|
965
964
|
? blob
|
|
966
965
|
: new File([blob], attachment.name || "attachment", {
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
966
|
+
type:
|
|
967
|
+
attachment.type || blob.type || "application/octet-stream",
|
|
968
|
+
});
|
|
970
969
|
|
|
971
970
|
const objectUrl = createObjectUrl(file);
|
|
972
971
|
if (!objectUrl) continue;
|
|
@@ -1055,7 +1054,7 @@ const AiChatbotBase: FC<AiChatbotProps & AiKitShellInjectedProps> = (props) => {
|
|
|
1055
1054
|
try {
|
|
1056
1055
|
const activeSessionId =
|
|
1057
1056
|
sessionRef.current &&
|
|
1058
|
-
|
|
1057
|
+
Date.now() - sessionRef.current.storedAt <
|
|
1059
1058
|
emptyHistoryAfterDays * TWENTY_FOUR_HOURS_MS
|
|
1060
1059
|
? sessionRef.current.id
|
|
1061
1060
|
: undefined;
|
|
@@ -1149,7 +1148,7 @@ const AiChatbotBase: FC<AiChatbotProps & AiKitShellInjectedProps> = (props) => {
|
|
|
1149
1148
|
try {
|
|
1150
1149
|
const activeSessionId =
|
|
1151
1150
|
sessionRef.current &&
|
|
1152
|
-
|
|
1151
|
+
Date.now() - sessionRef.current.storedAt <
|
|
1153
1152
|
emptyHistoryAfterDays * TWENTY_FOUR_HOURS_MS
|
|
1154
1153
|
? sessionRef.current.id
|
|
1155
1154
|
: undefined;
|
|
@@ -1777,53 +1776,53 @@ const AiChatbotBase: FC<AiChatbotProps & AiKitShellInjectedProps> = (props) => {
|
|
|
1777
1776
|
att.mediaType === "image" ||
|
|
1778
1777
|
(!att.mediaType && att.type.startsWith("image/")),
|
|
1779
1778
|
).length > 0 && (
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1779
|
+
<Group
|
|
1780
|
+
className="ai-thumbs ai-message-thumbs"
|
|
1781
|
+
gap="xs"
|
|
1782
|
+
>
|
|
1783
|
+
{msg.attachments
|
|
1784
|
+
.filter(
|
|
1785
|
+
(att) =>
|
|
1786
|
+
att.mediaType === "image" ||
|
|
1787
|
+
(!att.mediaType &&
|
|
1788
|
+
att.type.startsWith("image/")),
|
|
1789
|
+
)
|
|
1790
|
+
.map((attachment) => (
|
|
1791
|
+
<button
|
|
1792
|
+
key={attachment.id}
|
|
1793
|
+
type="button"
|
|
1794
|
+
className="thumb"
|
|
1795
|
+
style={{
|
|
1796
|
+
backgroundImage: attachment.objectUrl
|
|
1797
|
+
? `url(${attachment.objectUrl})`
|
|
1798
|
+
: undefined,
|
|
1799
|
+
backgroundSize: "cover",
|
|
1800
|
+
backgroundPosition: "center",
|
|
1801
|
+
backgroundRepeat: "no-repeat",
|
|
1802
|
+
}}
|
|
1803
|
+
onClick={() =>
|
|
1804
|
+
openAttachmentPreview(
|
|
1805
|
+
attachment.objectUrl,
|
|
1806
|
+
attachment.name,
|
|
1807
|
+
)
|
|
1808
|
+
}
|
|
1809
|
+
disabled={!attachment.objectUrl}
|
|
1810
|
+
title={
|
|
1811
|
+
attachment.name || I18n.get("View image")
|
|
1812
|
+
}
|
|
1813
|
+
aria-label={
|
|
1814
|
+
attachment.name || I18n.get("View image")
|
|
1815
|
+
}
|
|
1816
|
+
>
|
|
1817
|
+
{!attachment.objectUrl && (
|
|
1818
|
+
<Text size="xs" c="dimmed">
|
|
1819
|
+
{I18n.get("Image no longer available")}
|
|
1820
|
+
</Text>
|
|
1821
|
+
)}
|
|
1822
|
+
</button>
|
|
1823
|
+
))}
|
|
1824
|
+
</Group>
|
|
1825
|
+
)}
|
|
1827
1826
|
|
|
1828
1827
|
{/* Audio attachments */}
|
|
1829
1828
|
{msg.attachments
|
|
@@ -2000,7 +1999,7 @@ const AiChatbotBase: FC<AiChatbotProps & AiKitShellInjectedProps> = (props) => {
|
|
|
2000
1999
|
onClose={cancelReset}
|
|
2001
2000
|
centered
|
|
2002
2001
|
title={I18n.get("Reset conversation")}
|
|
2003
|
-
style={{ position: "fixed" }}
|
|
2002
|
+
style={{ zIndex: "var(--mb-z-index)", position: "fixed" }}
|
|
2004
2003
|
left={0}
|
|
2005
2004
|
>
|
|
2006
2005
|
<Text size="sm">
|