vercel / ai

Build AI-powered applications with React, Svelte, Vue, and Solid
https://sdk.vercel.ai/docs
Other
9.87k stars 1.46k forks source link

Errors when transpiling #2667

Open jensroth-git opened 2 months ago

jensroth-git commented 2 months ago

Description

install the "ai" and the "@ai-sdk/openai" package and build the following example...

node -v v20.16.0

tsc -v Version 5.5.4

image

Code example

import { createOpenAI } from '@ai-sdk/openai';
import { generateText } from 'ai';

async function main()
{
    let openai = createOpenAI({
        apiKey: OpenAIKey
    });

    let response = await generateText({
        model: openai("gpt-4o-mini"),
        prompt: "What is the meaning of life?",
    });

    console.log(response);
}

main();

Additional context

No response

lgrammel commented 2 months ago

TS 5.5.4 upgrade: https://github.com/vercel/ai/pull/2688

lgrammel commented 2 months ago

Thanks for the bug report! There are 3 issues here:

lgrammel commented 2 months ago

The fix has landed, with the workarounds you should be able to compile.