{messages.map((message) => (
{message.parts.map((part, i) => {
switch (part.type) {
case "text":
return
{part.text}
;
}
})}
))}
);
};
export default AI;
```
By leveraging this integration, we can easily manage the state of the AI request and update the UI as soon as the response is ready.
TurboStarter ships with a ready-to-use implementation of AI chat, allowing you to see this solution in action. Feel free to reuse or modify it according to your needs.