From e70413373f1a65962d661f2ece09c3788a0b5b2a Mon Sep 17 00:00:00 2001
From: Mike Fortman <michael.fortman@datastax.com>
Date: Mon, 4 Dec 2023 10:53:31 -0600
Subject: [PATCH] pr feedback: update import and constructor params

---
 examples/astradb/README.md                        |  2 +-
 examples/astradb/load.ts                          | 10 ++++++----
 examples/astradb/query.ts                         | 10 ++++++----
 packages/core/src/storage/index.ts                |  1 +
 .../src/storage/vectorStore/AstraDBVectorStore.ts | 15 ++++++++++-----
 5 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/examples/astradb/README.md b/examples/astradb/README.md
index ebbd21e24..72dde55f0 100644
--- a/examples/astradb/README.md
+++ b/examples/astradb/README.md
@@ -19,7 +19,7 @@ Here are two sample scripts which work well with the sample data in the Astra Po
 - `OPENAI_API_KEY`: Your OpenAI key
 
 2. `cd` Into the `examples` directory
-3. run `pnpm i`
+3. run `npm i`
 
 ## Load the data
 
diff --git a/examples/astradb/load.ts b/examples/astradb/load.ts
index ece5d8678..8e62d3180 100644
--- a/examples/astradb/load.ts
+++ b/examples/astradb/load.ts
@@ -1,7 +1,9 @@
-import { VectorStoreIndex } from "../../packages/core/src/indices/vectorStore/VectorStoreIndex";
-import { PapaCSVReader } from "../../packages/core/src/readers/CSVReader";
-import { storageContextFromDefaults } from "../../packages/core/src/storage";
-import { AstraDBVectorStore } from "../../packages/core/src/storage/vectorStore/AstraDBVectorStore";
+import {
+  AstraDBVectorStore,
+  PapaCSVReader,
+  storageContextFromDefaults,
+  VectorStoreIndex,
+} from "llamaindex";
 
 const collectionName = "movie_reviews";
 
diff --git a/examples/astradb/query.ts b/examples/astradb/query.ts
index b9c08982e..1ed39033d 100644
--- a/examples/astradb/query.ts
+++ b/examples/astradb/query.ts
@@ -1,8 +1,10 @@
-import { serviceContextFromDefaults } from "../../packages/core/src/ServiceContext";
-import { VectorStoreIndex } from "../../packages/core/src/indices/vectorStore/VectorStoreIndex";
-import { AstraDBVectorStore } from "../../packages/core/src/storage/vectorStore/AstraDBVectorStore";
+import {
+  AstraDBVectorStore,
+  serviceContextFromDefaults,
+  VectorStoreIndex,
+} from "llamaindex";
 
-const collectionName = "movie_reviews";
+const collectionName = "movie_reviews_2";
 
 async function main() {
   try {
diff --git a/packages/core/src/storage/index.ts b/packages/core/src/storage/index.ts
index 96f8743be..0621dc172 100644
--- a/packages/core/src/storage/index.ts
+++ b/packages/core/src/storage/index.ts
@@ -7,6 +7,7 @@ export { SimpleIndexStore } from "./indexStore/SimpleIndexStore";
 export * from "./indexStore/types";
 export { SimpleKVStore } from "./kvStore/SimpleKVStore";
 export * from "./kvStore/types";
+export { AstraDBVectorStore } from "./vectorStore/AstraDBVectorStore";
 export { MongoDBAtlasVectorSearch } from "./vectorStore/MongoDBAtlasVectorStore";
 export { SimpleVectorStore } from "./vectorStore/SimpleVectorStore";
 export * from "./vectorStore/types";
diff --git a/packages/core/src/storage/vectorStore/AstraDBVectorStore.ts b/packages/core/src/storage/vectorStore/AstraDBVectorStore.ts
index 04cb8c26f..37019ad0a 100644
--- a/packages/core/src/storage/vectorStore/AstraDBVectorStore.ts
+++ b/packages/core/src/storage/vectorStore/AstraDBVectorStore.ts
@@ -13,11 +13,16 @@ export class AstraDBVectorStore implements VectorStore {
   astraDBClient: AstraDB;
   collection: Collection | undefined;
 
-  constructor() {
-    const token = process.env.ASTRA_DB_APPLICATION_TOKEN;
-    const dbId = process.env.ASTRA_DB_ID;
-    const region = process.env.ASTRA_DB_REGION;
-    const keyspace = process.env.ASTRA_DB_NAMESPACE;
+  constructor(params?: {
+    token: string;
+    dbId: string;
+    region: string;
+    keyspace: string;
+  }) {
+    const token = params?.token ?? process.env.ASTRA_DB_APPLICATION_TOKEN;
+    const dbId = params?.dbId ?? process.env.ASTRA_DB_ID;
+    const region = params?.region ?? process.env.ASTRA_DB_REGION;
+    const keyspace = params?.keyspace ?? process.env.ASTRA_DB_NAMESPACE;
 
     if (!dbId) {
       throw new Error("Must specify ASTRA_DB_ID via env variable.");
-- 
GitLab