@mujian/js-sdk 0.0.6-beta.51 → 0.0.6-beta.53
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 +3 -10
- package/dist/umd/react.js +3 -10
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -977,13 +977,6 @@ class UnexpectedSseEndingError extends Error {
|
|
|
977
977
|
this.cause = cause;
|
|
978
978
|
}
|
|
979
979
|
}
|
|
980
|
-
class InsufficientBalanceError extends Error {
|
|
981
|
-
constructor(message, cause){
|
|
982
|
-
super(message);
|
|
983
|
-
this.name = this.constructor.name;
|
|
984
|
-
this.cause = cause;
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
980
|
async function* callSdk(mujian, content, type = 'generate', signal) {
|
|
988
981
|
const queue = [];
|
|
989
982
|
let resolveWait = null;
|
|
@@ -1164,7 +1157,7 @@ const useChatStreaming = ({ common, setError, setMessages, mujian })=>{
|
|
|
1164
1157
|
}
|
|
1165
1158
|
} catch (error) {
|
|
1166
1159
|
console.error('Error:', error);
|
|
1167
|
-
|
|
1160
|
+
setError(new SendMessageError('Send message failed', error));
|
|
1168
1161
|
setMessages((prev)=>prev.slice(0, -1));
|
|
1169
1162
|
} finally{
|
|
1170
1163
|
setIsStreaming(false);
|
|
@@ -1188,7 +1181,7 @@ const useChat = ({ body, onError, onFinish, pageSize })=>{
|
|
|
1188
1181
|
if (error) onError?.(error);
|
|
1189
1182
|
};
|
|
1190
1183
|
const isLoadingMore = useRef(false);
|
|
1191
|
-
const { data, loadMoreAsync, mutate } = useInfiniteScroll(async (current)=>{
|
|
1184
|
+
const { data, loadMoreAsync, loadingMore, loading, mutate, error: messageLoadError } = useInfiniteScroll(async (current)=>{
|
|
1192
1185
|
isLoadingMore.current = true;
|
|
1193
1186
|
if (current?.noMore) return {
|
|
1194
1187
|
noMore: true,
|
|
@@ -1360,7 +1353,7 @@ const useChat = ({ body, onError, onFinish, pageSize })=>{
|
|
|
1360
1353
|
editMessage,
|
|
1361
1354
|
deleteMessage,
|
|
1362
1355
|
loadMoreMessage,
|
|
1363
|
-
messagesStatus: 'loading'
|
|
1356
|
+
messagesStatus: messageLoadError ? 'error' : loadingMore || loading ? 'loading' : data?.noMore ? 'all-loaded' : 'has-more'
|
|
1364
1357
|
};
|
|
1365
1358
|
};
|
|
1366
1359
|
export { MdRenderer, MujianProvider, MujianSpinner, Thread, useChat, useMujian };
|
package/dist/umd/react.js
CHANGED
|
@@ -8443,13 +8443,6 @@ ${content}
|
|
|
8443
8443
|
this.cause = cause;
|
|
8444
8444
|
}
|
|
8445
8445
|
}
|
|
8446
|
-
class InsufficientBalanceError extends Error {
|
|
8447
|
-
constructor(message, cause){
|
|
8448
|
-
super(message);
|
|
8449
|
-
this.name = this.constructor.name;
|
|
8450
|
-
this.cause = cause;
|
|
8451
|
-
}
|
|
8452
|
-
}
|
|
8453
8446
|
async function* callSdk(mujian, content, type = 'generate', signal) {
|
|
8454
8447
|
const queue = [];
|
|
8455
8448
|
let resolveWait = null;
|
|
@@ -8630,7 +8623,7 @@ ${content}
|
|
|
8630
8623
|
}
|
|
8631
8624
|
} catch (error) {
|
|
8632
8625
|
console.error('Error:', error);
|
|
8633
|
-
|
|
8626
|
+
setError(new SendMessageError('Send message failed', error));
|
|
8634
8627
|
setMessages((prev)=>prev.slice(0, -1));
|
|
8635
8628
|
} finally{
|
|
8636
8629
|
setIsStreaming(false);
|
|
@@ -8654,7 +8647,7 @@ ${content}
|
|
|
8654
8647
|
if (error) onError?.(error);
|
|
8655
8648
|
};
|
|
8656
8649
|
const isLoadingMore = (0, external_React_.useRef)(false);
|
|
8657
|
-
const { data, loadMoreAsync, mutate } = useInfiniteScroll(async (current)=>{
|
|
8650
|
+
const { data, loadMoreAsync, loadingMore, loading, mutate, error: messageLoadError } = useInfiniteScroll(async (current)=>{
|
|
8658
8651
|
isLoadingMore.current = true;
|
|
8659
8652
|
if (current?.noMore) return {
|
|
8660
8653
|
noMore: true,
|
|
@@ -8826,7 +8819,7 @@ ${content}
|
|
|
8826
8819
|
editMessage,
|
|
8827
8820
|
deleteMessage,
|
|
8828
8821
|
loadMoreMessage,
|
|
8829
|
-
messagesStatus: 'loading'
|
|
8822
|
+
messagesStatus: messageLoadError ? 'error' : loadingMore || loading ? 'loading' : data?.noMore ? 'all-loaded' : 'has-more'
|
|
8830
8823
|
};
|
|
8831
8824
|
};
|
|
8832
8825
|
})();
|