Hello! I need help with a Pineconedb problem, Im currently using old version code and i have tried to create it so it works with the current version but i have not gotten lucky. If anyone can help i would really appreciate it. Here is the current code "
import {Pinecone} from ‘@pinecone-database/pinecone’;
import { downloadFromS3 } from “./s3-server”;
import { PDFLoader } from “langchain/document_loaders/fs/pdf”;
export const getPineconeClient = () => {
return new Pinecone({
environment: process.env.PINECONE_ENVIRONMENT!,
apiKey: process.env.PINECONE_API_KEY!,
});
};
type PDFPage = {
pageContent: string;
metadata: {
loc: { pageNumber: number };
};
};
export async function loadS3IntoPinecone(fileKey: string){
// 1. obtain the PDF → download and read from PDF
console.log(‘Downloading s3 into file system’)
const file_name = await downloadFromS3(fileKey);
if (!file_name){
throw new Error(‘Could not download from s3’)
}
const loader = new PDFLoader(file_name);
const pages = (await loader.load()) as PDFPage;
return pages
}"