Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[email protected] Axios Error #816

Closed
gkhngyk opened this issue Apr 15, 2023 · 5 comments
Closed

[email protected] Axios Error #816

gkhngyk opened this issue Apr 15, 2023 · 5 comments

Comments

@gkhngyk
Copy link
Contributor

gkhngyk commented Apr 15, 2023

Hello,
While trying to update version from 0.0.55 to 0.0.56, I get the axios error. How can I fix this error. Here is the error log:

While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/axios
npm ERR!   axios@"^1.3.4" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peerOptional axios@"^0.26.0" from [email protected]
npm ERR! node_modules/langchain
npm ERR!   langchain@"^0.0.56" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/axios
npm ERR!   peerOptional axios@"^0.26.0" from [email protected]
npm ERR!   node_modules/langchain
npm ERR!     langchain@"^0.0.56" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

Thank you,

@matboehm
Copy link

matboehm commented Apr 15, 2023

You will have to set the package axios in your package.json to 0.26.1 manually and install again, this should resolve the dependency version conflict.

I don't know why langchainjs uses such an outdated version of axios though, we are at version 1.3.4 at the moment and version ``0.26.1` is more than a year old.

By the way, I also have problems with running the Custom LLM Agent example and the axios-fetch-adapter.js seems to fail.

Any help would be greatly appreciated!

Loaded agent.
Executing with input "Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?"...
file:///home/matthias/gitrepositories/projects/plan-and-do/node_modules/langchain/dist/util/axios-fetch-adapter.js:237
    const headers = new Headers(config.headers);
                    ^
ReferenceError: Headers is not defined
    at createRequest (file:///home/matthias/gitrepositories/projects/plan-and-do/node_modules/langchain/dist/util/axios-fetch-adapter.js:237:21)
    at fetchAdapter (file:///home/matthias/gitrepositories/projects/plan-and-do/node_modules/langchain/dist/util/axios-fetch-adapter.js:165:21)
    at dispatchRequest (/home/matthias/gitrepositories/projects/plan-and-do/node_modules/axios/lib/core/dispatchRequest.js:58:10)
    at Axios.request (/home/matthias/gitrepositories/projects/plan-and-do/node_modules/axios/lib/core/Axios.js:108:15)
    at Function.wrap [as request] (/home/matthias/gitrepositories/projects/plan-and-do/node_modules/axios/lib/helpers/bind.js:9:15)
    at /home/matthias/gitrepositories/projects/plan-and-do/node_modules/openai/dist/common.js:149:22
    at /home/matthias/gitrepositories/projects/plan-and-do/node_modules/openai/dist/api.js:1738:133
    at async RetryOperation._fn (/home/matthias/gitrepositories/projects/plan-and-do/node_modules/p-retry/index.js:50:12) {
  attemptNumber: 7,
  retriesLeft: 0
}

@titocosta
Copy link

Running npm install [email protected] before npm install langchain@latest fixed it for me.

@nfcampos
Copy link
Collaborator

We use this version because this is the version the openai SDK uses, and we don't want people to have 2 of them in their app. If you want it updated please ask the openai folks

@matzkoh
Copy link

matzkoh commented Apr 16, 2023

In my use case, everything is working well with the following package.json.
Please refer to it if you want to use axios@1 right away.

  "dependencies": {
    "axios": "1.3.5",
    "langchain": "0.0.56",
    "openai": "3.2.1"
  },
  "overrides": {
    "axios": "$axios"
  }

@matboehm
Copy link

matboehm commented Apr 16, 2023

We use this version because this is the version the openai SDK uses, and we don't want people to have 2 of them in their app. If you want it updated please ask the openai folks

Thank you for the explanation, that makes sense!

For anyone having the same error I had ReferenceError: Headers is not defined in axios-fetch-adapter.js:
I tried to run langchainjs server side with Node.js, this is why it failed.

A quick fix for this is to install the node-fetch module and add import fetch, { Headers, Request } from "node-fetch"; at the top of axios-fetch-adapter.js.

Edit: I was using Node.js version 16.x, if you switch to 18.x you won't run into this error anymore (see #159)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants