Coder Social home page Coder Social logo

Comments (5)

lgrammel avatar lgrammel commented on August 22, 2024

Are you using typescript or javascript? Can you provide an example of the input that resulted in this error?

from ai.

castortech avatar castortech commented on August 22, 2024

I am using TS.

Here is a message causing the issue:

[
  {
    role: "system",
    content: "Today is 8/16/2024.\n\nUser Instructions:\nYou are a friendly, helpful AI assistant.",
  },
  {
    role: "user",
    content: [
      {
        type: "text",
        text: "explain image",
      },
      {
        type: "image_url",
        image_url: {
          url: "data:image/jpeg;base64,/9j/4aJORXhpZgAASUkqAAgAAAANAAABAwABAAAAAAwAAAEBAwABAAAA8A8AAA8BAgAHAAAAqgAAABABAgAMAAAAsQAAABIBAwABAAAAAQAAABoBBQABAAAAvQAAABsBBQABAAAAxQAAACgBAwABAAAAAgAAADEBAgAVAAAAzQAAADIBAgAUAAAA4gAA...=",
        },
      },
    ],
  },
]

and the resulting error:

[TypeError: Cannot read properties of undefined (reading 'type')]
Error in chat/openai: TypeError: Cannot read properties of undefined (reading 'type')
    at eval (webpack-internal:///(rsc)/./node_modules/@ai-sdk/openai/dist/index.mjs:41:26)
    at Array.map (<anonymous>)
    at convertToOpenAIChatMessages (webpack-internal:///(rsc)/./node_modules/@ai-sdk/openai/dist/index.mjs:39:28)
    at OpenAIChatLanguageModel.getArgs (webpack-internal:///(rsc)/./node_modules/@ai-sdk/openai/dist/index.mjs:254:17)
    at OpenAIChatLanguageModel.doStream (webpack-internal:///(rsc)/./node_modules/@ai-sdk/openai/dist/index.mjs:380:37)
    at fn (webpack-internal:///(rsc)/./node_modules/ai/dist/index.mjs:2942:35)
    at eval (webpack-internal:///(rsc)/./node_modules/ai/dist/index.mjs:328:28)
    at Object.startActiveSpan (webpack-internal:///(rsc)/./node_modules/ai/dist/index.mjs:257:14)
    at recordSpan (webpack-internal:///(rsc)/./node_modules/ai/dist/index.mjs:326:17)
    at eval (webpack-internal:///(rsc)/./node_modules/ai/dist/index.mjs:2914:15)

from ai.

lgrammel avatar lgrammel commented on August 22, 2024

@castortech I'm getting a TS error when I try to do this:

CleanShot 2024-08-16 at 12 28 25

Did this error show up for you? Or was it a situation where any was used?

(we might need to improve our internal checks regardless of typing bc of any)

from ai.

castortech avatar castortech commented on August 22, 2024

I am not forming the message manually, and a bit closer to any

Here is the type info:

let finalMessages: {
    role: string;
    content: string | ({
        type: string;
        image_url: {
            url: string;
        };
        image?: undefined;
    } | {
        type: string;
        image: string;
        image_url?: undefined;
    } | {
        type: string;
        text: string;
    })[];
}[]

that was made to be multi-provider but mostly OpenAI and that we are working to convert fully to Vercel AI (prior was using legacy provider only to stream response).

from ai.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.