-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
"Proxy object could not be cloned." - Fix proposal #193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
After several debugging, it was found that streamText initialisation called the structuredClone() function on messages. The problem is that messages is an object containing vue3 proxies, that can not be cloned. My proposed fix is to remove those proxies before passing messages to streamText
✅ Deploy Preview for airi-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for airi-vtuber ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
🤔 We have already called airi/packages/stage-ui/src/stores/chat.ts Lines 136 to 142 in 2dbeccc
|
This reverts commit 1575d30.
rest.tool_results is also a proxy that was not removed properly
Was it working on your side ? Maybe my setup is in cause 🤔 Well, I tried to run const newMessages = messages.value.slice(0, messages.value.length - 1).map((msg) => {
if (msg.role === 'assistant') {
const { slices: _, ...rest } = msg // exclude slices
const a = toRaw(rest)
return structuredClone(a) // FAILS HERE : Error sending message: DOMException: Proxy object could not be cloned.
}
const a = toRaw(msg)
return structuredClone(a)
}) Which didn't worked. I played around, displaying the content of So, we just need to add the following : if (msg.role === 'assistant') {
const { slices: _, ...rest } = msg // exclude slices
rest.tool_results = toRaw(rest.tool_results) // ADDED FIX
return toRaw(rest) I'll also revert what I did previously, this single line is more efficient that looping through the whole object |
Thanks for submitting the issue along with the fixes. Let me take a look into this. Either |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks, I really forgot to call toRaw
for tool call results.
Oh ok. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
* Fix for proxy could not be cloned error After several debugging, it was found that streamText initialisation called the structuredClone() function on messages. The problem is that messages is an object containing vue3 proxies, that can not be cloned. My proposed fix is to remove those proxies before passing messages to streamText * Revert "Fix for proxy could not be cloned error" This reverts commit 1575d30. * Fix for proxy clone error rest.tool_results is also a proxy that was not removed properly
Hi !
After some extensive debugging, I found the problem causing the error I encountered in #192 and was able to write a possible fix to it.
Description
In
airi/packages/stage-ui/src/stores/llm.ts
Lines 21 to 28 in 2dbeccc
streamText
object, an answer from the LLM. This object is generated by the package@xsai/stream-text
.By looking at the code from this package, I can see the following :
When instantiating a new
streamText
,messages
are passed tostructuredClone()
function. Sincemessages
is an object containing vue3 proxies somewhere, it fails ( Proxy object could not be cloned )The solution I found is to use the function
toRaw()
provided by vue on every properties ofmessages
using a convenient recursive function I added,toRawObject()
.That way,
structuredClone()
can be used without any trouble.Linked Issues
Fixes #192
Additional context
I think this is somewhat related to https://stackoverflow.com/questions/71075490/how-to-make-a-structuredclone-of-a-proxy-object
Before the fix :


After :