Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update Google Spanner Vector Store documentation #27124

Merged
merged 2 commits into from
Oct 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 25 additions & 19 deletions docs/docs/integrations/vectorstores/google_spanner.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
}
],
"source": [
"%pip install --upgrade --quiet langchain-google-spanner"
"%pip install --upgrade --quiet langchain-google-spanner langchain-google-vertexai"
]
},
{
Expand Down Expand Up @@ -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}"
]
},
{
Expand Down Expand Up @@ -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",
")"
]
},
Expand Down Expand Up @@ -262,17 +265,19 @@
" 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",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### 🔐 Add Documents\n",
"#### Add Documents\n",
"To add documents in the vector store."
]
},
Expand All @@ -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."
]
},
Expand All @@ -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."
]
},
Expand All @@ -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."
]
},
Expand All @@ -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."
]
},
Expand Down Expand Up @@ -377,7 +383,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
"version": "3.11.8"
}
},
"nbformat": 4,
Expand Down
Loading