ai icon indicating copy to clipboard operation
ai copied to clipboard

Allow changing `body` with `useCompletion`

Open mmurto opened this issue 1 year ago • 3 comments

I've got an endpoint that takes custom additional data - it would make using useCompletion a lot easier in many situations if it exposed setBody or something similar.

mmurto avatar Jun 17 '23 08:06 mmurto

Check the docs! Use the body property on useCompletion function Doc

Itsnotaka avatar Jun 17 '23 09:06 Itsnotaka

Check the docs! Use the body property on useCompletion function

I mean to change the body property after instantiating useCompletion, or adding body to the complete call. This is basically what I want to achieve (or setBody before calling complete), with response being the additional data.

const { complete } = useCompletion();

api.edge.search.context.useMutation({
  onSuccess: (response) => {
    complete(query, response);
  },
});

mmurto avatar Jun 17 '23 10:06 mmurto

Good call - ideally all methods that trigger a request should accept an extra optional option, that can contain custom body and headers.

shuding avatar Jun 17 '23 12:06 shuding