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

docs: add multi-step usechat suggestion #3467

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nicoalbanese
Copy link
Contributor

No description provided.

Comment on lines +99 to +113
## Multi-Step Calls with `useChat`

To access multi-step calls on the client with [ `useChat` ](/docs/reference/ai-sdk-ui/use-chat), you should set `maxSteps` within the `useChat` options rather than within the `generateText` or `streamText` call. This will allow you to access all steps in callbacks like `onToolCall` and `onFinish`.

```tsx highlight="2"
const { messages } = useChat({
maxSteps: 3,
onFinish: message => {
// access message from each step
},
onToolCall: ({ toolCall }) => {
// access tool call from each step
},
});
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm they need to work in combination. Server side roundtrips have many advantages.

Copy link
Collaborator

@lgrammel lgrammel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's hold on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants