langchainjs icon indicating copy to clipboard operation
langchainjs copied to clipboard

axios-request-adapter reaching too far into internals

Open carlosdp opened this issue 1 year ago • 3 comments

It looks like axios-request-adapter.js is importing parts from axios that aren't actually exporting from that library in the latest version (0.0.13), causing a crash when calling out to APIs using axios:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/core/settle' is not defined by "exports" in /Users/carlosdp/code/weaver/node_modules/axios/package.json imported from /Users/carlosdp/code/weaver/node_modules/langchain/dist/util/axios-fetch-adapter.js
    at new NodeError (node:internal/errors:371:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:453:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:731:3)
    at packageResolve (node:internal/modules/esm/resolve:913:14)
    at moduleResolve (node:internal/modules/esm/resolve:978:18)
    at defaultResolve (node:internal/modules/esm/resolve:1080:11)
    at ESMLoader.resolve (node:internal/modules/esm/loader:530:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:251:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:79:40)
    at link (node:internal/modules/esm/module_job:78:36) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'

I'll see if I have time to submit a PR for a fix for this later tonight, but downgrading to 0.0.12 is a temporary fix.

That said, I think the real fix is to eliminate the openai library and just call the HTTP API directly with axios -- it's not immediately clear to me why an adapter should be necessary for what amounts to extremely simple HTTP requests. (Also, the whole "you need to install the openai library" exception after install is a massive anti-pattern, so would be good to eliminate that anyways!)

carlosdp avatar Feb 27 '23 22:02 carlosdp