You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import { PineconeClient } from "@pinecone-database/pinecone";
import { VectorDBQAChain } from "langchain/chains";
import { OpenAIEmbeddings } from "langchain/embeddings/openai";
import { OpenAI } from "langchain/llms/openai";
import { PineconeStore } from "langchain/vectorstores/pinecone";
const pinecone = new PineconeClient();
await pinecone.init({
environment: process.env.PINECONE_ENV,
apiKey: process.env.PINECONE_SECRET,
namespace: process.env.PINECONE_NAMESPACE
});
const index = pinecone.Index(process.env.PINECONE_INDEX)
const vectorStore = await PineconeStore.fromExistingIndex(
new OpenAIEmbeddings(),
{ index }
);
const model = new OpenAI();
const chain = VectorDBQAChain.fromLLM(model, vectorStore, {
k: 1,
returnSourceDocuments: true,
});
const response = await chain.call({ query: "What is Pinecone and how does it work?" });
console.log(response);
This code keeps returning the following when I run it:
TypeError: Cannot read properties of undefined (reading 'query')
at PineconeStore.similaritySearchVectorWithScore (webpack internal:///(sc_server)/./node_modules/langchain/dist/vectorstores/pinecone.js:89:50)
at PineconeStore.similaritySearch (webpack-internal:///(sc_server)/./node_modules/langchain/dist/vectorstores/base.js:54:36)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async VectorDBQAChain._call (webpack-internal:///(sc_server)/./node_modules/langchain/dist/chains/vector_db_qa.js:63:22)
at async VectorDBQAChain.call (webpack-internal:///(sc_server)/./node_modules/langchain/dist/chains/base.js:75:28)
I am using "langchain": "^0.0.84", within a Nextjs 13 api route and have played around with it to no avail. If I am missing anything please let me know, thanks!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
This code keeps returning the following when I run it:
I am using "langchain": "^0.0.84", within a Nextjs 13 api route and have played around with it to no avail. If I am missing anything please let me know, thanks!
Beta Was this translation helpful? Give feedback.
All reactions