@gendive/chatllm 0.12.2 → 0.13.0
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/react/index.d.mts +8 -2
- package/dist/react/index.d.ts +8 -2
- package/dist/react/index.js +60 -30
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +60 -30
- package/dist/react/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react/index.mjs
CHANGED
|
@@ -1217,7 +1217,7 @@ var useChatUI = (options) => {
|
|
|
1217
1217
|
// Memory options
|
|
1218
1218
|
useGlobalMemoryEnabled = true,
|
|
1219
1219
|
globalMemoryConfig,
|
|
1220
|
-
enableAutoExtraction
|
|
1220
|
+
enableAutoExtraction: enableAutoExtractionProp,
|
|
1221
1221
|
// External storage options
|
|
1222
1222
|
useExternalStorage = false,
|
|
1223
1223
|
onLoadSessions,
|
|
@@ -1233,6 +1233,7 @@ var useChatUI = (options) => {
|
|
|
1233
1233
|
// Skills options
|
|
1234
1234
|
skills
|
|
1235
1235
|
} = options;
|
|
1236
|
+
const enableAutoExtraction = enableAutoExtractionProp ?? !useExternalStorage;
|
|
1236
1237
|
const [sessions, setSessions] = useState4([]);
|
|
1237
1238
|
const [currentSessionId, setCurrentSessionId] = useState4(null);
|
|
1238
1239
|
const [input, setInput] = useState4("");
|
|
@@ -1750,18 +1751,40 @@ ${newConversation}
|
|
|
1750
1751
|
if (!messageContent.trim() || isLoading) return;
|
|
1751
1752
|
let sessionId = currentSessionId;
|
|
1752
1753
|
if (!sessionId) {
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1754
|
+
if (useExternalStorage && onCreateSession) {
|
|
1755
|
+
try {
|
|
1756
|
+
const created = await onCreateSession();
|
|
1757
|
+
const now = Date.now();
|
|
1758
|
+
const newSess = {
|
|
1759
|
+
id: created.id,
|
|
1760
|
+
title: created.title,
|
|
1761
|
+
messages: [],
|
|
1762
|
+
model: selectedModel,
|
|
1763
|
+
createdAt: now,
|
|
1764
|
+
updatedAt: now
|
|
1765
|
+
};
|
|
1766
|
+
setSessions((prev) => [newSess, ...prev]);
|
|
1767
|
+
sessionId = newSess.id;
|
|
1768
|
+
setCurrentSessionId(sessionId);
|
|
1769
|
+
} catch (error) {
|
|
1770
|
+
onError?.(error instanceof Error ? error : new Error("Failed to create session"));
|
|
1771
|
+
setIsLoading(false);
|
|
1772
|
+
return;
|
|
1773
|
+
}
|
|
1774
|
+
} else {
|
|
1775
|
+
const now = Date.now();
|
|
1776
|
+
const newSess = {
|
|
1777
|
+
id: generateId2("session"),
|
|
1778
|
+
title: "\uC0C8 \uB300\uD654",
|
|
1779
|
+
messages: [],
|
|
1780
|
+
model: selectedModel,
|
|
1781
|
+
createdAt: now,
|
|
1782
|
+
updatedAt: now
|
|
1783
|
+
};
|
|
1784
|
+
setSessions((prev) => [newSess, ...prev]);
|
|
1785
|
+
sessionId = newSess.id;
|
|
1786
|
+
setCurrentSessionId(sessionId);
|
|
1787
|
+
}
|
|
1765
1788
|
}
|
|
1766
1789
|
let finalContent = messageContent.trim();
|
|
1767
1790
|
if (quotedText) {
|
|
@@ -2157,8 +2180,8 @@ ${result.content}
|
|
|
2157
2180
|
const assistantContentForSave = accumulatedContent;
|
|
2158
2181
|
if (assistantContentForSave && onSaveMessages) {
|
|
2159
2182
|
const messagesToSave = [
|
|
2160
|
-
{ role: "
|
|
2161
|
-
{ role: "
|
|
2183
|
+
{ role: "user", message: finalContent },
|
|
2184
|
+
{ role: "assistant", message: assistantContentForSave }
|
|
2162
2185
|
];
|
|
2163
2186
|
onSaveMessages(capturedSessionId, messagesToSave).catch((saveError) => {
|
|
2164
2187
|
console.error("[useChatUI] Failed to save messages:", saveError);
|
|
@@ -2861,8 +2884,11 @@ var ChatSidebar = ({
|
|
|
2861
2884
|
onDeleteSession,
|
|
2862
2885
|
onRenameSession,
|
|
2863
2886
|
isOpen,
|
|
2864
|
-
onToggle
|
|
2887
|
+
onToggle,
|
|
2888
|
+
width: widthProp,
|
|
2889
|
+
theme
|
|
2865
2890
|
}) => {
|
|
2891
|
+
const sidebarWidth = typeof widthProp === "number" ? `${widthProp}px` : widthProp || "288px";
|
|
2866
2892
|
const [editingId, setEditingId] = useState5(null);
|
|
2867
2893
|
const [editingTitle, setEditingTitle] = useState5("");
|
|
2868
2894
|
const inputRef = useRef4(null);
|
|
@@ -2897,12 +2923,13 @@ var ChatSidebar = ({
|
|
|
2897
2923
|
handleCancelEdit();
|
|
2898
2924
|
}
|
|
2899
2925
|
};
|
|
2926
|
+
const themeClass = theme === "dark" ? "chatllm-dark" : "";
|
|
2900
2927
|
return /* @__PURE__ */ jsx2(
|
|
2901
2928
|
"aside",
|
|
2902
2929
|
{
|
|
2903
|
-
className:
|
|
2930
|
+
className: `chatllm-sidebar chatllm-sidebar-transition ${theme ? `chatllm-root ${themeClass}` : ""}`,
|
|
2904
2931
|
style: {
|
|
2905
|
-
width: isOpen ?
|
|
2932
|
+
width: isOpen ? sidebarWidth : "0",
|
|
2906
2933
|
flexShrink: 0,
|
|
2907
2934
|
backgroundColor: "var(--chatllm-sidebar-bg)",
|
|
2908
2935
|
borderRight: isOpen ? "1px solid var(--chatllm-border)" : "none",
|
|
@@ -2915,7 +2942,7 @@ var ChatSidebar = ({
|
|
|
2915
2942
|
"div",
|
|
2916
2943
|
{
|
|
2917
2944
|
style: {
|
|
2918
|
-
width:
|
|
2945
|
+
width: sidebarWidth,
|
|
2919
2946
|
height: "100%",
|
|
2920
2947
|
display: "flex",
|
|
2921
2948
|
flexDirection: "column",
|
|
@@ -6105,7 +6132,7 @@ var MessageBubble = ({
|
|
|
6105
6132
|
display: "flex",
|
|
6106
6133
|
flexDirection: "column",
|
|
6107
6134
|
alignItems: "flex-end",
|
|
6108
|
-
padding: "
|
|
6135
|
+
padding: "4px 24px"
|
|
6109
6136
|
},
|
|
6110
6137
|
onMouseEnter: () => setShowActions(true),
|
|
6111
6138
|
onMouseLeave: () => setShowActions(false),
|
|
@@ -6171,7 +6198,7 @@ var MessageBubble = ({
|
|
|
6171
6198
|
display: "flex",
|
|
6172
6199
|
flexDirection: "column",
|
|
6173
6200
|
alignItems: "flex-start",
|
|
6174
|
-
padding: "
|
|
6201
|
+
padding: "4px 24px"
|
|
6175
6202
|
},
|
|
6176
6203
|
onMouseEnter: () => setShowActions(true),
|
|
6177
6204
|
onMouseLeave: () => setShowActions(false),
|
|
@@ -6183,25 +6210,25 @@ var MessageBubble = ({
|
|
|
6183
6210
|
className: "chatllm-sheet",
|
|
6184
6211
|
style: {
|
|
6185
6212
|
width: "100%",
|
|
6186
|
-
padding: "
|
|
6213
|
+
padding: "16px",
|
|
6187
6214
|
display: "flex",
|
|
6188
|
-
gap: "
|
|
6215
|
+
gap: "12px"
|
|
6189
6216
|
},
|
|
6190
6217
|
children: [
|
|
6191
6218
|
/* @__PURE__ */ jsx10("div", { style: { flexShrink: 0 }, children: /* @__PURE__ */ jsx10(
|
|
6192
6219
|
"div",
|
|
6193
6220
|
{
|
|
6194
6221
|
style: {
|
|
6195
|
-
width: "
|
|
6196
|
-
height: "
|
|
6197
|
-
borderRadius: "
|
|
6222
|
+
width: "32px",
|
|
6223
|
+
height: "32px",
|
|
6224
|
+
borderRadius: "10px",
|
|
6198
6225
|
backgroundColor: "var(--chatllm-primary-light)",
|
|
6199
6226
|
display: "flex",
|
|
6200
6227
|
alignItems: "center",
|
|
6201
6228
|
justifyContent: "center",
|
|
6202
6229
|
color: "var(--chatllm-primary)"
|
|
6203
6230
|
},
|
|
6204
|
-
children: /* @__PURE__ */ jsx10(IconSvg, { name: "magic-line", size:
|
|
6231
|
+
children: /* @__PURE__ */ jsx10(IconSvg, { name: "magic-line", size: 20 })
|
|
6205
6232
|
}
|
|
6206
6233
|
) }),
|
|
6207
6234
|
/* @__PURE__ */ jsxs9("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
@@ -6212,7 +6239,7 @@ var MessageBubble = ({
|
|
|
6212
6239
|
display: "flex",
|
|
6213
6240
|
alignItems: "center",
|
|
6214
6241
|
gap: "8px",
|
|
6215
|
-
marginBottom: "
|
|
6242
|
+
marginBottom: "8px"
|
|
6216
6243
|
},
|
|
6217
6244
|
children: /* @__PURE__ */ jsx10(
|
|
6218
6245
|
"span",
|
|
@@ -6462,7 +6489,7 @@ var MessageBubble = ({
|
|
|
6462
6489
|
display: "flex",
|
|
6463
6490
|
gap: "2px",
|
|
6464
6491
|
marginTop: "4px",
|
|
6465
|
-
marginLeft: "
|
|
6492
|
+
marginLeft: "44px",
|
|
6466
6493
|
height: "24px",
|
|
6467
6494
|
opacity: showActions ? 1 : 0,
|
|
6468
6495
|
transition: "opacity 0.15s ease"
|
|
@@ -7806,6 +7833,7 @@ var ChatUI = ({
|
|
|
7806
7833
|
apiEndpoint = "/api/chat",
|
|
7807
7834
|
theme,
|
|
7808
7835
|
showSidebar = true,
|
|
7836
|
+
sidebarWidth,
|
|
7809
7837
|
showSettings = true,
|
|
7810
7838
|
showModelSelector = true,
|
|
7811
7839
|
systemPrompt,
|
|
@@ -7966,7 +7994,9 @@ var ChatUI = ({
|
|
|
7966
7994
|
onDeleteSession: deleteSession,
|
|
7967
7995
|
onRenameSession: renameSession,
|
|
7968
7996
|
isOpen: sidebarOpen,
|
|
7969
|
-
onToggle: toggleSidebar
|
|
7997
|
+
onToggle: toggleSidebar,
|
|
7998
|
+
width: sidebarWidth,
|
|
7999
|
+
theme: theme?.mode
|
|
7970
8000
|
}
|
|
7971
8001
|
),
|
|
7972
8002
|
/* @__PURE__ */ jsxs13(
|