Skip to content

Huggingface call issues partly because of out-of-date dependency #8148

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

Open
5 tasks done
YasharF opened this issue May 9, 2025 · 1 comment
Open
5 tasks done

Huggingface call issues partly because of out-of-date dependency #8148

YasharF opened this issue May 9, 2025 · 1 comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@YasharF
Copy link

YasharF commented May 9, 2025

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

cjs

        const cacheBackedEmbeddings = CacheBackedEmbeddings.fromBytesStore(
          new HuggingFaceInferenceEmbeddings({
            apiKey: process.env.HUGGINGFACE_KEY,
            model: process.env.HUGGINGFACE_EMBEDDING_MODEL,
          }),
          documentEmbeddingsCache,
        );

        await MongoDBAtlasVectorSearch.fromDocuments(chunksWithMetadata, cacheBackedEmbeddings, {
          collection,
          indexName: 'default',
          textKey: 'text',
          embeddingKey: 'embedding',
        });

Error Message and Stack Trace (if applicable)

An error occurred while fetching the blob

Description

Summary: We need to upgrade @huggingface/inference to the latest version as HF has been working to change their API endpoint in support of their multi-provider API model.

My above code worked fine until mid last week when my app broke and I started to get the error about the same time HF released their new multi provider configurations thru their dashboard. Digging thru the code for @huggingface/inference ^2.6.4 that langchain specifies as a peer dependency, I found out that "An error occurred while fetching the blob" was because HF API endpoint was failing with a 404 error and only "400, 422, 404, 500" errors were being handled with a meaningful response in the huggingface inference npm package. It was just giving out the mentioned error for all other cases. The older version uses the "https://api-inference.huggingface.co" end point for the API calls ( https://github.com/huggingface/huggingface.js/blob/96b4436e76e613a8c6362423ee7201604d6e3bbc/packages/inference/src/lib/makeRequestOptions.ts#L5 ), while the newer versions use a new router endpoint with a "provider" (https://router.huggingface.co/[providerName]/models/[modelName]/pipeline/... ) . I couldn't find any announcements about the old end-point getting deprecated, but it may had gone down with a premature shutdown as part of their move to the new multi-provider model. I also don't know if the old end-point is still down or back online because I am using the newer @huggingface/inference 3.12.1 now in a clunky way and not planning to downgrade it. More specifically:

I was able to override @huggingface/inference in my package.json to the latest version and use patch-package to add some changes to langchain to get the new version to work and be back running. FYI, in addition to the new provider field that needs to be piped, I also noticed multiple methods used by langchain that @huggingface/inference 3.12 has marked as deprecated and to be removed in future versions. Those methods don't need to be changed to migrate to the new version at the moment, but they are a ticking bomb.

I can potentially look into a PR for this upgrade next week, unless if you are already working on or plan to do it.

System Info

WSL Ubuntu 24.04.01 LTS
$ node -v
v22.15.0

=====
"@langchain/community": "^0.3.42",
"@langchain/core": "^0.3.54",
"@langchain/mongodb": "^0.1.0",
"@langchain/textsplitters": "^0.1.0",
"langchain": "^0.3.24",

@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label May 9, 2025
@YasharF YasharF changed the title Huggingface intermitent issues partly because of out-of-date dependency Huggingface call issues partly because of out-of-date dependency May 9, 2025
@YasharF
Copy link
Author

YasharF commented May 26, 2025

PR: #8237

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

No branches or pull requests

1 participant