I am new to JS. Im trying to implement an API call to openai, and using:
import OpenAI from “openai”.
tsconfig:
“compilerOptions”: {
“target”: “es6”,
“lib”: r
“es6”
],
Any help with setting the right target?
I am new to JS. Im trying to implement an API call to openai, and using:
import OpenAI from “openai”.
tsconfig:
“compilerOptions”: {
“target”: “es6”,
“lib”: r
“es6”
],
Any help with setting the right target?
You can’t use ts compiler to add libraries, you need to use a bundler like esbuild, webpack or something like that and compile everything into a single file. Also you likely won’t be able to use a library like that on the plugin backend, so I recommend you do it on the plugin UI side.
Thanks Gleb. I’m using webpack (by following Libraries and Bundling), and so far been able to use papaparse npm module.
“dependencies”: {
“@types/papaparse”: “^5.3.14”,
“openai”: “^4.49.0”,
“papaparse”: “^5.4.1”
}
I’ve now npm install openai the same way, but I get the “Unexpected token …” error because of spread syntax.
Is there any setting I should change in my tsconfig to be able to use openai libraries?
Ah, ok. You can try es5 but es6 should work just fine as well.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.