Smooth streaming chinese text
You can smooth stream chinese text by using the smoothStream
function with streamText
, and the following regex that splits either on words of chinese characters:
page.tsx
import { smoothStream, streamText } from 'ai';
const result = streamText({ model: yourModel, prompt: 'Your prompt here', experimental_transform: smoothStream({ chunking: /[\u4E00-\u9FFF]|\S+\s+/, }),});