transitive-bullshit / agentic

AI agent stdlib that works with any LLM and TypeScript AI SDK.
MIT License
16.07k stars 2.11k forks source link

CJS Incompatibity Error #620

Closed darksuei closed 1 month ago

darksuei commented 9 months ago

Verify latest release

Verify webapp is working

Environment details

NodeJS v18.17.0 Ubuntu 22.04

Describe the Bug

Steps to Reproduce : import { ChatGPTUnofficialProxyAPI } from "chatgpt"; const api = new ChatGPTUnofficialProxyAPI({ accessToken: "xxx", apiReverseProxyUrl: "yyy", });

Importing the module does not work in typescript backend, it seems to stem from some incompatibility the module has with cjs that typescript compiler spits out. Is there a way to go about this without reconfiguring the ts config? PS even that doesnt work.

Error: Error [ERR_REQUIRE_ESM]: require() of ES Module /home/bot/Desktop/Projects/Mains/studera-be/node_modules/chatgpt/build/index.js from /home/bot/Desktop/Projects/Mains/studera-be/utils/utils.ts not supported. Instead change the require of index.js in /home/bot/Desktop/Projects/Mains/studera-be/utils/utils.ts to a dynamic import() which is available in all CommonJS modules. at require.extensions. [as .js] (/home/bot/Desktop/Projects/Mains/studera-be/node_modules/ts-node/dist/index.js:851:20) at Object. (/home/bot/Desktop/Projects/Mains/studera-be/utils/utils.ts:13:19) at m._compile (/home/bot/Desktop/Projects/Mains/studera-be/node_modules/ts-node/dist/index.js:857:29) ...

swellee commented 6 months ago

I run into the same error. is it resolved?

transitive-bullshit commented 1 month ago

This project is undergoing a major revamp; closing out old issues as part of the prep process.

The chatgpt package is pretty outdated at this point. I recommend that you use the openai package or the openai-fetch package instead.