From 290c8d7c9f4625b36e9cb25e79948acb6f3d8ef8 Mon Sep 17 00:00:00 2001 From: Stefano Lottini Date: Sat, 18 May 2024 01:42:53 +0200 Subject: [PATCH] support for nondefault namespace; slight rewording in readme --- .../Philosophical_Quotes_AstraPy.ipynb | 28 ++++++++----------- .../cassandra_astradb/README.md | 4 +-- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/examples/vector_databases/cassandra_astradb/Philosophical_Quotes_AstraPy.ipynb b/examples/vector_databases/cassandra_astradb/Philosophical_Quotes_AstraPy.ipynb index c311bc5..22aef9e 100644 --- a/examples/vector_databases/cassandra_astradb/Philosophical_Quotes_AstraPy.ipynb +++ b/examples/vector_databases/cassandra_astradb/Philosophical_Quotes_AstraPy.ipynb @@ -142,13 +142,18 @@ "output_type": "stream", "text": [ "Please enter your API Endpoint: https://01234567-89ab-cdef-0123-456789abcdef-us-east1.apps.astra.datastax.com\n", - "Please enter your Token ········\n" + "Please enter your Token: ········\n", + "Please enter your namespace. Leave empty for default: \n" ] } ], "source": [ "ASTRA_DB_API_ENDPOINT = input(\"Please enter your API Endpoint:\")\n", - "ASTRA_DB_APPLICATION_TOKEN = getpass(\"Please enter your Token\")" + "ASTRA_DB_APPLICATION_TOKEN = getpass(\"Please enter your Token:\")\n", + "\n", + "ASTRA_DB_KEYSPACE = input(\"Please enter your namespace. Leave empty for default:\")\n", + "if not ASTRA_DB_KEYSPACE:\n", + " ASTRA_DB_KEYSPACE = None" ] }, { @@ -167,7 +172,7 @@ "outputs": [], "source": [ "astra_db_client = DataAPIClient(token=ASTRA_DB_APPLICATION_TOKEN)\n", - "database = astra_db_client.get_database_by_api_endpoint(ASTRA_DB_API_ENDPOINT)" + "database = astra_db_client.get_database_by_api_endpoint(ASTRA_DB_API_ENDPOINT, namespace=ASTRA_DB_KEYSPACE)" ] }, { @@ -246,18 +251,7 @@ "execution_count": 7, "id": "6bf89454-9a55-4202-ab6b-ea15b2048f3d", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'ok': 1}" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "client = openai.OpenAI(api_key=OPENAI_API_KEY)\n", "embedding_model_name = \"text-embedding-3-small\"\n", @@ -796,7 +790,7 @@ "** end of logging\n", "\n", "A new generated quote:\n", - "- In politics, true virtue is the compass that guides a nation towards righteousness and prosperity.\n" + "- In politics, true virtue is the compass that guides us towards a better society.\n" ] } ], @@ -830,7 +824,7 @@ "** end of logging\n", "\n", "A new generated quote:\n", - "The true measure of humanity lies in our treatment of animals, for in their eyes we see reflections of our own souls.\n" + "The true measure of humanity lies in our treatment of animals, for compassion towards all living beings reflects our moral essence.\n" ] } ], diff --git a/examples/vector_databases/cassandra_astradb/README.md b/examples/vector_databases/cassandra_astradb/README.md index 4033fbe..0997385 100644 --- a/examples/vector_databases/cassandra_astradb/README.md +++ b/examples/vector_databases/cassandra_astradb/README.md @@ -8,8 +8,8 @@ These example notebooks demonstrate implementation of the same GenAI standard RAG workload with different libraries and APIs. To use [Astra DB](https://docs.datastax.com/en/astra/home/astra.html) -with its HTTP API interface, head to the "AstraPy" notebook (`astrapy` -is the Python client to interact with the database). +through its Data API interface, head to the "AstraPy" notebook (`astrapy` +is the Python client for the Data API). If you prefer CQL access to the database (either with [Astra DB](https://docs.datastax.com/en/astra-serverless/docs/vector-search/overview.html)