vercel / ai-chatbot

A full-featured, hackable Next.js AI chatbot built by Vercel
https://chat.vercel.ai
Other
9.87k stars 2.5k forks source link

No response after 6 rounds of dialogues #335

Open Ray8716397 opened 6 months ago

Ray8716397 commented 6 months ago

Screenshot from 2024-05-10 10-21-42

i modified the submitUserMessage function for using langchain like: async function submitUserMessage(content: string) { 'use server' console.error(content); const aiState = getMutableAIState()

aiState.update({
    ...aiState.get(),
    messages: [
        ...aiState.get().messages,
        {
            id: nanoid(),
            role: 'user',
            content
        }
    ]
})

const textStream = createStreamableUI(<SpinnerMessage/>)
const msgs = aiState.get().messages;
// console.log(aiState.get().messages[]);
runAsyncFnWithoutBlocking(async () => {
    let buf = "";
    try {
        const res = await chain.call({
            input: content,
            callbacks: [
                {
                    handleLLMNewToken(token) {
                        buf += token;
                        textStream.update(<BotMessage content={buf}/>);
                    },
                    // handleLLMEnd(token) {
                    //     // emitter.emit("data", { event: "end" });
                    //   console.log("stream:\n", token);
                    //   textStream.done(<BotMessage content={buf} />);
                    // },
                },
            ],
        });
    } catch (e) {
        console.error(e);
    } finally {
        textStream.done(<BotMessage content={buf}/>);
    }
})

return {
    id: nanoid(),
    display: textStream.value
}

}

but I change Got no response after 6 rounds of dialogues,how can i debug it or how can i solve it,please help

Jurredr commented 5 months ago

I'm experiencing the exact same issue, did you ever end up solving this?