-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Starting with 2.1.13 streamed responses not rendered anymore - works fine with 2.1.12 #260
Comments
Here to confirm the same with my results. Here's my code using langchain
What I'm seeing is the message array in the frontend stays empty This will result in a repeat stream of I am also seeing a response in devtools |
Yep, also seeing this (seems to affect both the chat and completion APIs). The examples in the docs here don't work with 2.1.13: Works after downgrading to 2.1.12. |
Saw the same issue as well |
Seems like this commit is probably the issue, since it's the only commit with actual source code changed between 2.1.12 (works fine) and 2.1.13 (broken hook) fd82961 |
Same issue. The returned value { completion: "" } |
Same issue with huggingface |
I thought I had gone insane when all of the sudden yesterday everything just didn't work. Glad it wasn't just me. Here's a quick fix/revert that fixes it (React/Next.js, but same idea for other frameworks, just provide an id, you can check the old id generation from this commit fd82961): import { useId } from 'react';
import { UseChatOptions, useChat } from 'ai/react'
const useChatWrapper = (options?: UseChatOptions) => {
const id = useId();
const chat = useChat({...(options ?? {}), id})
return chat;
};
export default function Chat() {
const { messages, input, handleInputChange, handleSubmit } = useChatWrapper()
....
} |
This is amazing, this fixed it. I've been trying to fix this for the last 2 hours and was almost losing my mind. |
Amazing ! It's worked. |
For anyone wanting to actually fix this with a PR and still use nanoid-based ids, change it so that the id-generating function is not called on each render as it currently clearly is. Likely this was missed during testing as I assume they have an id that they provide to My fix above is just one way of ensuring there's an id that does not change. You can also just use import { useChat } from 'ai/react'
export default function Chat() {
const { messages, input, handleInputChange, handleSubmit } = useChat({ id: "hello world" })
....
} |
This has been resolved. #264 . Sorry about that! |
@jaredpalmer I'm not sure if there was an actual reason for using nanoid based ids, but if there was, at least in react, just placing the id value in the persistent state to avoid running it on each render should suffice, i.e. import {useState} from 'react'
...
const [chatId,] = useState(id || `chat-${nanoid()}`) Again, not sure whether there was a reason for the change, and I am not an expert in svelte nor vue, but I assume they have similar mechanisms to avoid such issues. |
When using the exact sample application as provided in the docs, chat messages are rendered as expected with version
2.1.12
. However changing the package to2.1.13
does not render the messages anymore.The requests work fine and responses are coming back to application (seen in chrome devtools), but the messages are not rendered anymore.
The text was updated successfully, but these errors were encountered: