@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.
@@ -119,6 +119,10 @@ const NormalChat = ({
119
119
  useEffect(() => {
120
120
  onStreamingStateChange == null ? void 0 : onStreamingStateChange(isStreaming);
121
121
  }, [isStreaming, onStreamingStateChange]);
122
+ const accessTokenRef = useRef(user == null ? void 0 : user.accessToken);
123
+ useEffect(() => {
124
+ accessTokenRef.current = user == null ? void 0 : user.accessToken;
125
+ }, [user == null ? void 0 : user.accessToken]);
122
126
  useEffect(() => {
123
127
  isMountedRef.current = true;
124
128
  return () => {
@@ -549,6 +553,11 @@ const NormalChat = ({
549
553
  setIsStreamEnd((_H = (_G = data == null ? void 0 : data.chatStream) == null ? void 0 : _G.continueChatResult) == null ? void 0 : _H.isEnd);
550
554
  }
551
555
  };
556
+ const liveHeaders = {
557
+ get Authorization() {
558
+ return accessTokenRef.current ? `Bearer ${accessTokenRef.current}` : void 0;
559
+ }
560
+ };
552
561
  const handleStream = (event, isFirstQuestionSent, userInputParam, isValidationFailure = false, customId, setIsLoading) => {
553
562
  var _a, _b;
554
563
  const contentSource = userInputParam !== void 0 ? userInputParam : userInput || "";
@@ -644,9 +653,7 @@ const NormalChat = ({
644
653
  chatPreviewId: chatPreviewIdRef.current,
645
654
  customMetaData,
646
655
  aiModel: "",
647
- additionalHeaders: (user == null ? void 0 : user.accessToken) ? {
648
- Authorization: `Bearer ${user.accessToken}`
649
- } : void 0,
656
+ additionalHeaders: liveHeaders,
650
657
  onStreamEvent: (data) => {
651
658
  if (!isMountedRef.current || streamGenerationRef.current !== streamGeneration) return;
652
659
  handleMessages(
@@ -694,6 +701,7 @@ const NormalChat = ({
694
701
  setInitialLoadingMessage(loadingMessage);
695
702
  streamStartTimesRef.current.set(params.requestId, Date.now());
696
703
  currentStreamRequestIdRef.current = params.requestId;
704
+ console.log("Chat Stream Params:", params);
697
705
  startChatStream(params);
698
706
  }
699
707
  setIsLoading && setIsLoading(false);