ai icon indicating copy to clipboard operation
ai copied to clipboard

Unable to access some of the return values from `streamUI()`

Open ashersamuel8 opened this issue 1 year ago • 1 comments

Description

Unable to access some of the return values from the returned object of streamUI. I am only being able to access rawCall, rawResponse, stream, value, and warnings. I'm unable to access values like textStream, fullStream, usage, etc. I am using google's gemini-flash as the model. This code is in actions.tsx and I am using [email protected] and [email protected].

Code example

  const result = await streamUI({
    model: google("models/gemini-1.5-flash-latest"),
    messages: [
      ...aiState.get().messages.map((message: any) => ({
        role: message.role,
        content: message.content,
        name: message.name,
      })),
    ],
  })

Additional context

No response

ashersamuel8 avatar Jul 01 '24 15:07 ashersamuel8

@ashersamuel8 with streamUI, you can use parameters to define callbacks, see https://sdk.vercel.ai/docs/ai-sdk-rsc/streaming-react-components#adding-a-tool

lgrammel avatar Jul 08 '24 06:07 lgrammel

@lgrammel the docs suggest that these methods are returned in the result, similarly to streamText, but that doesn't appear the case. Looking through the commit history, it doesn't seem to have ever been the case in previous releases either. https://sdk.vercel.ai/docs/reference/ai-sdk-rsc/stream-ui#returns

  const result = await streamUI({
    model: google("models/gemini-1.5-flash-latest"),
    messages: [
      ...aiState.get().messages.map((message: any) => ({
        role: message.role,
        content: message.content,
        name: message.name,
      })),
    ],
  })
  // `fullStream` etc is not returned as the docs suggest
  const { value, fullStream } = result

The result resolves to:

{
    value: ReactNode;
} & {
    stream: ReadableStream<LanguageModelV1StreamPart>;
    rawCall: {
        rawPrompt: unknown;
        rawSettings: Record<string, unknown>;
    };
    rawResponse?: {
        headers?: Record<string, string>;
    };
    warnings?: LanguageModelV1CallWarning[];
}

Saran33 avatar Aug 31 '24 18:08 Saran33

@Saran33 this information is incorrect. I'll update the docs. thank you

lgrammel avatar Sep 02 '24 14:09 lgrammel

Docs fix: https://github.com/vercel/ai/pull/2871

lgrammel avatar Sep 02 '24 14:09 lgrammel