diff --git a/docs/docs/integrations/vectorstores/google_spanner.ipynb b/docs/docs/integrations/vectorstores/google_spanner.ipynb index c7c0d90299c9e..fb06a69296442 100644 --- a/docs/docs/integrations/vectorstores/google_spanner.ipynb +++ b/docs/docs/integrations/vectorstores/google_spanner.ipynb @@ -52,7 +52,7 @@ } ], "source": [ - "%pip install --upgrade --quiet langchain-google-spanner" + "%pip install --upgrade --quiet langchain-google-spanner langchain-google-vertexai" ] }, { @@ -124,7 +124,8 @@ "PROJECT_ID = \"my-project-id\" # @param {type:\"string\"}\n", "\n", "# Set the project id\n", - "!gcloud config set project {PROJECT_ID}" + "!gcloud config set project {PROJECT_ID}\n", + "%env GOOGLE_CLOUD_PROJECT={PROJECT_ID}" ] }, { @@ -194,14 +195,16 @@ " instance_id=INSTANCE,\n", " database_id=DATABASE,\n", " table_name=TABLE_NAME,\n", - " id_column=\"row_id\",\n", - " metadata_columns=[\n", - " TableColumn(name=\"metadata\", type=\"JSON\", is_null=True),\n", - " TableColumn(name=\"title\", type=\"STRING(MAX)\", is_null=False),\n", - " ],\n", - " secondary_indexes=[\n", - " SecondaryIndex(index_name=\"row_id_and_title\", columns=[\"row_id\", \"title\"])\n", - " ],\n", + " # Customize the table creation\n", + " # id_column=\"row_id\",\n", + " # content_column=\"content_column\",\n", + " # metadata_columns=[\n", + " # TableColumn(name=\"metadata\", type=\"JSON\", is_null=True),\n", + " # TableColumn(name=\"title\", type=\"STRING(MAX)\", is_null=False),\n", + " # ],\n", + " # secondary_indexes=[\n", + " # SecondaryIndex(index_name=\"row_id_and_title\", columns=[\"row_id\", \"title\"])\n", + " # ],\n", ")" ] }, @@ -262,9 +265,11 @@ " instance_id=INSTANCE,\n", " database_id=DATABASE,\n", " table_name=TABLE_NAME,\n", - " ignore_metadata_columns=[],\n", " embedding_service=embeddings,\n", - " metadata_json_column=\"metadata\",\n", + " # Connect to a custom vector store table\n", + " # id_column=\"row_id\",\n", + " # content_column=\"content\",\n", + " # metadata_columns=[\"metadata\", \"title\"],\n", ")" ] }, @@ -272,7 +277,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "#### 🔐 Add Documents\n", + "#### Add Documents\n", "To add documents in the vector store." ] }, @@ -289,14 +294,15 @@ "loader = HNLoader(\"https://news.ycombinator.com/item?id=34817881\")\n", "\n", "documents = loader.load()\n", - "ids = [str(uuid.uuid4()) for _ in range(len(documents))]" + "ids = [str(uuid.uuid4()) for _ in range(len(documents))]\n", + "db.add_documents(documents, ids)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "#### 🔐 Search Documents\n", + "#### Search Documents\n", "To search documents in the vector store with similarity search." ] }, @@ -313,7 +319,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "#### 🔐 Search Documents\n", + "#### Search Documents\n", "To search documents in the vector store with max marginal relevance search." ] }, @@ -330,7 +336,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "#### 🔐 Delete Documents\n", + "#### Delete Documents\n", "To remove documents from the vector store, use the IDs that correspond to the values in the `row_id`` column when initializing the VectorStore." ] }, @@ -347,7 +353,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "#### 🔐 Delete Documents\n", + "#### Delete Documents\n", "To remove documents from the vector store, you can utilize the documents themselves. The content column and metadata columns provided during VectorStore initialization will be used to find out the rows corresponding to the documents. Any matching rows will then be deleted." ] }, @@ -377,7 +383,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.6" + "version": "3.11.8" } }, "nbformat": 4,