'use client'; import { readStreamableValue } from '@ai-sdk/rsc'; import { useState } from 'react'; import { generateCompletion } from './generate-completion'; export default function Chat() { const [input, setInput] = useState(''); const [completion, setCompletion] = useState(''); const handleInputChange = (event: React.ChangeEvent) => { setInput(event.target.value); }; return (

RSC Completion Example

{completion}
{ e.preventDefault(); const streamableCompletion = await generateCompletion(input); for await (const text of readStreamableValue(streamableCompletion)) { setCompletion(text ?? ''); } }} >
); }