cohere-ai/cohere-typescript

fetch issue in AWS lambda

alex-cortenix opened this issue · 6 comments

Hello Team,

I am currently attempting to integrate Cohere embed within an AWS Lambda function and have come across a frustrating issue. It appears that the library interferes with the global "fetch" function that is provided by Node.js version 18, resulting in a malfunction that causes other libraries that utilize "fetch" to fail. The specific error message I'm receiving is "TypeError: fetch is not a function." Could anyone suggest a potential solution or workaround for this problem?

Thank you for your assistance.

Hey @alex-cortenix thanks for reporting, we're seeing similar issues with #110. Will sync with @dsinghvi and have a fix for you asap.

you may have luck depending on 7.6.0 if that unblocks you for now. This was the version that used axios, not fetch. Thanks

Closing in favour of fern-api/fern#2555

Hey @alex-cortenix this should be working as of 7.7.5. Let me know if you have any further issues! Thanks

Hello I'm using @langchain/cohere with CohereRerank which uses cohere-ai client version 7.7.7 running on lambda and getting the error

CohereError: fetchFn is not a function

Could this still be related? Anyone managed to make it work with lambda?

Found the cause of the error, in my case if I update the compiled js code to be const response = yield fetchFn.default insteadof const response = yield fetchFn under makeRequest in Fetcher file, it works. I suspect it has something to do with how require("node-fetch") is used. I'm using node 18