@e-llm-studio/instant-learning 1.3.18 → 1.3.20

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.
Files changed (51) hide show
  1. package/dist/cjs/features/IL-OTJ/_components/ChatComponents/ChatComponent.js +61 -10
  2. package/dist/cjs/features/IL-OTJ/_components/ChatComponents/ChatComponent.js.map +1 -1
  3. package/dist/cjs/features/IL-OTJ/_components/ChatComponents/ChatComponent.module.css.js +2 -2
  4. package/dist/cjs/features/IL-OTJ/_components/CriticalGaps.js +31 -15
  5. package/dist/cjs/features/IL-OTJ/_components/CriticalGaps.js.map +1 -1
  6. package/dist/cjs/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.js +3 -1
  7. package/dist/cjs/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.js.map +1 -1
  8. package/dist/cjs/features/IL-OTJ/_components/MessageRendering/MessageRendering.js +31 -8
  9. package/dist/cjs/features/IL-OTJ/_components/MessageRendering/MessageRendering.js.map +1 -1
  10. package/dist/cjs/features/IL-OTJ/helpers/rhsFieldAttention.js +19 -0
  11. package/dist/cjs/features/IL-OTJ/helpers/rhsFieldAttention.js.map +1 -0
  12. package/dist/cjs/features/LearningManagement/components/InstantLearningModal.js +2 -0
  13. package/dist/cjs/features/LearningManagement/components/InstantLearningModal.js.map +1 -1
  14. package/dist/cjs/features/LearningManagement/components/InstantLearningModalDynamic.js +5 -2
  15. package/dist/cjs/features/LearningManagement/components/InstantLearningModalDynamic.js.map +1 -1
  16. package/dist/cjs/schema-driven/BPARenderer.js +51 -2
  17. package/dist/cjs/schema-driven/BPARenderer.js.map +1 -1
  18. package/dist/cjs/schema-driven/utils/PayloadUtils.js +2 -2
  19. package/dist/cjs/schema-driven/utils/PayloadUtils.js.map +1 -1
  20. package/dist/features/IL-OTJ/_components/ChatComponents/ChatComponent.js +62 -11
  21. package/dist/features/IL-OTJ/_components/ChatComponents/ChatComponent.js.map +1 -1
  22. package/dist/features/IL-OTJ/_components/ChatComponents/ChatComponent.module.css.js +2 -2
  23. package/dist/features/IL-OTJ/_components/CriticalGaps.js +31 -15
  24. package/dist/features/IL-OTJ/_components/CriticalGaps.js.map +1 -1
  25. package/dist/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.js +3 -1
  26. package/dist/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.js.map +1 -1
  27. package/dist/features/IL-OTJ/_components/MessageRendering/MessageRendering.js +31 -8
  28. package/dist/features/IL-OTJ/_components/MessageRendering/MessageRendering.js.map +1 -1
  29. package/dist/features/IL-OTJ/helpers/rhsFieldAttention.js +14 -0
  30. package/dist/features/IL-OTJ/helpers/rhsFieldAttention.js.map +1 -0
  31. package/dist/features/LearningManagement/components/InstantLearningModal.js +3 -1
  32. package/dist/features/LearningManagement/components/InstantLearningModal.js.map +1 -1
  33. package/dist/features/LearningManagement/components/InstantLearningModalDynamic.js +5 -2
  34. package/dist/features/LearningManagement/components/InstantLearningModalDynamic.js.map +1 -1
  35. package/dist/schema-driven/BPARenderer.js +52 -3
  36. package/dist/schema-driven/BPARenderer.js.map +1 -1
  37. package/dist/schema-driven/utils/PayloadUtils.js +2 -2
  38. package/dist/schema-driven/utils/PayloadUtils.js.map +1 -1
  39. package/dist/types/src/features/IL-OTJ/_components/ChatComponents/ChatComponent.d.ts.map +1 -1
  40. package/dist/types/src/features/IL-OTJ/_components/CriticalGaps.d.ts +2 -1
  41. package/dist/types/src/features/IL-OTJ/_components/CriticalGaps.d.ts.map +1 -1
  42. package/dist/types/src/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.d.ts +2 -1
  43. package/dist/types/src/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.d.ts.map +1 -1
  44. package/dist/types/src/features/IL-OTJ/_components/MessageRendering/MessageRendering.d.ts.map +1 -1
  45. package/dist/types/src/features/IL-OTJ/helpers/rhsFieldAttention.d.ts +7 -0
  46. package/dist/types/src/features/IL-OTJ/helpers/rhsFieldAttention.d.ts.map +1 -0
  47. package/dist/types/src/features/LearningManagement/components/InstantLearningModal.d.ts.map +1 -1
  48. package/dist/types/src/features/LearningManagement/components/InstantLearningModalDynamic.d.ts.map +1 -1
  49. package/dist/types/src/schema-driven/BPARenderer.d.ts.map +1 -1
  50. package/dist/types/src/schema-driven/utils/PayloadUtils.d.ts.map +1 -1
  51. package/package.json +4 -4
@@ -24,6 +24,8 @@ var utils = require('../../helpers/utils.js');
24
24
  var SendButton = require('../_svg/SendButton.js');
25
25
  var SparkleIcon = require('../_svg/SparkleIcon.js');
26
26
  var UserIcon = require('../_svg/UserIcon.js');
27
+ var messageRenderingUtils = require('../../helpers/message-rendering-utils.js');
28
+ var rhsFieldAttention = require('../../helpers/rhsFieldAttention.js');
27
29
  var useAuthStore = require('../../../LearningManagement/store/useAuthStore.js');
28
30
  var useLMSConfigStore = require('../../../LearningManagement/store/useLMSConfigStore.js');
29
31
 
@@ -80,6 +82,7 @@ const createGuidelineAssistantMessage = (learningTerm) => `I would be happy to h
80
82
  \`\`\`
81
83
  -->`;
82
84
  const CRITICAL_GAP_RESPONSE_PREFIX = "Here is my response for the critical gap(s):";
85
+ process.env.NODE_ENV === "development";
83
86
  const ChatComponent = ({
84
87
  chatAssistantName,
85
88
  organizationName,
@@ -191,9 +194,43 @@ const ChatComponent = ({
191
194
  const isInputEmpty = React.useMemo(() => {
192
195
  return (userInput == null ? void 0 : userInput.trim()) === "" || isStreaming;
193
196
  }, [userInput, isStreaming]);
197
+ const rhsInteraction = React.useMemo(() => {
198
+ if (!Array.isArray(messages) || messages.length === 0) {
199
+ return { isActive: false, fieldIds: [] };
200
+ }
201
+ const lastMessage = messages[messages.length - 1];
202
+ if ((lastMessage == null ? void 0 : lastMessage.role) !== "assistant" || !(lastMessage == null ? void 0 : lastMessage.isEnd)) {
203
+ return { isActive: false, fieldIds: [] };
204
+ }
205
+ let isActive = false;
206
+ const content = typeof lastMessage.content === "string" ? lastMessage.content : "";
207
+ let blocks = [];
208
+ try {
209
+ blocks = messageRenderingUtils.parseJsonBlocks(content);
210
+ } catch (error) {
211
+ console.warn("[IL-OTJ][rhs-interaction] Failed to parse critical-gap data.", error);
212
+ return { isActive: false, fieldIds: [] };
213
+ }
214
+ const fieldIds = blocks.filter((block) => (block == null ? void 0 : block.property) === "critical_gaps").flatMap((block) => {
215
+ var _a;
216
+ const criticalGaps = ((_a = block == null ? void 0 : block.data) == null ? void 0 : _a.critical_gaps) || (block == null ? void 0 : block.data);
217
+ if (!criticalGaps || typeof criticalGaps !== "object") return [];
218
+ const gaps = (criticalGaps == null ? void 0 : criticalGaps.gap_cards) || (criticalGaps == null ? void 0 : criticalGaps.gaps) || [];
219
+ return (Array.isArray(gaps) ? gaps : [gaps]).flatMap((gap) => {
220
+ var _a2, _b;
221
+ if (!gap || typeof gap !== "object") return [];
222
+ if (((_a2 = gap == null ? void 0 : gap.interaction) == null ? void 0 : _a2.interaction_type) !== "rhs" && (gap == null ? void 0 : gap.inputType) !== "rhs") return [];
223
+ isActive = true;
224
+ const options = ((_b = gap == null ? void 0 : gap.interaction) == null ? void 0 : _b.options) || (gap == null ? void 0 : gap.options) || [];
225
+ return (Array.isArray(options) ? options : [options]).map((option) => (option == null ? void 0 : option.highlight_rhs_field) || (option == null ? void 0 : option.highlightRhsField)).filter((fieldId) => typeof fieldId === "string" && fieldId.trim().length > 0);
226
+ });
227
+ });
228
+ return { isActive, fieldIds: Array.from(new Set(fieldIds)) };
229
+ }, [messages]);
230
+ const { isActive: isRhsInteractionActive, fieldIds: rhsGapFieldIds } = rhsInteraction;
194
231
  const isTextareaDisabled = React.useMemo(
195
- () => isFormValidating,
196
- [isFormValidating]
232
+ () => isFormValidating || isRhsInteractionActive,
233
+ [isFormValidating, isRhsInteractionActive]
197
234
  );
198
235
  const isLastMessageUser = React.useMemo(
199
236
  () => {
@@ -203,9 +240,14 @@ const ChatComponent = ({
203
240
  [messages]
204
241
  );
205
242
  const isSendButtonDisabled = React.useMemo(
206
- () => isInputEmpty || isFormValidating || !!isGlobalEditActive || isLastMessageUser,
207
- [isInputEmpty, isFormValidating, isGlobalEditActive, isLastMessageUser]
243
+ () => isInputEmpty || isTextareaDisabled || !!isGlobalEditActive || isLastMessageUser,
244
+ [isInputEmpty, isTextareaDisabled, isGlobalEditActive, isLastMessageUser]
208
245
  );
246
+ const remindRhsField = React.useCallback((event) => {
247
+ if (!isRhsInteractionActive) return;
248
+ event.preventDefault();
249
+ rhsGapFieldIds.forEach((fieldId) => rhsFieldAttention.highlightRhsField(fieldId));
250
+ }, [isRhsInteractionActive, rhsGapFieldIds]);
209
251
  React.useEffect(() => {
210
252
  if (initialDraftMessage && !userInput) {
211
253
  setUserInput(initialDraftMessage);
@@ -293,7 +335,7 @@ const ChatComponent = ({
293
335
  skeletonContent: message
294
336
  };
295
337
  setMessages((prev) => [...prev, skeletonMsg]);
296
- handleStream(new KeyboardEvent("keydown", { key: "Enter" }), false, message, false, skId);
338
+ handleStream(new KeyboardEvent("keydown", { key: "Enter" }), false, message, false, skId, void 0, true);
297
339
  setHighlightedMessageId(skId);
298
340
  setSendMessageInChat && setSendMessageInChat("");
299
341
  setTimeout(() => {
@@ -776,7 +818,7 @@ ${liveContent}` : liveContent;
776
818
  streamTimeoutRefsMap.current.set(requestId, timer);
777
819
  }
778
820
  }, [handleStreamTimeout, socketTimeOutInMilliSeconds]);
779
- const handleStream = async (event, isFirstQuestionSent, userInputParam, isValidationFailure = false, customId, setIsLoading) => {
821
+ const handleStream = async (event, isFirstQuestionSent, userInputParam, isValidationFailure = false, customId, setIsLoading, allowRhsInteractionBypass = false) => {
780
822
  var _a, _b, _c, _d, _e, _f;
781
823
  const contentSource = userInputParam !== void 0 ? userInputParam : userInput || "";
782
824
  let finalInput = contentSource.trim();
@@ -785,7 +827,7 @@ ${liveContent}` : liveContent;
785
827
  (_a = event == null ? void 0 : event.preventDefault) == null ? void 0 : _a.call(event);
786
828
  }
787
829
  const isLastMessageUser2 = ((_b = messages[messages.length - 1]) == null ? void 0 : _b.role) === "user";
788
- if (!finalInput || isStreaming || isRequestInFlightRef.current || isLastMessageUser2 || (event == null ? void 0 : event.key) && !isEnterKey) {
830
+ if (!finalInput || isRhsInteractionActive && !allowRhsInteractionBypass || isStreaming || isRequestInFlightRef.current || isLastMessageUser2 || (event == null ? void 0 : event.key) && !isEnterKey) {
789
831
  return;
790
832
  }
791
833
  if (isInitialAddChatMessageFlow) {
@@ -1255,7 +1297,7 @@ ${liveContent}` : liveContent;
1255
1297
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: ChatComponent_module["default"].inputAreaWrapper, children: /* @__PURE__ */ jsxRuntime.jsx(
1256
1298
  Tooltip__default["default"],
1257
1299
  {
1258
- title: isFormValidating ? "Please wait for the validation to be completed." : "",
1300
+ title: isRhsInteractionActive ? "Please fill the respective field in the form to continue." : isFormValidating ? "Please wait for the validation to be completed." : "",
1259
1301
  children: /* @__PURE__ */ jsxRuntime.jsxs(
1260
1302
  "div",
1261
1303
  {
@@ -1279,12 +1321,12 @@ ${liveContent}` : liveContent;
1279
1321
  children: /* @__PURE__ */ jsxRuntime.jsx(ScrollToBottom.ScrollToBottom, {})
1280
1322
  }
1281
1323
  ),
1282
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { width: "100%", display: "flex" }, children: [
1324
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ChatComponent_module["default"].chatInputRow, children: [
1283
1325
  /* @__PURE__ */ jsxRuntime.jsx(
1284
1326
  "textarea",
1285
1327
  {
1286
1328
  ref: textAreaRef,
1287
- placeholder: textareaPlaceholder,
1329
+ placeholder: isRhsInteractionActive ? "Please fill the respective field in the form to continue." : isFormValidating ? "Please wait for the validation to be completed." : textareaPlaceholder,
1288
1330
  value: userInput || "",
1289
1331
  onChange: (e) => {
1290
1332
  setUserInput(e.target.value);
@@ -1302,6 +1344,15 @@ ${liveContent}` : liveContent;
1302
1344
  }
1303
1345
  }
1304
1346
  ),
1347
+ isRhsInteractionActive && /* @__PURE__ */ jsxRuntime.jsx(
1348
+ "button",
1349
+ {
1350
+ type: "button",
1351
+ className: ChatComponent_module["default"].rhsTextareaBlocker,
1352
+ "aria-label": "Return to the highlighted form field",
1353
+ onClick: remindRhsField
1354
+ }
1355
+ ),
1305
1356
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: ChatComponent_module["default"].sendButtonWrapper, children: /* @__PURE__ */ jsxRuntime.jsx(
1306
1357
  "button",
1307
1358
  {