-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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 'replace') at OpenAIEmbeddings.embedQuery #5143
Comments
The error you're encountering, "TypeError: Cannot read properties of undefined (reading 'replace')", occurs because the To resolve this issue, ensure that the text passed to This problem is likely happening because the text parameter being passed to Additionally, reviewing similar issues in the LangChain.js repository might provide further insights or solutions that are specific to your use case. Sources
|
I can see that embeddings are being created and are saved in the folder. |
const data = fs.readFileSync(profileFilePath);
const textSplitterChat = new RecursiveCharacterTextSplitter({
chunkSize: 1000,
chunkOverlap: 200,
separators: ["\n"],
});
const docs = await textSplitterChat.createDocuments(
profile.toString()
); Maybe the |
Is there any solution for this? We are also having this issue |
Checked other resources
Example Code
Generating Embeddings
Initiating conversation
Error Message and Stack Trace (if applicable)
TypeError: Cannot read properties of undefined (reading 'replace')
at OpenAIEmbeddings.embedQuery (file:///.../node_modules/@langchain/openai/dist/embeddings.js:212:46)
at HNSWLib.similaritySearch (file:///.../node_modules/@langchain/core/dist/vectorstores.js:104:90)
at VectorStoreRetriever._getRelevantDocuments (file:///.../node_modules/@langchain/core/dist/vectorstores.js:68:33)
at VectorStoreRetriever.getRelevantDocuments (file:///.../node_modules/@langchain/core/dist/retrievers/index.js:67:40)
at async RunnableSequence.invoke (file:///.../node_modules/@langchain/core/dist/runnables/base.js:1055:33)
at async file:///.../node_modules/@langchain/core/dist/runnables/base.js:1264:31
at async Promise.all (index 0)
at async RunnableMap.invoke (file:///.../node_modules/@langchain/core/dist/runnables/base.js:1263:13)
at async RunnableSequence.invoke (file:///...node_modules/@langchain/core/dist/runnables/base.js:1055:33)
at async initiateConversation (file:///.../src/conversation.js:124:26)
Description
Embeddings are being saved successfully.
But the problem is in initiateConversation.
System Info
{
"type": "module",
"dependencies": {
"@langchain/community": "0.0.49",
"@langchain/openai": "0.0.28",
"dotenv": "16.4.5",
"hnswlib-node": "1.4.2",
"langchain": "0.1.33"
},
"engines": {
"node": ">=18"
}
}
The text was updated successfully, but these errors were encountered: