Hacker News new | past | comments | ask | show | jobs | submit login
AI SDK 3.0: Stream React Components from LLMs to deliver richer user experiences (vercel.com)
9 points by MaxLeiter 8 months ago | hide | past | favorite | 3 comments



I am confused about the demo. Is the AI generating the `Weather` component that is used to render the response, or is it just returning the weather in a structure that the `Weather` component expects?

The example code is confusing me, because there is a `render()` method that references both `<Weather>` and `<Spinner>`, but neither of these JSX components are imported into the script. (In fact, `getWeather()` isn't defined, either.) Is that the part I'm missing? The LLM will just see these component references and know how to render them? Or is the codeblock wrong? Because this is technically invalid syntax (reference to undefined).


The AI is calling a function (https://platform.openai.com/docs/guides/function-calling) that is mapped to developer-controlled logic. The easiest thing to do is render specific UIs for every function call, but you can render however you'd like.

We kept the code snippets in the blog post brief, but you can see the full code for the demo here: https://github.com/vercel/ai/tree/main/examples/next-ai-rsc


You can check out the demo here: https://sdk.vercel.ai/demo

tip: have your network tab open so you can inspect the responses as components stream in




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: