-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Cannot read properties of undefined (reading embedQuery) #2549
Comments
🤖 Hello, The error you're encountering, "Cannot read properties of undefined (reading 'embedQuery')", is likely due to the Here's how you should initialize the const embeddings = new OpenAIEmbeddings({
modelName: 'text-embedding-ada-002',
batchSize: 512,
stripNewLines: true,
timeout: 1000,
azureOpenAIApiKey: 'your-azure-openai-api-key',
azureOpenAIApiInstanceName: 'your-azure-openai-api-instance-name',
azureOpenAIApiDeploymentName: 'your-azure-openai-api-deployment-name',
azureOpenAIApiVersion: 'your-azure-openai-api-version',
azureOpenAIBasePath: 'your-azure-openai-base-path',
maxConcurrency: 1,
});
/* Embed queries */
const res = await embeddings.embedQuery("Hello world");
console.log(res);
/* Embed documents */
const documentRes = await embeddings.embedDocuments([
"Hello world",
"Bye bye",
]);
console.log({ documentRes }); Please replace As for the function of the I hope this helps! If you have any other questions, feel free to ask. Best, Sources
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. |
@dosu-bot Please take a look at the update description of the issue and let me know how to fix the issue. |
🤖 Hello, The error you're encountering, "Cannot read properties of undefined (reading 'embedQuery')", suggests that the object on which you're trying to call the 'embedQuery' method is undefined. In your case, you're using the 'embedQuery' method on an instance of OpenAIEmbeddings. The 'embedQuery' method in the OpenAIEmbeddings class in the LangChain codebase is used to generate embeddings for a given text query. These embeddings are numerical representations of the input text, which can be used for various natural language processing tasks. Based on the context provided, it seems like you're missing the embeddings object when loading a vector store with Here's how you can modify your code: const embeddings = new OpenAIEmbeddings();
const vectorStore = await HNSWLib.load("./src/vector_store", embeddings); In the above code, an instance of OpenAIEmbeddings is created and passed to the If the issue persists, please provide more context or code snippets where the error is occurring. Also, ensure that the 'embedQuery' method exists on the OpenAIEmbeddings class. If the method doesn't exist or is not accessible, you will encounter this error. I hope this helps! Let me know if you have any other questions. Best, Sources
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. |
thanks @dosu-beta The above fixes helped, closing the issue. |
🤖 I'm glad to hear that your issue has been resolved and you're closing the issue. However, for future reference and to help other users who might encounter the same problem, it would be beneficial if you could provide some details about the issue you were facing and how you resolved it. From the context provided, it seems you were using version 0.0.4 of LangChain when you encountered the issue. But the specifics of the issue, your environment setup, and the steps taken to resolve it weren't clear. If you could share these details, it would greatly contribute to the LangChain community. Thank you for your understanding and cooperation. SourcesThis 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. |
I am getting the following error when I am using VectorDBQAChain as a tool to the agent.
Following is the code which I have used.
The text was updated successfully, but these errors were encountered: