@lota-sdk/ui 0.3.2 → 0.4.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lota-sdk/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"registry": "https://registry.npmjs.org/"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@lota-sdk/shared": "0.
|
|
28
|
+
"@lota-sdk/shared": "0.4.0",
|
|
29
29
|
"ai": "^6.0.145"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
@@ -4,7 +4,7 @@ import type { ChatInit, ChatState, ChatStatus, UIMessage } from 'ai'
|
|
|
4
4
|
import { useCallback, useEffect, useRef, useSyncExternalStore } from 'react'
|
|
5
5
|
|
|
6
6
|
function throttleCallback(callback: () => void, waitMs?: number): () => void {
|
|
7
|
-
if (waitMs
|
|
7
|
+
if (waitMs === undefined) {
|
|
8
8
|
return callback
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -214,20 +214,17 @@ export function useSnapshottingChat<UI_MESSAGE extends UIMessage = UIMessage>({
|
|
|
214
214
|
() => chatRef.current.error,
|
|
215
215
|
)
|
|
216
216
|
|
|
217
|
-
const setMessages = useCallback(
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
217
|
+
const setMessages = useCallback((messagesParam: UI_MESSAGE[] | ((messages: UI_MESSAGE[]) => UI_MESSAGE[])) => {
|
|
218
|
+
if (typeof messagesParam === 'function') {
|
|
219
|
+
messagesParam = messagesParam(chatRef.current.messages)
|
|
220
|
+
}
|
|
222
221
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
[],
|
|
226
|
-
)
|
|
222
|
+
chatRef.current.messages = messagesParam
|
|
223
|
+
}, [])
|
|
227
224
|
|
|
228
225
|
useEffect(() => {
|
|
229
226
|
if (resume) {
|
|
230
|
-
chatRef.current.resumeStream()
|
|
227
|
+
void chatRef.current.resumeStream()
|
|
231
228
|
}
|
|
232
229
|
}, [resume])
|
|
233
230
|
|