ai
ai copied to clipboard
Request body is not sent with useChat after upgrading to >=2.2.26
Description
Install version >2.2.25
Use useChat hook and point the api at a lambda url (haven't tested another backend service)
Try to log the request body, it is undefined
Install version 2.2.25
Works fine
Code example
const { messages, input, handleInputChange, append, isLoading, setMessages } = useChat({
api: process.env.NEXT_PUBLIC_CHAT_LAMBDA_URL,
body: {
functions,
idToken,
...settings,
},
});
in my backend (lambda) I do
console.log('body', event.body);
// INFO body undefined
Change version to "ai": "2.2.25", and it works fine
INFO body
{
"messages": [
...
Additional context
No response
try setting sendExtraMessageFields to true. works for us with v2.2.35
const { messages, input, handleInputChange, append, isLoading, setMessages } = useChat({
api: process.env.NEXT_PUBLIC_CHAT_LAMBDA_URL,
sendExtraMessageFields: true,
body: {
functions,
idToken,
...settings,
},
});
try setting
sendExtraMessageFieldstotrue. works for us withv2.2.35
Hey thanks for the reply, sadly that did not work for me.
This is an issue for me in 3.0.23. Any resolution? body is not dynamic.
This is an issue for me in 3.0.23. Any resolution? body is not dynamic.
You can send in the body in handleSubmit if it's dynamic: https://sdk.vercel.ai/docs/ai-sdk-ui/chatbot#setting-custom-body-fields-per-request