Replies: 3 comments 2 replies
-
🤖 Hey @meshboy88, good to see you back! Diving into another intriguing challenge, I see? Let's crack this one together. Based on the error message you provided, it seems like the issue is related to the type of the In your code, you're creating the const pineconeIndex = pineconeClient.Index(
process.env.PINECONE_INDEX || ('' as string)
) as Index<RecordMetadata>; And then you're passing it to the const vectorStore = await PineconeStore.fromExistingIndex(
new OpenAIEmbeddings({ openAIApiKey: process.env.OPENAI_API_KEY }),
{ pineconeIndex }
); The error message suggests that the To resolve this issue, you should ensure that the import { PineconeIndex } from "@pinecone-database/pinecone";
// Create a PineconeIndex instance
let pineconeIndex: PineconeIndex = new PineconeIndex(...);
// Pass the PineconeIndex instance to the PineconeStore.fromExistingIndex method
const vectorStore = await PineconeStore.fromExistingIndex(
new OpenAIEmbeddings({ openAIApiKey: process.env.OPENAI_API_KEY }),
{ pineconeIndex }
); Please replace the If this doesn't resolve your issue, could you please provide more information about the Sources
|
Beta Was this translation helpful? Give feedback.
-
Try updating your version of
This worked for me. Good luck. |
Beta Was this translation helpful? Give feedback.
-
This worked for me
|
Beta Was this translation helpful? Give feedback.
-
I have been trying to incorporate vector store containing OpenAIEmbeddings indexed on pinecone. But i keep getting type error, no matter what i do.
At { pineconeIndex }, in this line:
Error: vectorstores.d.ts(11, 5): The expected type comes from property 'pineconeIndex' which is declared here on type 'PineconeStoreParams'
My Imports:
import { Redis } from "@upstash/redis";
import { OpenAIEmbeddings } from "@langchain/openai";
import { Pinecone, Index, RecordMetadata } from "@pinecone-database/pinecone";
import { PineconeStore } from "@langchain/pinecone";
Whole code:
import { Redis } from "@upstash/redis";
import { OpenAIEmbeddings } from "@langchain/openai";
import { Pinecone, Index, RecordMetadata } from "@pinecone-database/pinecone";
import { PineconeStore } from "@langchain/pinecone";
export type CompanionKey = {
companionName: string;
modelName: string;
userId: string;
};
export class MemoryManager {
private static instance: MemoryManager;
private history: Redis;
private vectorDBClient: Pinecone;
public constructor() {
this.history = Redis.fromEnv();
this.vectorDBClient = new Pinecone({
apiKey: process.env.PINECONE_API_KEY!,
environment: process.env.PINECONE_ENVIRONMENT!,
});
}
public async vectorSearch(
recentChatHistory: string,
companionFileName: string
) {
const pineconeClient = this.vectorDBClient;
}
public static async getInstance(): Promise {
if (!MemoryManager.instance) {
MemoryManager.instance = new MemoryManager();
}
private generateRedisCompanionKey(companionKey: CompanionKey): string {
return
${companionKey.companionName}-${companionKey.modelName}-${companionKey.userId}
;}
public async writeToHistory(text: string, companionKey: CompanionKey) {
if (!companionKey || typeof companionKey.userId == "undefined") {
console.log("Companion key set incorrectly");
return "";
}
}
public async readLatestHistory(companionKey: CompanionKey): Promise {
if (!companionKey || typeof companionKey.userId == "undefined") {
console.log("Companion key set incorrectly");
return "";
}
}
public async seedChatHistory(
seedContent: String,
delimiter: string = "\n",
companionKey: CompanionKey
) {
const key = this.generateRedisCompanionKey(companionKey);
if (await this.history.exists(key)) {
console.log("User already has chat history");
return;
}
}
}
Beta Was this translation helpful? Give feedback.
All reactions