Rowny Robert
Rowny Robert

Reputation: 27

record not getting added in the astra db

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);

Upvotes: 0

Views: 27

Answers (0)

Related Questions