record not getting added in the astra db

13 Views Asked by At

The Collection is getting created in the astradb but not the record console also says connected to the astra db but I am not geetting any record saved in the astra db dashboard

        const response = await fetch(`pdf_link`);
        const blob = await response.blob();
        const loader = new PDFLoader(blob);


        const pageLevelDocs = await loader.load();


        const pagesAmt = pageLevelDocs.length;

        const splitter = new RecursiveCharacterTextSplitter({
          chunkSize: 1000,
          chunkOverlap: 15,
        });
        const texts = await splitter.splitDocuments(pageLevelDocs);
        console.log("Loaded ", texts.length, " documents.");


        // If the collection does not exist, it is created automatically.
        const astraConfig: AstraLibArgs = {
          token: "",
          endpoint: "",
          collection: "",
          collectionOptions: {
            vector: {
              dimension: 1536,
              metric: "cosine",
            },
          },
        };

        console.log(texts)
        const vectorStore = await AstraDBVectorStore.fromDocuments(
          texts,
          new OpenAIEmbeddings({ openAIApiKey: process.env.OPENAI_API_KEY }),
          astraConfig
        );
        vectorStore.addDocuments(texts);
0

There are 0 best solutions below