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

Error: Cannot read properties of undefined (reading 'embedDocuments') #5148

Open
5 tasks done
jiveshkalra opened this issue Apr 18, 2024 · 2 comments
Open
5 tasks done
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@jiveshkalra
Copy link

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

  const vectorStore = await HNSWLib.fromTexts( final_posts,new HuggingFaceTransformersEmbeddings({model: "mixedbread-ai/mxbai-embed-large-v1"}));

Error Message and Stack Trace (if applicable)

Unhandled Runtime Error
Error: Cannot read properties of undefined (reading 'embedDocuments')

Source
app\actions\chatbot_action.jsx (43:36) @ fromTexts

  41 | 
  42 | 
> 43 | const vectorStore = await HNSWLib.fromTexts( final_posts,new HuggingFaceTransformersEmbeddings({model: "mixedbread-ai/mxbai-embed-large-v1",}));
     |                                  ^
  44 | const retriever = vectorStore.asRetriever();```

### Description

I am trying to set up a simple RAG with HNSWLib , I have my documents in final_post and I cant use OpenAI So I am going for opensource embedding model ,but I am unable to use that 

### System Info

Platform Windows
Node v20.9.0
langchain info ->
```markdown
langchain@0.1.34 | MIT | deps: 17 | versions: 265
Typescript bindings for langchain
https://github.com/langchain-ai/langchainjs/tree/main/langchain/

keywords: llm, ai, gpt3, chain, prompt, prompt engineering, chatgpt, machine learning, ml, openai, embeddings, vectorstores

dist
.tarball: https://registry.npmjs.org/langchain/-/langchain-0.1.34.tgz
.shasum: 3c28a6bde69c5f4ac3931376d34187de0e44e43a
.integrity: sha512-4TVH2mzhITrLPOeyfGucfqo1+360DJMl4+ItG56ApxVY1krO4hV0EkqcRLAxW06W6sIue8mIU70WbyhBYH68Ug==
.unpackedSize: 4.1 MB

dependencies:
@anthropic-ai/sdk: ^0.9.1     binary-extensions: ^2.2.0     langchainhub: ~0.0.8          p-retry: 4                    zod: ^3.22.4
@langchain/community: ~0.0.47 js-tiktoken: ^1.0.7           langsmith: ~0.1.7             uuid: ^9.0.0
@langchain/core: ~0.1.56      js-yaml: ^4.1.0               ml-distance: ^4.0.0           yaml: ^2.2.1
@langchain/openai: ~0.0.28    jsonpointer: ^5.0.1           openapi-types: ^12.1.3        zod-to-json-schema: ^3.22.3

maintainers:
- nfcampos <nuno@boringbits.io>
- jacoblee93 <jacoblee93@gmail.com>
- andrewnguonly <andrewnguonly@gmail.com>
- davidduong <david@duong.cz>
- hwchase17 <hw.chase.17@gmail.com>
- basproul <braceasproul@gmail.com>

dist-tags:
latest: 0.1.34     next: 0.1.29-rc.0

published 16 hours ago by jacoblee93 <jacoblee93@gmail.com>
Copy link

dosubot bot commented Apr 18, 2024

The error you're encountering, "Cannot read properties of undefined (reading 'embedDocuments')", indicates that the HuggingFaceTransformersEmbeddings object you're passing to HNSWLib.fromTexts might not be correctly instantiated or does not have the embedDocuments method defined. This method is essential for converting texts to vectors, which are then added to the HNSW index.

To resolve this issue, ensure that HuggingFaceTransformersEmbeddings is properly implemented and instantiated. It should adhere to the EmbeddingsInterface, which requires an embedDocuments method that takes an array of documents as input and returns a promise resolving to an array of vectors for each document.

Here's a quick checklist:

  • Verify that HuggingFaceTransformersEmbeddings is compatible with LangChain.js and is correctly installed in your project.
  • Ensure that HuggingFaceTransformersEmbeddings correctly implements the EmbeddingsInterface, especially the embedDocuments method.
  • Double-check the instantiation of HuggingFaceTransformersEmbeddings before passing it to HNSWLib.fromTexts.

If after these checks the issue persists, it might be helpful to review the documentation or source code of HuggingFaceTransformersEmbeddings to ensure it's being used as intended.

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label Apr 18, 2024
@jiveshkalra
Copy link
Author

jiveshkalra commented Apr 18, 2024

Also using Memory Vector store gives me even weirder error ->
image

ror: (0 , _xenova_transformers__WEBPACK_IMPORTED_MODULE_0__.pipeline) is not a function

Source
app\actions\chatbot_action.jsx (44:46) @ fromDocuments

  42 | 
  43 | 
> 44 | const vectorStore = await MemoryVectorStore.fromDocuments(final_posts,new HuggingFaceTransformersEmbeddings({model: "mixedbread-ai/mxbai-embed-large-v1",}));
     |                                            ^

in code I just only changed a one word in the code

  const vectorStore = await MemoryVectorStore.fromDocuments(final_posts,new HuggingFaceTransformersEmbeddings({model: "mixedbread-ai/mxbai-embed-large-v1",}));```

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