I can help you with this migration issue. The readDataStream
function is mentioned in the troubleshooting documentation but not explicitly in the migration guides 1.
Based on the AI SDK documentation, it appears that the readDataStream
function was part of the internal API in version 3.3, and it might have been removed or relocated in newer versions. This is likely why you're not seeing it in the package exports anymore.
Here are a few options to address this issue:
readDataStream
to process stream data, you can now use the documented stream data protocol 1. The AI SDK switched to this protocol in version 3.0.20 and later.readDataStream
, you can process the stream using the newer API methods:// If you're using useChat/useCompletion
const { messages } = useChat({
streamProtocol: 'text', // Use this instead of the older streamMode
// ...other options
});
// Or if you're using streamText directly
const result = streamText({
model: openai('gpt-4o'),
prompt: 'Your prompt here',
onChunk: ({ chunk }) => {
if (chunk.type === 'text-delta') {
// Process the text chunk
console.log(chunk.text);
}
},
});
If you need more specific guidance, could you share how you were using readDataStream
in your application? That would help me provide more targeted migration advice.