Hacker News new | ask | show | jobs
by brrrrrm 921 days ago
why on earth did they design the Node.js and Web APIs to be slightly different and incompatible? (edit: this might just be a bug/oversight on the landing page?)

Node.js:

   const model = genAI.getGenerativeModel({ model: "gemini-pro-vision"});

   const result = model.generateContent({ contents: [{parts: [
      {text: "What’s in this photo?"},
      {inlineData: {data: imgBase64, mimeType: 'image/png'}}
    ] }] })
Web:

    const model = genAI.getGenerativeModel({ model: "gemini-pro-vision"});

    const result = await model.generateContent([
      "What’s in this photo?",
      {inlineData: {data: imgDataInBase64, mimeType: 'image/png'}}
    ]);
2 comments

Hey! This is Miguel from Google working of these SDKS. I'm confused about this comment, Both Web and Node.js are the same. Can you clarify where you see the difference?
as documented it looks different (async vs sync + the necessity of `text:` annotations in the Node.js version?)

updated my comment to paste in what's written in the docs

Thanks, that helps to understand the confusion.

The web and Node.js are the same, each of them has many function overloads so users can call functions with simplified or complex arguments, as they prefer. We are going to fix the doc and code snippets so both Web and Node.js consistently show the same code to avoid misunderstandings. Thanks a lot!

What do you mean? They look exactly the same to me.
You may be a host