Open xmlking opened 6 months ago
I have experienced this issue as well. I work around it using
let myData: T;
const { input, handleSubmit, messages } = useChat({ sendExtraMessageFields: true, });
$: body = { myData };
async function submitHandler(event: SubmitEvent) {
event.preventDefault();
handleSubmit(event, {
options: {
body
}
});
}
Description
body
is set only once foruseCompletion
, during initialization :body: { text: value }
For my case I need to pass extra param e.g.,
text
to my backend api:api/completion
.text
is alway gettingundefined
on API side.The React
useCompletion
SDK seams working fine. This looks like a bug only in Svelte implementation.To Reproduce
.env
then run:turbo dev--filter=console
Code example
body
is set only once here during initialization :body: { text: value }
For my case I need to pass extra param
text
to my backend api:api/completion
,text
is alway gettingundefined
on API side.The React
useCompletion
API seams working fine. this looks like a bug in Svelte implementationmy +server.ts
Additional context
Code problem location: https://github.com/xmlking/spectacular/blob/55872cfeb0207801ac26a1e6f03c63d312033554/apps/console/src/lib/components/magic-spell-textarea/magic-spell-textarea.svelte#L29