@mujian/js-sdk 0.0.6-beta.25 → 0.0.6-beta.27
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.js +9 -2
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -96,7 +96,7 @@ function addDOMPurifyHooks() {
|
|
|
96
96
|
* @returns {string} Encoded message text
|
|
97
97
|
* @copyright https://github.com/kwaroran/risuAI
|
|
98
98
|
*/ function encodeStyleTags(text) {
|
|
99
|
-
const styleRegex = /<style>(
|
|
99
|
+
const styleRegex = /<style>([\s\S]+?)<\/style>/gi;
|
|
100
100
|
return text.replaceAll(styleRegex, (_, match)=>`<custom-style>${encodeURIComponent(match)}</custom-style>`);
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
@@ -770,6 +770,8 @@ async function* callSdk(mujian, content, type = 'generate', signal) {
|
|
|
770
770
|
});
|
|
771
771
|
}
|
|
772
772
|
const NOT_SAVED_MSG_ID_PREFIX = 'not_saved';
|
|
773
|
+
const FALLBACK_MESSAGE = `<!-- 此条HTML消息为系统提示,请勿复读 -->
|
|
774
|
+
哎呀,AI线路好像抽风了,重说一下试试吧~`;
|
|
773
775
|
const useChatStreaming = ({ common, setError, setMessages, mujian })=>{
|
|
774
776
|
const { body } = common;
|
|
775
777
|
const [isStreaming, setIsStreaming] = useState(false);
|
|
@@ -887,10 +889,15 @@ const useChatStreaming = ({ common, setError, setMessages, mujian })=>{
|
|
|
887
889
|
const newMessages = [
|
|
888
890
|
...prev
|
|
889
891
|
];
|
|
890
|
-
|
|
892
|
+
const lastMessage = {
|
|
891
893
|
...newMessages[newMessages.length - 1],
|
|
892
894
|
isStreaming: false
|
|
893
895
|
};
|
|
896
|
+
if (!lastMessage.swipes[lastMessage.activeSwipeId]) {
|
|
897
|
+
lastMessage.swipes[lastMessage.activeSwipeId] = FALLBACK_MESSAGE;
|
|
898
|
+
lastMessage.content = FALLBACK_MESSAGE;
|
|
899
|
+
}
|
|
900
|
+
newMessages[newMessages.length - 1] = lastMessage;
|
|
894
901
|
return newMessages;
|
|
895
902
|
});
|
|
896
903
|
}
|