From 0a69fe09fabe5c6eb31f496da9217964cac380c5 Mon Sep 17 00:00:00 2001
From: Thuc Pham <51660321+thucpn@users.noreply.github.com>
Date: Mon, 14 Oct 2024 16:03:41 +0700
Subject: [PATCH] fix: missing params when init Astra vectorstore (#373)

---
 .changeset/forty-pillows-clean.md                          | 5 +++++
 .../components/vectordbs/typescript/astra/generate.ts      | 7 ++++++-
 templates/components/vectordbs/typescript/astra/index.ts   | 7 ++++++-
 templates/types/streaming/express/package.json             | 2 +-
 templates/types/streaming/nextjs/package.json              | 2 +-
 5 files changed, 19 insertions(+), 4 deletions(-)
 create mode 100644 .changeset/forty-pillows-clean.md

diff --git a/.changeset/forty-pillows-clean.md b/.changeset/forty-pillows-clean.md
new file mode 100644
index 00000000..4be3cfde
--- /dev/null
+++ b/.changeset/forty-pillows-clean.md
@@ -0,0 +1,5 @@
+---
+"create-llama": patch
+---
+
+fix: missing params when init Astra vectorstore
diff --git a/templates/components/vectordbs/typescript/astra/generate.ts b/templates/components/vectordbs/typescript/astra/generate.ts
index f66657b5..b78a3b1d 100644
--- a/templates/components/vectordbs/typescript/astra/generate.ts
+++ b/templates/components/vectordbs/typescript/astra/generate.ts
@@ -14,7 +14,12 @@ async function loadAndIndex() {
 
   // create vector store and a collection
   const collectionName = process.env.ASTRA_DB_COLLECTION!;
-  const vectorStore = new AstraDBVectorStore();
+  const vectorStore = new AstraDBVectorStore({
+    params: {
+      endpoint: process.env.ASTRA_DB_ENDPOINT!,
+      token: process.env.ASTRA_DB_APPLICATION_TOKEN!,
+    },
+  });
   await vectorStore.createAndConnect(collectionName, {
     vector: {
       dimension: parseInt(process.env.EMBEDDING_DIM!),
diff --git a/templates/components/vectordbs/typescript/astra/index.ts b/templates/components/vectordbs/typescript/astra/index.ts
index 4ee66ade..b113523a 100644
--- a/templates/components/vectordbs/typescript/astra/index.ts
+++ b/templates/components/vectordbs/typescript/astra/index.ts
@@ -5,7 +5,12 @@ import { checkRequiredEnvVars } from "./shared";
 
 export async function getDataSource(params?: any) {
   checkRequiredEnvVars();
-  const store = new AstraDBVectorStore();
+  const store = new AstraDBVectorStore({
+    params: {
+      endpoint: process.env.ASTRA_DB_ENDPOINT!,
+      token: process.env.ASTRA_DB_APPLICATION_TOKEN!,
+    },
+  });
   await store.connect(process.env.ASTRA_DB_COLLECTION!);
   return await VectorStoreIndex.fromVectorStore(store);
 }
diff --git a/templates/types/streaming/express/package.json b/templates/types/streaming/express/package.json
index f7cea6f0..be18e8e6 100644
--- a/templates/types/streaming/express/package.json
+++ b/templates/types/streaming/express/package.json
@@ -21,7 +21,7 @@
     "dotenv": "^16.3.1",
     "duck-duck-scrape": "^2.2.5",
     "express": "^4.18.2",
-    "llamaindex": "0.6.19",
+    "llamaindex": "0.6.21",
     "pdf2json": "3.0.5",
     "ajv": "^8.12.0",
     "@e2b/code-interpreter": "0.0.9-beta.3",
diff --git a/templates/types/streaming/nextjs/package.json b/templates/types/streaming/nextjs/package.json
index c8f694ed..3f8ad57e 100644
--- a/templates/types/streaming/nextjs/package.json
+++ b/templates/types/streaming/nextjs/package.json
@@ -27,7 +27,7 @@
     "duck-duck-scrape": "^2.2.5",
     "formdata-node": "^6.0.3",
     "got": "^14.4.1",
-    "llamaindex": "0.6.19",
+    "llamaindex": "0.6.21",
     "lucide-react": "^0.294.0",
     "next": "^14.2.4",
     "react": "^18.2.0",
-- 
GitLab