You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using the latest ai and @ai-sdk/openai versions. I use openai, streamText, and createStreamableValue from the packages to generate a response based on user query. I copied the example from here and while it does work, most of the time I get some out of order responses, which also messes up my markdown formatter. Here is what a bad response looks like.
Code example
// server side code'use server';import{openai}from'@ai-sdk/openai';import{streamText,typeCoreMessage}from'ai';import{createStreamableValue}from'ai/rsc';importtype{SearchResponse}from'@/lib/search';import{read}from'@/lib/jina';constsystemPrompt=`REDACTED\n\n`;constgenerate=async(query: string,content: string)=>{'use server';conststream=createStreamableValue('');constmessages=[{role: 'system',content: systemPrompt+content},{role: 'user',content: query,},]asCoreMessage[];(async()=>{const{ textStream }=awaitstreamText({
messages,model: openai('gpt-4o'),});forawait(consttextoftextStream){stream.update(text);}stream.done();})();returnstream.value;};exportdefaultgenerate;
Description
I'm using the latest
ai
and@ai-sdk/openai
versions. I useopenai
,streamText
, andcreateStreamableValue
from the packages to generate a response based on user query. I copied the example from here and while it does work, most of the time I get some out of order responses, which also messes up my markdown formatter. Here is what a bad response looks like.Code example
Additional context
It also seems to make duplicate requests according the logs but I'm not sure if that's related or not.
The text was updated successfully, but these errors were encountered: