From 6909b070cd7be03fdc7f267eab971855a81361ee Mon Sep 17 00:00:00 2001 From: Jack Wotherspoon Date: Wed, 3 Apr 2024 17:25:14 -0400 Subject: [PATCH 01/13] chore: update sample in vector_store.ipynb (#110) --- docs/vector_store.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/vector_store.ipynb b/docs/vector_store.ipynb index eb4fa871..8800fff5 100644 --- a/docs/vector_store.ipynb +++ b/docs/vector_store.ipynb @@ -512,7 +512,7 @@ "all_texts = [\"Apples and oranges\", \"Cars and airplanes\", \"Pineapple\", \"Train\", \"Banana\"]\n", "metadatas = [{\"len\": len(t)} for t in all_texts]\n", "ids = [str(uuid.uuid4()) for _ in all_texts]\n", - "await store.aadd_texts(all_texts, metadatas=metadatas, ids=ids)\n", + "await custom_store.aadd_texts(all_texts, metadatas=metadatas, ids=ids)\n", "\n", "# Use filter on search\n", "docs = await custom_store.asimilarity_search_by_vector(query_vector, filter=\"len >= 6\")\n", @@ -545,4 +545,4 @@ }, "nbformat": 4, "nbformat_minor": 0 -} \ No newline at end of file +} From 3ffb40ef7394531df082e21d5ecda9ff92234c80 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Mon, 15 Apr 2024 21:53:04 +0200 Subject: [PATCH 02/13] chore(deps): update dependency idna to v3.7 [security] (#112) --- .kokoro/requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.kokoro/requirements.txt b/.kokoro/requirements.txt index f13a55e6..c2ce28db 100644 --- a/.kokoro/requirements.txt +++ b/.kokoro/requirements.txt @@ -255,9 +255,9 @@ googleapis-common-protos==1.63.0 \ --hash=sha256:17ad01b11d5f1d0171c06d3ba5c04c54474e883b66b949722b4938ee2694ef4e \ --hash=sha256:ae45f75702f7c08b541f750854a678bd8f534a1a6bace6afe975f1d0a82d6632 # via google-api-core -idna==3.6 \ - --hash=sha256:9ecdbbd083b06798ae1e86adcbfe8ab1479cf864e4ee30fe4e46a003d12491ca \ - --hash=sha256:c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f +idna==3.7 \ + --hash=sha256:028ff3aadf0609c1fd278d8ea3089299412a7a8b9bd005dd08b9f8285bcb5cfc \ + --hash=sha256:82fee1fc78add43492d3a1898bfa6d8a904cc97d8427f683ed8e798d07761aa0 # via requests importlib-metadata==6.11.0 \ --hash=sha256:1231cf92d825c9e03cfc4da076a16de6422c863558229ea0b22b675657463443 \ From 26c534221dfb89a190bb1773b32493aae1ddf598 Mon Sep 17 00:00:00 2001 From: Averi Kitsch Date: Mon, 15 Apr 2024 16:06:59 -0700 Subject: [PATCH 03/13] fix: update docs pipeline (#109) * fix: update docs pipeline * move install * fix dockerfile * debug * fix install * Update Dockerfile * Update publish-docs.sh * fix buckets * update bucket * debug * Update publish-docs.sh * Update common.cfg --- .kokoro/docker/docs/Dockerfile | 9 +++---- .kokoro/docker/docs/requirements.in | 1 + .kokoro/docker/docs/requirements.txt | 38 ++++++++++++++++++++++++++++ .kokoro/docs/common.cfg | 6 ++--- .kokoro/publish-docs.sh | 7 ++--- DEVELOPER.md | 12 +++++++-- README.rst | 4 +-- 7 files changed, 62 insertions(+), 15 deletions(-) create mode 100644 .kokoro/docker/docs/requirements.in create mode 100644 .kokoro/docker/docs/requirements.txt diff --git a/.kokoro/docker/docs/Dockerfile b/.kokoro/docker/docs/Dockerfile index d0576288..a26ce619 100644 --- a/.kokoro/docker/docs/Dockerfile +++ b/.kokoro/docker/docs/Dockerfile @@ -60,11 +60,6 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* \ && rm -f /var/cache/apt/archives/*.deb -ENV VERSION v4.2.0 -ENV BINARY yq_linux_amd64 -RUN wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY} -O /usr/bin/yq && \ - chmod +x /usr/bin/yq - ###################### Install python 3.9.13 # Download python 3.9.13 @@ -85,4 +80,8 @@ RUN wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \ # Test pip RUN python3 -m pip +# Install build requirements +COPY requirements.txt /requirements.txt +RUN python3 -m pip install --require-hashes -r requirements.txt + CMD ["python3.8"] diff --git a/.kokoro/docker/docs/requirements.in b/.kokoro/docker/docs/requirements.in new file mode 100644 index 00000000..027bd54a --- /dev/null +++ b/.kokoro/docker/docs/requirements.in @@ -0,0 +1 @@ +nox \ No newline at end of file diff --git a/.kokoro/docker/docs/requirements.txt b/.kokoro/docker/docs/requirements.txt new file mode 100644 index 00000000..177d79b4 --- /dev/null +++ b/.kokoro/docker/docs/requirements.txt @@ -0,0 +1,38 @@ +# +# This file is autogenerated by pip-compile with Python 3.9 +# by the following command: +# +# pip-compile --allow-unsafe --generate-hashes requirements.in +# +argcomplete==3.2.3 \ + --hash=sha256:bf7900329262e481be5a15f56f19736b376df6f82ed27576fa893652c5de6c23 \ + --hash=sha256:c12355e0494c76a2a7b73e3a59b09024ca0ba1e279fb9ed6c1b82d5b74b6a70c + # via nox +colorlog==6.8.2 \ + --hash=sha256:3e3e079a41feb5a1b64f978b5ea4f46040a94f11f0e8bbb8261e3dbbeca64d44 \ + --hash=sha256:4dcbb62368e2800cb3c5abd348da7e53f6c362dda502ec27c560b2e58a66bd33 + # via nox +distlib==0.3.8 \ + --hash=sha256:034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784 \ + --hash=sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64 + # via virtualenv +filelock==3.13.1 \ + --hash=sha256:521f5f56c50f8426f5e03ad3b281b490a87ef15bc6c526f168290f0c7148d44e \ + --hash=sha256:57dbda9b35157b05fb3e58ee91448612eb674172fab98ee235ccb0b5bee19a1c + # via virtualenv +nox==2024.3.2 \ + --hash=sha256:e53514173ac0b98dd47585096a55572fe504fecede58ced708979184d05440be \ + --hash=sha256:f521ae08a15adbf5e11f16cb34e8d0e6ea521e0b92868f684e91677deb974553 + # via -r requirements.in +packaging==24.0 \ + --hash=sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5 \ + --hash=sha256:eb82c5e3e56209074766e6885bb04b8c38a0c015d0a30036ebe7ece34c9989e9 + # via nox +platformdirs==4.2.0 \ + --hash=sha256:0614df2a2f37e1a662acbd8e2b25b92ccf8632929bc6d43467e17fe89c75e068 \ + --hash=sha256:ef0cc731df711022c174543cb70a9b5bd22e5a9337c8624ef2c2ceb8ddad8768 + # via virtualenv +virtualenv==20.25.1 \ + --hash=sha256:961c026ac520bac5f69acb8ea063e8a4f071bcc9457b9c1f28f6b085c511583a \ + --hash=sha256:e08e13ecdca7a0bd53798f356d5831434afa5b07b93f0abdf0797b7a06ffe197 + # via nox \ No newline at end of file diff --git a/.kokoro/docs/common.cfg b/.kokoro/docs/common.cfg index 500e377f..e5ccc1b4 100644 --- a/.kokoro/docs/common.cfg +++ b/.kokoro/docs/common.cfg @@ -25,14 +25,14 @@ env_vars: { env_vars: { key: "STAGING_BUCKET" - value: "docs-staging" + value: "docs-staging" # Used for googleapis.dev } env_vars: { key: "V2_STAGING_BUCKET" # Push non-cloud library docs to `docs-staging-v2-staging` instead of the # Cloud RAD bucket `docs-staging-v2` - value: "docs-staging-v2-staging" + value: "docs-staging-v2" } # It will upload the docker image after successful builds. @@ -64,4 +64,4 @@ before_action { keyname: "docuploader_service_account" } } -} \ No newline at end of file +} diff --git a/.kokoro/publish-docs.sh b/.kokoro/publish-docs.sh index e7480aa5..503f4b28 100755 --- a/.kokoro/publish-docs.sh +++ b/.kokoro/publish-docs.sh @@ -35,7 +35,7 @@ python3 -m docuploader create-metadata \ --name=$(jq --raw-output '.name // empty' .repo-metadata.json) \ --version=$VERSION \ --language=$(jq --raw-output '.language // empty' .repo-metadata.json) \ - --distribution-name=$(yq -oy '.project.name' pyproject.toml) \ + --distribution-name=$(jq --raw-output '.distribution_name // empty' .repo-metadata.json) \ --product-page=$(jq --raw-output '.product_documentation // empty' .repo-metadata.json) \ --github-repository=$(jq --raw-output '.repo // empty' .repo-metadata.json) \ --issue-tracker=$(jq --raw-output '.issue_tracker // empty' .repo-metadata.json) @@ -43,10 +43,11 @@ python3 -m docuploader create-metadata \ cat docs.metadata # upload docs +echo "Uploading docs to ${STAGING_BUCKET}" python3 -m docuploader upload docs/_build/html --metadata-file docs.metadata --staging-bucket "${STAGING_BUCKET}" -# docfx yaml files +# docfx yaml files for CGC nox -s docfx # create metadata. @@ -54,7 +55,7 @@ python3 -m docuploader create-metadata \ --name=$(jq --raw-output '.name // empty' .repo-metadata.json) \ --version=$VERSION \ --language=$(jq --raw-output '.language // empty' .repo-metadata.json) \ - --distribution-name=$(yq -oy '.project.name' pyproject.toml) \ + --distribution-name=$(jq --raw-output '.distribution_name // empty' .repo-metadata.json) \ --product-page=$(jq --raw-output '.product_documentation // empty' .repo-metadata.json) \ --github-repository=$(jq --raw-output '.repo // empty' .repo-metadata.json) \ --issue-tracker=$(jq --raw-output '.issue_tracker // empty' .repo-metadata.json) diff --git a/DEVELOPER.md b/DEVELOPER.md index 679dbd41..3cb0d40b 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -89,9 +89,17 @@ Currently, manual PRs are made to the [Langchain GitHub repo](https://github.com ### API Reference -API docs are templated in the `docs/` directory. See `.kokoro/` for the release pipeline. +#### Build the documentation +API docs are templated in the `docs/` directory. -To test locally, run: `nox -s` +To test locally, run: `nox -s docs` + +The nox session, `docs`, is used to create HTML to publish to googleapis.dev +The nox session, `docfx`, is used to create YAML to publish to CGC. + +#### Publish the documentation + +The kokoro docs pipeline runs when a new release is created. See `.kokoro/` for the release pipeline. [provider]: https://python.langchain.com/docs/integrations/platforms/google diff --git a/README.rst b/README.rst index 592e259e..b28f11ee 100644 --- a/README.rst +++ b/README.rst @@ -58,7 +58,7 @@ Mac/Linux pip install virtualenv virtualenv source /bin/activate - /bin/pip install google-cloud-bigquery + /bin/pip install langchain-google-cloud-sql-pg Windows @@ -69,7 +69,7 @@ Windows pip install virtualenv virtualenv \Scripts\activate - \Scripts\pip.exe install google-cloud-bigquery + \Scripts\pip.exe install langchain-google-cloud-sql-pg Example Usage From ab331f9659230a0ed40d419d29b881afef5704b7 Mon Sep 17 00:00:00 2001 From: Averi Kitsch Date: Tue, 16 Apr 2024 12:10:31 -0700 Subject: [PATCH 04/13] chore: update test deps for 3.8 (#115) * chore: update test deps for 3.8 * fix typo * Update requirements.txt --- integration.cloudbuild.yaml | 8 ++------ requirements-3.8.txt | 6 ------ requirements.txt | 3 ++- 3 files changed, 4 insertions(+), 13 deletions(-) delete mode 100644 requirements-3.8.txt diff --git a/integration.cloudbuild.yaml b/integration.cloudbuild.yaml index ed4d2a27..b375ada7 100644 --- a/integration.cloudbuild.yaml +++ b/integration.cloudbuild.yaml @@ -15,12 +15,8 @@ steps: - id: Install dependencies name: python:${_VERSION} - entrypoint: /bin/bash - args: - - -c - - | - if [[ $_VERSION == "3.8" ]]; then version="-3.8"; fi - pip install --user -r requirements${version}.txt + entrypoint: pip + args: ["install", "--user", "-r", "requirements.txt"] - id: Install module (and test requirements) name: python:${_VERSION} diff --git a/requirements-3.8.txt b/requirements-3.8.txt deleted file mode 100644 index 5c6014e8..00000000 --- a/requirements-3.8.txt +++ /dev/null @@ -1,6 +0,0 @@ -cloud-sql-python-connector[asyncpg]==1.8.0 -langchain-core==0.1.35 -langchain-community==0.0.28 -numpy==1.24.4 -pgvector==0.2.5 -SQLAlchemy==2.0.28 diff --git a/requirements.txt b/requirements.txt index 64224cce..98827dbf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ cloud-sql-python-connector[asyncpg]==1.8.0 langchain-core==0.1.35 langchain-community==0.0.28 -numpy==1.26.4 +numpy==1.24.4; python_version<='3.8' +numpy==1.26.4; python_version>'3.8' pgvector==0.2.5 SQLAlchemy==2.0.28 From d542530f4df6b8dbdb06b2c1ba176df99ae07e2e Mon Sep 17 00:00:00 2001 From: Averi Kitsch Date: Tue, 16 Apr 2024 12:11:27 -0700 Subject: [PATCH 05/13] chore: Update renovate.json5 (#105) * chore: Update renovate.json5 * Update renovate.json5 * Update renovate.json5 * Update renovate.json5 --- .github/renovate.json5 | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 531cae20..868655c3 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -6,14 +6,10 @@ "group:allNonMajor", // https://docs.renovatebot.com/presets-group/#groupallnonmajor ":separateMajorReleases", // https://docs.renovatebot.com/presets-default/#separatemajorreleases ":prConcurrentLimitNone", // View complete backlog as PRs. https://docs.renovatebot.com/presets-default/#prconcurrentlimitnone - ":prNotPending", // https://docs.renovatebot.com/presets-default/#prnotpending ":prHourlyLimitNone", // https://docs.renovatebot.com/presets-default/#prhourlylimitnone ":preserveSemverRanges", ], - - // Synchronized with a 2 week sprint cycle and outside business hours. - // https://docs.renovatebot.com/configuration-options/#schedule - "schedule": ["every 2 weeks on Saturday"], + "ignorePaths": [".kokoro/**"], // Dependabot will make security updates // Give ecosystem time to catch up. // npm allows maintainers to unpublish a release up to 3 days later. From 4790460880093df7d6a69fad0c7125fcd272ac22 Mon Sep 17 00:00:00 2001 From: Averi Kitsch Date: Tue, 16 Apr 2024 12:20:53 -0700 Subject: [PATCH 06/13] fix: Readme.rst rendering (#114) * fix: Readme.rst rendering * use code * use code * use code block --- README.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index b28f11ee..586e7c11 100644 --- a/README.rst +++ b/README.rst @@ -85,7 +85,7 @@ Vector Store Usage Use a Vector Store to store embedded data and perform vector search. -.. code-block:: python +.. code-block:: from langchain_google_cloud_sql_pg import PostgresVectorstore, PostgresEngine from langchain.embeddings import VertexAIEmbeddings @@ -112,7 +112,7 @@ Document Loader Usage Use a document loader to load data as Documents. -.. code-block:: python +.. code-block:: from langchain_google_cloud_sql_pg import PostgresEngine, PostgresLoader @@ -133,7 +133,7 @@ Chat Message History Usage Use Chat Message History to store messages and provide conversation history to LLMs. -.. code-block:: python +.. code-block:: from langchain_google_cloud_sql_pg import PostgresChatMessageHistory, PostgresEngine @@ -150,8 +150,8 @@ See the full `Chat Message History`_ tutorial. .. _`Chat Message History`: https://github.com/googleapis/langchain-google-cloud-sql-pg-python/tree/main/docs/chat_message_history.ipynb -Contributing -~~~~~~~~~~~~ +Contributions +~~~~~~~~~~~~~ Contributions to this library are always welcome and highly encouraged. From 1bc76842b88adbd3d7ecca142e2fac54046bd2c7 Mon Sep 17 00:00:00 2001 From: Averi Kitsch Date: Tue, 16 Apr 2024 12:25:11 -0700 Subject: [PATCH 07/13] fix: doc release pipeline (#116) --- .trampolinerc | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .trampolinerc diff --git a/.trampolinerc b/.trampolinerc new file mode 100644 index 00000000..5a7f8bc2 --- /dev/null +++ b/.trampolinerc @@ -0,0 +1,61 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Add required env vars here. +required_envvars+=( +) + +# Add env vars which are passed down into the container here. +pass_down_envvars+=( + "NOX_SESSION" + ############### + # Docs builds + ############### + "STAGING_BUCKET" + "V2_STAGING_BUCKET" + ################## + # Samples builds + ################## + "INSTALL_LIBRARY_FROM_SOURCE" + "RUN_TESTS_SESSION" + "BUILD_SPECIFIC_GCLOUD_PROJECT" + # Target directories. + "RUN_TESTS_DIRS" + # The nox session to run. + "RUN_TESTS_SESSION" +) + +# Prevent unintentional override on the default image. +if [[ "${TRAMPOLINE_IMAGE_UPLOAD:-false}" == "true" ]] && \ + [[ -z "${TRAMPOLINE_IMAGE:-}" ]]; then + echo "Please set TRAMPOLINE_IMAGE if you want to upload the Docker image." + exit 1 +fi + +# Define the default value if it makes sense. +if [[ -z "${TRAMPOLINE_IMAGE_UPLOAD:-}" ]]; then + TRAMPOLINE_IMAGE_UPLOAD="" +fi + +if [[ -z "${TRAMPOLINE_IMAGE:-}" ]]; then + TRAMPOLINE_IMAGE="" +fi + +if [[ -z "${TRAMPOLINE_DOCKERFILE:-}" ]]; then + TRAMPOLINE_DOCKERFILE="" +fi + +if [[ -z "${TRAMPOLINE_BUILD_FILE:-}" ]]; then + TRAMPOLINE_BUILD_FILE="" +fi \ No newline at end of file From 941e309d21811890cd1b30dca20b99c2eceb339a Mon Sep 17 00:00:00 2001 From: Averi Kitsch Date: Mon, 22 Apr 2024 10:44:12 -0700 Subject: [PATCH 08/13] chore: update code owners (#119) * chore: update code owners * Update sync-repo-settings.yaml --- .github/CODEOWNERS | 2 +- .github/sync-repo-settings.yaml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 39c75e75..b7ca7815 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -3,4 +3,4 @@ # For syntax help see: # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax -* @googleapis/senseai-eco \ No newline at end of file +* @googleapis/senseai-eco @googleapis/langchain-csql-pg \ No newline at end of file diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index d9236153..c40bfe9d 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -43,3 +43,5 @@ branchProtectionRules: permissionRules: - team: senseai-eco permission: admin + - team: langchain-csql-pg + permission: push From d4807603d8573789199f2d277f59ef654e980198 Mon Sep 17 00:00:00 2001 From: Jack Wotherspoon Date: Mon, 29 Apr 2024 14:31:39 -0400 Subject: [PATCH 09/13] fix: update required dep to SQLAlchemy[asyncio] (#121) --- pyproject.toml | 4 ++-- requirements.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 084614cd..7caffb57 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ dependencies = [ "langchain-community>=0.0.18, <0.1.0", "numpy>=1.24.4, <2.0.0", "pgvector>=0.2.5, <1.0.0", - "SQLAlchemy>=2.0.25, <3.0.0" + "SQLAlchemy[asyncio]>=2.0.25, <3.0.0" ] classifiers = [ @@ -64,4 +64,4 @@ warn_unused_configs = true exclude = [ 'docs/*', 'noxfile.py' -] \ No newline at end of file +] diff --git a/requirements.txt b/requirements.txt index 98827dbf..ebb83631 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,4 @@ langchain-community==0.0.28 numpy==1.24.4; python_version<='3.8' numpy==1.26.4; python_version>'3.8' pgvector==0.2.5 -SQLAlchemy==2.0.28 +SQLAlchemy[asyncio]==2.0.28 From 008a995485e00610814268250f4e7dc65a8d6cf0 Mon Sep 17 00:00:00 2001 From: Jack Wotherspoon Date: Tue, 30 Apr 2024 12:16:04 -0400 Subject: [PATCH 10/13] refactor: return early if credentials have service account field (#122) --- src/langchain_google_cloud_sql_pg/engine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/langchain_google_cloud_sql_pg/engine.py b/src/langchain_google_cloud_sql_pg/engine.py index eaa854ee..d24126d1 100644 --- a/src/langchain_google_cloud_sql_pg/engine.py +++ b/src/langchain_google_cloud_sql_pg/engine.py @@ -59,7 +59,7 @@ async def _get_iam_principal_email( request = google.auth.transport.requests.Request() credentials.refresh(request) if hasattr(credentials, "_service_account_email"): - email = credentials._service_account_email + return credentials._service_account_email.replace(".gserviceaccount.com", "") # call OAuth2 api to get IAM principal email associated with OAuth2 token url = f"https://oauth2.googleapis.com/tokeninfo?access_token={credentials.token}" async with aiohttp.ClientSession() as client: From b490c81ea96abca5a8acff1ca10f6ea8380a8ff1 Mon Sep 17 00:00:00 2001 From: Averi Kitsch Date: Tue, 30 Apr 2024 12:56:54 -0700 Subject: [PATCH 11/13] fix: missing quote in table name (#123) * fix: missing quote in table name * fix quote * fix tests * Update vectorstore.py * Update vectorstore.py * Update vectorstore.py --- .../vectorstore.py | 4 +-- tests/test_cloudsql_vectorstore.py | 34 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/langchain_google_cloud_sql_pg/vectorstore.py b/src/langchain_google_cloud_sql_pg/vectorstore.py index 9f8b15b3..221c6249 100644 --- a/src/langchain_google_cloud_sql_pg/vectorstore.py +++ b/src/langchain_google_cloud_sql_pg/vectorstore.py @@ -461,7 +461,7 @@ async def __query_collection( search_function = self.distance_strategy.search_function filter = f"WHERE {filter}" if filter else "" - stmt = f"SELECT *, {search_function}({self.embedding_column}, '{embedding}') as distance FROM {self.table_name} {filter} ORDER BY {self.embedding_column} {operator} '{embedding}' LIMIT {k};" + stmt = f"SELECT *, {search_function}({self.embedding_column}, '{embedding}') as distance FROM \"{self.table_name}\" {filter} ORDER BY {self.embedding_column} {operator} '{embedding}' LIMIT {k};" if self.index_query_options: await self.engine._aexecute( f"SET LOCAL {self.index_query_options.to_string()};" @@ -742,7 +742,7 @@ async def aapply_vector_index( params = "WITH " + index.index_options() function = index.distance_strategy.index_function name = name or index.name - stmt = f"CREATE INDEX {'CONCURRENTLY' if concurrently else ''} {name} ON {self.table_name} USING {index.index_type} ({self.embedding_column} {function}) {params} {filter};" + stmt = f'CREATE INDEX {"CONCURRENTLY" if concurrently else ""} {name} ON "{self.table_name}" USING {index.index_type} ({self.embedding_column} {function}) {params} {filter};' if concurrently: await self.engine._aexecute_outside_tx(stmt) else: diff --git a/tests/test_cloudsql_vectorstore.py b/tests/test_cloudsql_vectorstore.py index 7a20f4a1..eda556fb 100644 --- a/tests/test_cloudsql_vectorstore.py +++ b/tests/test_cloudsql_vectorstore.py @@ -22,8 +22,8 @@ from langchain_google_cloud_sql_pg import Column, PostgresEngine, PostgresVectorStore -DEFAULT_TABLE = "test_table" + str(uuid.uuid4()).replace("-", "_") -DEFAULT_TABLE_SYNC = "test_table_sync" + str(uuid.uuid4()).replace("-", "_") +DEFAULT_TABLE = "test_table" + str(uuid.uuid4()) +DEFAULT_TABLE_SYNC = "test_table_sync" + str(uuid.uuid4()) CUSTOM_TABLE = "test-table-custom" + str(uuid.uuid4()) VECTOR_SIZE = 768 @@ -94,7 +94,7 @@ def vs_sync(self, engine_sync): table_name=DEFAULT_TABLE_SYNC, ) yield vs - engine_sync._execute(f"DROP TABLE IF EXISTS {DEFAULT_TABLE_SYNC}") + engine_sync._execute(f'DROP TABLE IF EXISTS "{DEFAULT_TABLE_SYNC}"') engine_sync._engine.dispose() @pytest_asyncio.fixture(scope="class") @@ -106,7 +106,7 @@ async def vs(self, engine): table_name=DEFAULT_TABLE, ) yield vs - await engine._aexecute(f"DROP TABLE IF EXISTS {DEFAULT_TABLE}") + await engine._aexecute(f'DROP TABLE IF EXISTS "{DEFAULT_TABLE}"') await engine._engine.dispose() @pytest_asyncio.fixture(scope="class") @@ -149,45 +149,45 @@ async def test_post_init(self, engine): async def test_aadd_texts(self, engine, vs): ids = [str(uuid.uuid4()) for i in range(len(texts))] await vs.aadd_texts(texts, ids=ids) - results = await engine._afetch(f"SELECT * FROM {DEFAULT_TABLE}") + results = await engine._afetch(f'SELECT * FROM "{DEFAULT_TABLE}"') assert len(results) == 3 ids = [str(uuid.uuid4()) for i in range(len(texts))] await vs.aadd_texts(texts, metadatas, ids) - results = await engine._afetch(f"SELECT * FROM {DEFAULT_TABLE}") + results = await engine._afetch(f'SELECT * FROM "{DEFAULT_TABLE}"') assert len(results) == 6 - await engine._aexecute(f"TRUNCATE TABLE {DEFAULT_TABLE}") + await engine._aexecute(f'TRUNCATE TABLE "{DEFAULT_TABLE}"') async def test_aadd_texts_edge_cases(self, engine, vs): texts = ["Taylor's", '"Swift"', "best-friend"] ids = [str(uuid.uuid4()) for i in range(len(texts))] await vs.aadd_texts(texts, ids=ids) - results = await engine._afetch(f"SELECT * FROM {DEFAULT_TABLE}") + results = await engine._afetch(f'SELECT * FROM "{DEFAULT_TABLE}"') assert len(results) == 3 - await engine._aexecute(f"TRUNCATE TABLE {DEFAULT_TABLE}") + await engine._aexecute(f'TRUNCATE TABLE "{DEFAULT_TABLE}"') async def test_aadd_docs(self, engine, vs): ids = [str(uuid.uuid4()) for i in range(len(texts))] await vs.aadd_documents(docs, ids=ids) - results = await engine._afetch(f"SELECT * FROM {DEFAULT_TABLE}") + results = await engine._afetch(f'SELECT * FROM "{DEFAULT_TABLE}"') assert len(results) == 3 - await engine._aexecute(f"TRUNCATE TABLE {DEFAULT_TABLE}") + await engine._aexecute(f'TRUNCATE TABLE "{DEFAULT_TABLE}"') async def test_aadd_embedding(self, engine, vs): ids = [str(uuid.uuid4()) for i in range(len(texts))] await vs._aadd_embeddings(texts, embeddings, metadatas, ids) - results = await engine._afetch(f"SELECT * FROM {DEFAULT_TABLE}") + results = await engine._afetch(f'SELECT * FROM "{DEFAULT_TABLE}"') assert len(results) == 3 - await engine._aexecute(f"TRUNCATE TABLE {DEFAULT_TABLE}") + await engine._aexecute(f'TRUNCATE TABLE "{DEFAULT_TABLE}"') async def test_adelete(self, engine, vs): ids = [str(uuid.uuid4()) for i in range(len(texts))] await vs.aadd_texts(texts, ids=ids) - results = await engine._afetch(f"SELECT * FROM {DEFAULT_TABLE}") + results = await engine._afetch(f'SELECT * FROM "{DEFAULT_TABLE}"') assert len(results) == 3 # delete an ID await vs.adelete([ids[0]]) - results = await engine._afetch(f"SELECT * FROM {DEFAULT_TABLE}") + results = await engine._afetch(f'SELECT * FROM "{DEFAULT_TABLE}"') assert len(results) == 2 async def test_aadd_texts_custom(self, engine, vs_custom): @@ -249,13 +249,13 @@ async def test_adelete_custom(self, engine, vs_custom): async def test_add_docs(self, engine_sync, vs_sync): ids = [str(uuid.uuid4()) for i in range(len(texts))] vs_sync.add_documents(docs, ids=ids) - results = engine_sync._fetch(f"SELECT * FROM {DEFAULT_TABLE_SYNC}") + results = engine_sync._fetch(f'SELECT * FROM "{DEFAULT_TABLE_SYNC}"') assert len(results) == 3 async def test_add_texts(self, engine_sync, vs_sync): ids = [str(uuid.uuid4()) for i in range(len(texts))] vs_sync.add_texts(texts, ids=ids) - results = engine_sync._fetch(f"SELECT * FROM {DEFAULT_TABLE_SYNC}") + results = engine_sync._fetch(f'SELECT * FROM "{DEFAULT_TABLE_SYNC}"') assert len(results) == 6 # Need tests for store metadata=False From 1c59d6bf880f2a2755ef5a4f8eab8f7be0b95dc0 Mon Sep 17 00:00:00 2001 From: Averi Kitsch Date: Thu, 2 May 2024 15:20:10 -0700 Subject: [PATCH 12/13] docs: update readme codeblocks (#124) Co-authored-by: Tabby --- README.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 586e7c11..bb534ed4 100644 --- a/README.rst +++ b/README.rst @@ -85,7 +85,7 @@ Vector Store Usage Use a Vector Store to store embedded data and perform vector search. -.. code-block:: +.. code-block:: python from langchain_google_cloud_sql_pg import PostgresVectorstore, PostgresEngine from langchain.embeddings import VertexAIEmbeddings @@ -96,7 +96,7 @@ Use a Vector Store to store embedded data and perform vector search. table_name="my-table", vector_size=768, # Vector size for `VertexAIEmbeddings()` ) - embeddings_service = VertexAIEmbeddings() + embeddings_service = VertexAIEmbeddings(model_name="textembedding-gecko@003") vectorstore = PostgresVectorStore.create_sync( engine, table_name="my-table", @@ -112,7 +112,7 @@ Document Loader Usage Use a document loader to load data as Documents. -.. code-block:: +.. code-block:: python from langchain_google_cloud_sql_pg import PostgresEngine, PostgresLoader @@ -133,7 +133,7 @@ Chat Message History Usage Use Chat Message History to store messages and provide conversation history to LLMs. -.. code-block:: +.. code-block:: python from langchain_google_cloud_sql_pg import PostgresChatMessageHistory, PostgresEngine From c2b74cb3c1b96e4a245936c378adb910929baaee Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 2 May 2024 15:27:08 -0700 Subject: [PATCH 13/13] chore(main): release 0.4.1 (#113) * chore(main): release 0.4.1 * Update CHANGELOG.md --------- Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Averi Kitsch --- CHANGELOG.md | 14 ++++++++++++++ src/langchain_google_cloud_sql_pg/version.py | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 665ec098..739a7fae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## [0.4.1](https://github.com/googleapis/langchain-google-cloud-sql-pg-python/compare/v0.4.0...v0.4.1) (2024-05-02) + + +### Bug Fixes + +* Missing quote in table name ([#123](https://github.com/googleapis/langchain-google-cloud-sql-pg-python/issues/123)) ([b490c81](https://github.com/googleapis/langchain-google-cloud-sql-pg-python/commit/b490c81ea96abca5a8acff1ca10f6ea8380a8ff1)) +* Update required dep to SQLAlchemy[asyncio] ([#121](https://github.com/googleapis/langchain-google-cloud-sql-pg-python/issues/121)) ([d480760](https://github.com/googleapis/langchain-google-cloud-sql-pg-python/commit/d4807603d8573789199f2d277f59ef654e980198)) + + +### Documentation + +* Update readme codeblocks ([#124](https://github.com/googleapis/langchain-google-cloud-sql-pg-python/issues/124)) ([1c59d6b](https://github.com/googleapis/langchain-google-cloud-sql-pg-python/commit/1c59d6bf880f2a2755ef5a4f8eab8f7be0b95dc0)) +* Update docs pipeline ([#109](https://github.com/googleapis/langchain-google-cloud-sql-pg-python/issues/109)) ([26c5342](https://github.com/googleapis/langchain-google-cloud-sql-pg-python/commit/26c534221dfb89a190bb1773b32493aae1ddf598)) + ## [0.4.0](https://github.com/googleapis/langchain-google-cloud-sql-pg-python/compare/v0.3.0...v0.4.0) (2024-04-03) diff --git a/src/langchain_google_cloud_sql_pg/version.py b/src/langchain_google_cloud_sql_pg/version.py index 47d56082..2ebf21c0 100644 --- a/src/langchain_google_cloud_sql_pg/version.py +++ b/src/langchain_google_cloud_sql_pg/version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.4.0" +__version__ = "0.4.1"