From 425e2bccccd4da83ff7c59e06abe83ccbbc2f6e7 Mon Sep 17 00:00:00 2001 From: Mike Fortman <michael.fortman@datastax.com> Date: Fri, 1 Dec 2023 14:52:16 -0600 Subject: [PATCH] Add docs --- examples/astradb/README.md | 34 +++++++++++++++++++ .../storage/vectorStore/AstraDBVectorStore.ts | 7 ---- 2 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 examples/astradb/README.md diff --git a/examples/astradb/README.md b/examples/astradb/README.md new file mode 100644 index 000000000..ebbd21e24 --- /dev/null +++ b/examples/astradb/README.md @@ -0,0 +1,34 @@ +# DataStax AstraDB Vector Store + +Here are two sample scripts which work well with the sample data in the Astra Portal + +## Prerequisites + +- An Astra DB account. You can [create one here](https://astra.datastax.com/register). + - An Astra Vector Database +- An OpenAI API Key + +## Setup + +1. Set your env variables: + +- `ASTRA_DB_ID`: Your Astra DB vector database id +- `ASTRA_DB_APPLICATION_TOKEN`: The generated app token for your Astra database +- `ASTRA_DB_REGION`: Your Astra DB database region +- `ASTRA_DB_NAMESPACE`: The existing Astra Namespace/Keyspace (if you don't set this it will default to `default_keyspace`) +- `OPENAI_API_KEY`: Your OpenAI key + +2. `cd` Into the `examples` directory +3. run `pnpm i` + +## Load the data + +This sample loads the same dataset of movie reviews as the Astra Portal sample dataset. (Feel free to load the data in your the Astra Data Explorer to compare) + +run `ts-node astradb/load` + +## Use RAG to Query the data + +Check out your data in the Astra Data Explorer and change the sample query as you see fit. + +run `ts-node astradb/query` diff --git a/packages/core/src/storage/vectorStore/AstraDBVectorStore.ts b/packages/core/src/storage/vectorStore/AstraDBVectorStore.ts index bdbfed9ea..b9fc482a4 100644 --- a/packages/core/src/storage/vectorStore/AstraDBVectorStore.ts +++ b/packages/core/src/storage/vectorStore/AstraDBVectorStore.ts @@ -146,7 +146,6 @@ export class AstraDBVectorStore implements VectorStore { const similarities: number[] = []; await cursor.forEach(async (doc: Record<string, any>) => { - // console.log(doc); ids.push(doc._id); similarities.push(doc.$similarity); const node = metadataDictToNode({ @@ -155,12 +154,6 @@ export class AstraDBVectorStore implements VectorStore { delete doc.$vector; node.setContent(JSON.stringify(doc)); nodes.push(node); - // nodes.push(new Document({ - // id_: doc._id, - // text: doc.document, - // metadata: row.metadata, - // embedding: doc.$vector, - // })) }); return { -- GitLab