Could anyone help with this please. I do not understand why this has happened after upgrading to the latest version of the openai API. This is my error message
const openai = new OpenAI({
^
TypeError: OpenAI is not a constructor
I’ll try to give you a semi-maybe-helpful stop-gap reply until someone in a more similar boat replies to your thread
I’ve stopped using the lib a looong time ago so I can’t confirm or reject your issue, but with things like these the first thing I would do is to navigate into the dependency.
If you have an IDE you should be able to click on OpenAI and say go to definition or implementation. Then it becomes fairly straight-forward to identify whether you’ve imported the wrong thing or if something else went wrong.
What you also can also do is type OpenAI. and see what your IDE spits out. It’s quite possible that you’d have to type new OpenAI.OpenAI(…) the way you imported it.
Yeah, looks like they might have borked the commonjs exports.
They’ve borked a lot of stuff in the past and they likely will going forward.
Quite understandable. The ecosystem can be quite confusing, because it grew fairly rapidly in the past 10 years, and ChatGPT is not going to help you with this because there’s simply so much conflicting information out there