@e-llm-studio/instant-learning 1.3.4 → 1.3.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.
@@ -129,6 +129,10 @@ const NormalChat = ({
129
129
  React.useEffect(() => {
130
130
  onStreamingStateChange == null ? void 0 : onStreamingStateChange(isStreaming);
131
131
  }, [isStreaming, onStreamingStateChange]);
132
+ const accessTokenRef = React.useRef(user == null ? void 0 : user.accessToken);
133
+ React.useEffect(() => {
134
+ accessTokenRef.current = user == null ? void 0 : user.accessToken;
135
+ }, [user == null ? void 0 : user.accessToken]);
132
136
  React.useEffect(() => {
133
137
  isMountedRef.current = true;
134
138
  return () => {
@@ -559,6 +563,11 @@ const NormalChat = ({
559
563
  setIsStreamEnd((_H = (_G = data == null ? void 0 : data.chatStream) == null ? void 0 : _G.continueChatResult) == null ? void 0 : _H.isEnd);
560
564
  }
561
565
  };
566
+ const liveHeaders = {
567
+ get Authorization() {
568
+ return accessTokenRef.current ? `Bearer ${accessTokenRef.current}` : void 0;
569
+ }
570
+ };
562
571
  const handleStream = (event, isFirstQuestionSent, userInputParam, isValidationFailure = false, customId, setIsLoading) => {
563
572
  var _a, _b;
564
573
  const contentSource = userInputParam !== void 0 ? userInputParam : userInput || "";
@@ -654,9 +663,7 @@ const NormalChat = ({
654
663
  chatPreviewId: chatPreviewIdRef.current,
655
664
  customMetaData,
656
665
  aiModel: "",
657
- additionalHeaders: (user == null ? void 0 : user.accessToken) ? {
658
- Authorization: `Bearer ${user.accessToken}`
659
- } : void 0,
666
+ additionalHeaders: liveHeaders,
660
667
  onStreamEvent: (data) => {
661
668
  if (!isMountedRef.current || streamGenerationRef.current !== streamGeneration) return;
662
669
  handleMessages(
@@ -704,6 +711,7 @@ const NormalChat = ({
704
711
  setInitialLoadingMessage(loadingMessage);
705
712
  streamStartTimesRef.current.set(params.requestId, Date.now());
706
713
  currentStreamRequestIdRef.current = params.requestId;
714
+ console.log("Chat Stream Params:", params);
707
715
  streamingResponse.startChatStream(params);
708
716
  }
709
717
  setIsLoading && setIsLoading(false);