Skip to content
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

with ai-sdk/vue on v4.0 I can't edit the body anymore #3763

Closed
cosbgn opened this issue Nov 19, 2024 · 1 comment
Closed

with ai-sdk/vue on v4.0 I can't edit the body anymore #3763

cosbgn opened this issue Nov 19, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@cosbgn
Copy link

cosbgn commented Nov 19, 2024

Description

I used to do something like this:

const { messages, input, handleSubmit } = useChat()
const callApi = async(e, chatRequestOptions) => { 
	const new_opt = {
			...chatRequestOptions?.options,
			body: { ...chatRequestOptions?.options?.body, model: ai_model.value }
	}
	return handleSubmit(e, { ...chatRequestOptions, options: new_opt }) 
}

This was working perfectly until v4. It allowed me to dynamically edit the body ( and pass new properties like ai_model.value).
I can't use the useChat() body option directly because that won't be reactive, i.e. it will be set on first load an never change.

Code example

const { messages, input, handleSubmit } = useChat()
const callApi = async(e, chatRequestOptions) => { 
	const new_opt = {
			...chatRequestOptions?.options,
			body: { ...chatRequestOptions?.options?.body, model: ai_model.value }
	}
	return handleSubmit(e, { ...chatRequestOptions, options: new_opt }) 
}

AI provider

ai sdk v4.0 (VUE)

Additional context

No response

@cosbgn cosbgn added the bug Something isn't working label Nov 19, 2024
@cosbgn
Copy link
Author

cosbgn commented Nov 19, 2024

fixed with:

const callApi = async (e, chatRequestOptions) => {
  const updatedRequestOptions = {
    ...chatRequestOptions,
    body: {
      ...chatRequestOptions?.body,
      model: ai_model.value
    }
  }
  return handleSubmit(e, updatedRequestOptions)
}

@cosbgn cosbgn closed this as completed Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant