@e-llm-studio/instant-learning 1.3.31-alpha.2 → 1.3.31-alpha.3
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/cjs/features/IL-OTJ/ILOTJ.js +9 -1
- package/dist/cjs/features/IL-OTJ/ILOTJ.js.map +1 -1
- package/dist/cjs/features/IL-OTJ/_components/ChatComponents/ChatComponent.js +15 -6
- package/dist/cjs/features/IL-OTJ/_components/ChatComponents/ChatComponent.js.map +1 -1
- package/dist/cjs/features/IL-OTJ/_components/ChatComponents/NormalChat.js +15 -6
- package/dist/cjs/features/IL-OTJ/_components/ChatComponents/NormalChat.js.map +1 -1
- package/dist/cjs/features/IL-OTJ/_components/ChatComponents/chatSessionStorage.js +98 -0
- package/dist/cjs/features/IL-OTJ/_components/ChatComponents/chatSessionStorage.js.map +1 -0
- package/dist/features/IL-OTJ/ILOTJ.js +9 -1
- package/dist/features/IL-OTJ/ILOTJ.js.map +1 -1
- package/dist/features/IL-OTJ/_components/ChatComponents/ChatComponent.js +15 -6
- package/dist/features/IL-OTJ/_components/ChatComponents/ChatComponent.js.map +1 -1
- package/dist/features/IL-OTJ/_components/ChatComponents/NormalChat.js +15 -6
- package/dist/features/IL-OTJ/_components/ChatComponents/NormalChat.js.map +1 -1
- package/dist/features/IL-OTJ/_components/ChatComponents/chatSessionStorage.js +89 -0
- package/dist/features/IL-OTJ/_components/ChatComponents/chatSessionStorage.js.map +1 -0
- package/dist/types/src/features/IL-OTJ/ILOTJ.d.ts.map +1 -1
- package/dist/types/src/features/IL-OTJ/_components/ChatComponents/ChatComponent.d.ts +1 -0
- package/dist/types/src/features/IL-OTJ/_components/ChatComponents/ChatComponent.d.ts.map +1 -1
- package/dist/types/src/features/IL-OTJ/_components/ChatComponents/NormalChat.d.ts +1 -0
- package/dist/types/src/features/IL-OTJ/_components/ChatComponents/NormalChat.d.ts.map +1 -1
- package/dist/types/src/features/IL-OTJ/_components/ChatComponents/chatSessionStorage.d.ts +7 -0
- package/dist/types/src/features/IL-OTJ/_components/ChatComponents/chatSessionStorage.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -25,6 +25,7 @@ var SendButton = require('../_svg/SendButton.js');
|
|
|
25
25
|
var SparkleIcon = require('../_svg/SparkleIcon.js');
|
|
26
26
|
var UserIcon = require('../_svg/UserIcon.js');
|
|
27
27
|
var useAuthStore = require('../../../LearningManagement/store/useAuthStore.js');
|
|
28
|
+
var chatSessionStorage = require('./chatSessionStorage.js');
|
|
28
29
|
|
|
29
30
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
30
31
|
|
|
@@ -51,6 +52,7 @@ const NormalChat = ({
|
|
|
51
52
|
aiResponse,
|
|
52
53
|
setAIResponse,
|
|
53
54
|
onResetChat,
|
|
55
|
+
chatSessionStorageKey,
|
|
54
56
|
initialChatMessage = "",
|
|
55
57
|
onSave,
|
|
56
58
|
chatSize,
|
|
@@ -73,7 +75,7 @@ const NormalChat = ({
|
|
|
73
75
|
}) => {
|
|
74
76
|
const chatAssistant = chatAssistantName;
|
|
75
77
|
const user = useAuthStore["default"]((state) => state.user);
|
|
76
|
-
const guestSessionIdRef = React.useRef(
|
|
78
|
+
const guestSessionIdRef = React.useRef(chatSessionStorage.getOrCreateTeachMeChatSessionId(chatSessionStorageKey, chatAssistant, organizationName));
|
|
77
79
|
const chatPreviewIdRef = React.useRef(`${uuid.v4()}`);
|
|
78
80
|
const url = baseUrl;
|
|
79
81
|
const scrollContainerRef = React.useRef(null);
|
|
@@ -81,11 +83,12 @@ const NormalChat = ({
|
|
|
81
83
|
const messagesEndRef = React.useRef(null);
|
|
82
84
|
const textAreaRef = React.useRef(null);
|
|
83
85
|
const [userInput, setUserInput] = React.useState("");
|
|
84
|
-
const [messages, setMessages] = React.useState(
|
|
86
|
+
const [messages, setMessages] = React.useState(() => chatSessionStorage.readTeachMeChatMessages(chatSessionStorageKey, guestSessionIdRef.current));
|
|
87
|
+
const messagesRef = React.useRef(messages);
|
|
85
88
|
const [messageLoading, setMessageLoading] = React.useState(false);
|
|
86
89
|
const [waitMessageLoading, setWaitMessageLoading] = React.useState(false);
|
|
87
90
|
const [isStreamEnd, setIsStreamEnd] = React.useState(true);
|
|
88
|
-
const [showWelcomeMessage, setShowWelcomeMessage] = React.useState(
|
|
91
|
+
const [showWelcomeMessage, setShowWelcomeMessage] = React.useState(() => messagesRef.current.length === 0);
|
|
89
92
|
const [chatInitialMessage, setChatInitialMessage] = React.useState("");
|
|
90
93
|
const [initialLoadingMessage, setInitialLoadingMessage] = React.useState("");
|
|
91
94
|
const [isStreaming, setIsStreaming] = React.useState(false);
|
|
@@ -226,6 +229,10 @@ const NormalChat = ({
|
|
|
226
229
|
console.error("Error handling sendMessageInChat signal", err);
|
|
227
230
|
}
|
|
228
231
|
}, [sendMessageInChat]);
|
|
232
|
+
React.useEffect(() => {
|
|
233
|
+
messagesRef.current = messages;
|
|
234
|
+
chatSessionStorage.persistTeachMeChatMessages(chatSessionStorageKey, guestSessionIdRef.current, messages);
|
|
235
|
+
}, [messages, chatSessionStorageKey]);
|
|
229
236
|
React.useEffect(() => {
|
|
230
237
|
getChatSettings();
|
|
231
238
|
getChatHistory();
|
|
@@ -313,11 +320,12 @@ const NormalChat = ({
|
|
|
313
320
|
withCredentials: true
|
|
314
321
|
};
|
|
315
322
|
transport.http.get(getHistoryURL, requestOptions).then((response) => {
|
|
316
|
-
const data = response.data;
|
|
323
|
+
const data = Array.isArray(response.data) ? response.data : [];
|
|
317
324
|
if (data.length > 0) {
|
|
318
325
|
setMessages(data);
|
|
326
|
+
setShowWelcomeMessage(false);
|
|
319
327
|
scrollToBottom();
|
|
320
|
-
} else {
|
|
328
|
+
} else if (messagesRef.current.length === 0) {
|
|
321
329
|
setShowWelcomeMessage(true);
|
|
322
330
|
}
|
|
323
331
|
}).catch((error) => {
|
|
@@ -329,6 +337,7 @@ const NormalChat = ({
|
|
|
329
337
|
}
|
|
330
338
|
};
|
|
331
339
|
const resetChatHistory = () => {
|
|
340
|
+
const previousSessionId = guestSessionIdRef.current;
|
|
332
341
|
const resetChatHistoryURL = `${url}/api/chat/resetHistory?name=${chatAssistant}&organizationName=${organizationName}`;
|
|
333
342
|
try {
|
|
334
343
|
const requestOptions = {
|
|
@@ -352,7 +361,7 @@ const NormalChat = ({
|
|
|
352
361
|
}).catch((error) => {
|
|
353
362
|
console.error(error);
|
|
354
363
|
}).finally(() => {
|
|
355
|
-
guestSessionIdRef.current =
|
|
364
|
+
guestSessionIdRef.current = chatSessionStorage.createNewTeachMeChatSessionId(chatSessionStorageKey, chatAssistant, organizationName, previousSessionId);
|
|
356
365
|
});
|
|
357
366
|
} catch (error) {
|
|
358
367
|
setMessageLoading(false);
|