docs: update Google Spanner Vector Store documentation (#27124)

Thank you for contributing to LangChain!

- [X] **PR title**: "package: description"
- Where "package" is whichever of langchain, community, core, etc. is
being modified. Use "docs: ..." for purely docs changes, "templates:
..." for template changes, "infra: ..." for CI changes.
  - Example: "community: add foobar LLM"


- [x] **PR message**: ***Delete this entire checklist*** and replace
with
    - **Description:** Update Spanner VS integration doc
    - **Issue:** None
    - **Dependencies:** None
    - **Twitter handle:** NA


- [x] **Add tests and docs**: If you're adding a new integration, please
include
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in
`docs/docs/integrations` directory.


- [x] **Lint and test**: Run `make format`, `make lint` and `make test`
from the root of the package(s) you've modified. See contribution
guidelines for more: https://python.langchain.com/docs/contributing/

Additional guidelines:
- Make sure optional dependencies are imported within a function.
- Please do not add dependencies to pyproject.toml files (even optional
ones) unless they are required for unit tests.
- Most PRs should not touch more than one package.
- Changes should be backwards compatible.
- If you are adding something to community, do not re-import it in
langchain.

If no one reviews your PR within a few days, please @-mention one of
baskaryan, efriis, eyurtsev, ccurme, vbarda, hwchase17.

Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
Averi Kitsch 2024-10-04 16:59:10 -07:00 committed by GitHub
parent 06ce5d1d5c
commit 7a07196df6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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,